#[test]
fn test_REPL_007_MUTATION_002_greater_than_or_equal() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "10".to_string());
let bp_gt = Breakpoint::with_condition(5, "$count >= 5".to_string());
assert!(
bp_gt.should_break(&vars),
"Should break when count (10) >= 5 (greater than threshold)"
);
vars.insert("count".to_string(), "5".to_string());
let bp_eq = Breakpoint::with_condition(5, "$count >= 5".to_string());
assert!(
bp_eq.should_break(&vars),
"Should break when count (5) >= 5 (equal to threshold)"
);
vars.insert("count".to_string(), "3".to_string());
let bp_lt = Breakpoint::with_condition(5, "$count >= 5".to_string());
assert!(
!bp_lt.should_break(&vars),
"Should NOT break when count (3) >= 5 (less than threshold)"
);
vars.insert("count".to_string(), "100".to_string());
let bp_large = Breakpoint::with_condition(5, "$count >= 99".to_string());
assert!(
bp_large.should_break(&vars),
"Should break when count (100) >= 99 (multi-digit value parsing)"
);
vars.insert("count".to_string(), "0".to_string());
let bp_zero = Breakpoint::with_condition(5, "$count >= 0".to_string());
assert!(
bp_zero.should_break(&vars),
"Should break when count (0) >= 0 (zero boundary)"
);
}
#[test]
fn test_REPL_007_MUTATION_003_less_than_or_equal() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "3".to_string());
let bp_lt = Breakpoint::with_condition(5, "$count <= 5".to_string());
assert!(
bp_lt.should_break(&vars),
"Should break when count (3) <= 5 (less than threshold)"
);
vars.insert("count".to_string(), "5".to_string());
let bp_eq = Breakpoint::with_condition(5, "$count <= 5".to_string());
assert!(
bp_eq.should_break(&vars),
"Should break when count (5) <= 5 (equal to threshold)"
);
vars.insert("count".to_string(), "10".to_string());
let bp_gt = Breakpoint::with_condition(5, "$count <= 5".to_string());
assert!(
!bp_gt.should_break(&vars),
"Should NOT break when count (10) <= 5 (greater than threshold)"
);
vars.insert("count".to_string(), "50".to_string());
let bp_large = Breakpoint::with_condition(5, "$count <= 99".to_string());
assert!(
bp_large.should_break(&vars),
"Should break when count (50) <= 99 (multi-digit value parsing)"
);
vars.insert("count".to_string(), "0".to_string());
let bp_zero = Breakpoint::with_condition(5, "$count <= 0".to_string());
assert!(
bp_zero.should_break(&vars),
"Should break when count (0) <= 0 (zero boundary)"
);
vars.insert("count".to_string(), "-5".to_string());
let bp_neg = Breakpoint::with_condition(5, "$count <= 0".to_string());
assert!(
bp_neg.should_break(&vars),
"Should break when count (-5) <= 0 (negative value)"
);
}
#[test]
fn test_REPL_007_MUTATION_004_less_than_boundary() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "3".to_string());
let bp_lt = Breakpoint::with_condition(5, "$count < 5".to_string());
assert!(
bp_lt.should_break(&vars),
"Should break when count (3) < 5 (less than threshold)"
);
vars.insert("count".to_string(), "5".to_string());
let bp_eq = Breakpoint::with_condition(5, "$count < 5".to_string());
assert!(
!bp_eq.should_break(&vars),
"Should NOT break when count (5) < 5 (EQUAL to threshold) - catches `<` → `<=` mutant"
);
vars.insert("count".to_string(), "10".to_string());
let bp_gt = Breakpoint::with_condition(5, "$count < 5".to_string());
assert!(
!bp_gt.should_break(&vars),
"Should NOT break when count (10) < 5 (greater than threshold)"
);
vars.insert("count".to_string(), "50".to_string());
let bp_large = Breakpoint::with_condition(5, "$count < 99".to_string());
assert!(
bp_large.should_break(&vars),
"Should break when count (50) < 99 (multi-digit value parsing)"
);
vars.insert("count".to_string(), "0".to_string());
let bp_zero = Breakpoint::with_condition(5, "$count < 0".to_string());
assert!(
!bp_zero.should_break(&vars),
"Should NOT break when count (0) < 0 (zero boundary - equal case)"
);
}
#[test]
fn test_REPL_007_002_conditional_false() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "5".to_string());
let bp = Breakpoint::with_condition(5, "$count > 10".to_string());
assert!(
!bp.should_break(&vars),
"Should not break when count (5) <= 10"
);
}
#[test]
fn test_REPL_007_002_conditional_invalid() {
let vars = HashMap::new();
let bp1 = Breakpoint::with_condition(5, "$missing > 10".to_string());
assert!(
!bp1.should_break(&vars),
"Should not break with missing variable"
);
let bp2 = Breakpoint::with_condition(5, "invalid syntax".to_string());
assert!(
!bp2.should_break(&vars),
"Should not break with invalid syntax"
);
}
#[test]
fn test_REPL_007_002_string_equality() {
let mut vars = HashMap::new();
vars.insert("status".to_string(), "running".to_string());
let bp_eq = Breakpoint::with_condition(5, "$status == running".to_string());
assert!(
bp_eq.should_break(&vars),
"Should break when status == running"
);
let bp_ne = Breakpoint::with_condition(5, "$status != stopped".to_string());
assert!(
bp_ne.should_break(&vars),
"Should break when status != stopped"
);
let bp_ne_false = Breakpoint::with_condition(5, "$status != running".to_string());
assert!(
!bp_ne_false.should_break(&vars),
"Should not break when status == running (but checking !=)"
);
}
#[test]
fn test_REPL_007_002_less_than() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "5".to_string());
let bp_lt = Breakpoint::with_condition(5, "$count < 10".to_string());
assert!(
bp_lt.should_break(&vars),
"Should break when count (5) < 10"
);
let bp_lt_false = Breakpoint::with_condition(5, "$count < 3".to_string());
assert!(
!bp_lt_false.should_break(&vars),
"Should not break when count (5) >= 3"
);
}
#[test]
fn test_REPL_007_002_disabled_conditional() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "15".to_string());
let mut bp = Breakpoint::with_condition(5, "$count > 10".to_string());
bp.disable();
assert!(
!bp.should_break(&vars),
"Disabled breakpoint should not trigger even if condition is true"
);
}
#[test]
fn test_REPL_007_003_hit_count_trigger() {
let vars = HashMap::new();
let mut bp = Breakpoint::with_hit_count(5, 3);
assert!(
!bp.should_break_with_hit(&vars),
"Should not break on hit 1"
);
assert!(
!bp.should_break_with_hit(&vars),
"Should not break on hit 2"
);
assert!(bp.should_break_with_hit(&vars), "Should break on hit 3");
assert!(bp.should_break_with_hit(&vars), "Should break on hit 4");
}
#[test]
fn test_REPL_007_003_hit_count_not_reached() {
let vars = HashMap::new();
let mut bp = Breakpoint::with_hit_count(5, 5);
for i in 1..=4 {
assert!(
!bp.should_break_with_hit(&vars),
"Should not break on hit {}",
i
);
}
assert!(bp.should_break_with_hit(&vars), "Should break on hit 5");
}
#[test]
fn test_REPL_007_003_hit_count_reset() {
let vars = HashMap::new();
let mut bp = Breakpoint::with_hit_count(5, 2);
assert!(
!bp.should_break_with_hit(&vars),
"Should not break on hit 1"
);
assert!(bp.should_break_with_hit(&vars), "Should break on hit 2");
bp.reset_hit_count();
assert!(
!bp.should_break_with_hit(&vars),
"Should not break after reset"
);
assert!(
bp.should_break_with_hit(&vars),
"Should break on hit 2 after reset"
);
}
#[test]
fn test_REPL_007_003_hit_count_with_condition() {
let mut vars = HashMap::new();
vars.insert("count".to_string(), "15".to_string());
let mut bp = Breakpoint::with_hit_count_and_condition(5, 2, "$count > 10".to_string());
assert!(
!bp.should_break_with_hit(&vars),
"Should not break: condition true but hit count = 1"
);
assert!(
bp.should_break_with_hit(&vars),
"Should break: condition true and hit count = 2"
);
}
#[test]
fn test_REPL_007_003_get_hit_count() {
let vars = HashMap::new();
let mut bp = Breakpoint::with_hit_count(5, 3);
assert_eq!(bp.get_hit_count(), 0, "Initial hit count should be 0");
bp.should_break_with_hit(&vars);
assert_eq!(
bp.get_hit_count(),
1,
"Hit count should be 1 after first hit"
);
bp.should_break_with_hit(&vars);
assert_eq!(
bp.get_hit_count(),
2,
"Hit count should be 2 after second hit"
);
bp.should_break_with_hit(&vars);
assert_eq!(
bp.get_hit_count(),
3,
"Hit count should be 3 after third hit"
);
}
#[test]
fn test_REPL_007_003_disabled_hit_count() {
let vars = HashMap::new();
let mut bp = Breakpoint::with_hit_count(5, 2);
bp.disable();
assert!(
!bp.should_break_with_hit(&vars),
"Should not break when disabled"
);
assert!(
!bp.should_break_with_hit(&vars),
"Should not break when disabled"
);
assert!(
!bp.should_break_with_hit(&vars),
"Should not break when disabled"
);
}