pub module statement_test; pub fn test_var_decl() { let x = 42; assert_eq!(x, 42); let y i32 = 10; assert_eq!(y, 10); let name *str = "mist"; assert_eq!(name, "mist"); } pub fn test_var_decl_with_init() { let mut x = 0; x = 5; assert_eq!(x, 5); } pub fn test_if_statement() { let mut x = 0; if true { x = 1; } assert_eq!(x, 1); if false { x = 2; } else { x = 3; } assert_eq!(x, 3); } pub fn test_if_else_if() { let mut x = 0; if x == 1 { x = 10; } else if x == 0 { x = 20; } else { x = 30; } assert_eq!(x, 20); } pub fn test_while_loop() { let mut count = 0; while count < 5 { count++; } assert_eq!(count, 5); } pub fn test_for_loop() { let mut sum = 0; for i in 0..4 { sum += i; } assert_eq!(sum, 6); } pub fn test_loop_stmt() { let mut count = 0; loop { count++; if count >= 3 { break; } } assert_eq!(count, 3); } pub fn test_break_continue() { let mut sum = 0; for i in 0..10 { if i % 2 == 0 { continue; } if i >= 7 { break; } sum += i; } assert_eq!(sum, 1 + 3 + 5); } pub fn test_return_from_fn() i32 { return 42; } pub fn test_block_scope() { let x = { let inner = 10; inner + 5 }; assert_eq!(x, 15); } pub fn test_match_literal() { let x = 2; let result; match x { 1 => { result = 10; } 2 => { result = 20; } 3 => { result = 30; } _ => panic!(); } assert_eq!(result, 20); } pub fn test_match_or_pattern() { let x = 1; let result i32; match x { 1 | 2 => { result = 100; } 3 => { result = 200; } _ => panic!(); } assert_eq!(result, 100); } pub fn test_match_default() { let x = 99; let result; match x { 1 => { result = 10; } y => { result = y; } } assert_eq!(result, 99); } pub fn test_for_with_pattern_destructure() { let pairs = [(1, "a"), (2, "b")]; let mut keys = 0; for [k, _] in pairs { keys += k; } assert_eq!(keys, 3); } pub fn run_tests() { test_var_decl(); test_var_decl_with_init(); test_if_statement(); test_if_else_if(); test_while_loop(); test_for_loop(); test_loop_stmt(); test_break_continue(); assert_eq!(test_return_from_fn(), 42); test_block_scope(); test_match_literal(); test_match_or_pattern(); test_match_default(); test_for_with_pattern_destructure(); }