use super::*;
use crate::linter::shell_type::ShellType;
#[test]
fn test_batch9_exit_code_patterns_universal() {
let exit_code_rules = vec!["SC2181", "SC2182"];
for rule in exit_code_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch9_assignment_expansion_universal() {
let universal_rules = vec![
"SC2183", "SC2184", "SC2185", "SC2186", "SC2187", "SC2188", "SC2189", "SC2192", "SC2193",
"SC2194", "SC2195", "SC2196", "SC2197",
];
for rule in universal_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch9_universal_count() {
let universal_rules = vec![
"SC2181", "SC2182", "SC2183", "SC2184", "SC2185", "SC2186", "SC2187", "SC2188", "SC2189", "SC2192", "SC2193", "SC2194", "SC2195", "SC2196", "SC2197",
];
let unique_count = universal_rules.len();
assert_eq!(unique_count, 15, "Batch 9 should have 15 Universal rules");
for rule in universal_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
}
let notsh_rules = vec![
"SC2178", "SC2179", "SC2180", "SC2190", "SC2191", ];
for rule in notsh_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::NotSh),
"{} should be NotSh (array operations)",
rule
);
}
}
#[test]
fn test_batch10_array_quoting_notsh() {
let array_rules = vec!["SC2206", "SC2207"];
for rule in array_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::NotSh),
"{} should be NotSh (arrays are bash/zsh/ksh specific)",
rule
);
assert!(
!should_apply_rule(rule, ShellType::Sh),
"{} should not apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch10_command_structure_universal() {
let command_rules = vec![
"SC2202", "SC2203", "SC2204", "SC2205", "SC2208", "SC2209", "SC2216", "SC2217",
];
for rule in command_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch10_arithmetic_operations_universal() {
let arithmetic_rules = vec!["SC2210", "SC2211", "SC2214", "SC2215", "SC2220", "SC2221"];
for rule in arithmetic_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch10_control_flow_universal() {
let control_flow_rules = vec!["SC2212", "SC2213", "SC2218", "SC2219"];
for rule in control_flow_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch10_universal_count() {
let universal_rules = vec![
"SC2202", "SC2203", "SC2204", "SC2205", "SC2208", "SC2209", "SC2216", "SC2217",
"SC2210", "SC2211", "SC2214", "SC2215", "SC2220", "SC2221",
"SC2212", "SC2213", "SC2218", "SC2219",
];
let unique_count = universal_rules.len();
assert_eq!(unique_count, 18, "Batch 10 should have 18 Universal rules");
for rule in universal_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
}
let notsh_rules = vec![
"SC2206", "SC2207", ];
for rule in notsh_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::NotSh),
"{} should be NotSh (array operations)",
rule
);
}
}
#[test]
fn test_batch11_case_statement_syntax_universal() {
let case_rules = vec!["SC2222", "SC2223"];
for rule in case_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal (case is POSIX)",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch11_control_flow_universal() {
let control_flow_rules = vec!["SC2224", "SC2225", "SC2226", "SC2227", "SC2228", "SC2229"];
for rule in control_flow_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch11_command_portability_universal() {
let portability_rules = vec!["SC2230", "SC2231", "SC2232", "SC2233", "SC2234"];
for rule in portability_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal (POSIX portability)",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch11_quoting_safety_universal() {
let quoting_rules = vec![
"SC2235", "SC2236", "SC2237", "SC2238", "SC2239", "SC2240", "SC2241",
];
for rule in quoting_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"{} should be Universal (quoting is universal)",
rule
);
assert!(
should_apply_rule(rule, ShellType::Bash),
"{} should apply to bash",
rule
);
assert!(
should_apply_rule(rule, ShellType::Sh),
"{} should apply to sh",
rule
);
assert!(
should_apply_rule(rule, ShellType::Zsh),
"{} should apply to zsh",
rule
);
}
}
#[test]
fn test_batch11_universal_count() {
let batch11_rules = vec![
"SC2222", "SC2223", "SC2224", "SC2225", "SC2226", "SC2227", "SC2228", "SC2229",
"SC2230", "SC2231", "SC2232", "SC2233", "SC2234", "SC2235", "SC2236", "SC2237", "SC2238", "SC2239", "SC2240", "SC2241",
];
for rule in &batch11_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal),
"Batch 11 rule {} should be Universal",
rule
);
}
assert_eq!(batch11_rules.len(), 20);
}
#[test]
fn test_batch12_control_flow_universal() {
let control_rules = vec!["SC2242", "SC2243", "SC2244", "SC2245", "SC2246"];
for rule in control_rules {
assert_eq!(
get_rule_compatibility(rule),
Some(ShellCompatibility::Universal)
);
assert!(should_apply_rule(rule, ShellType::Bash));
assert!(should_apply_rule(rule, ShellType::Sh));
assert!(should_apply_rule(rule, ShellType::Zsh));
}
}
include!("rule_registry_tests_part2_incl2.rs");