|
3 | 3 | use cirru_parser::{parse, print_error}; |
4 | 4 |
|
5 | 5 | fn main() { |
6 | | - println!("🔍 Testing escape_debug in error messages\n"); |
7 | | - println!("{}\n", "═".repeat(70)); |
| 6 | + println!("🔍 Testing escape_debug in error messages\n"); |
| 7 | + println!("{}\n", "═".repeat(70)); |
8 | 8 |
|
9 | | - // Test 1: Newline in string |
10 | | - println!("Test 1: Newline character in string"); |
11 | | - let code1 = "defn test\n print \"hello\nworld\""; |
12 | | - println!("Code: {code1:?}\n"); |
13 | | - if let Err(e) = parse(code1) { |
14 | | - print_error(&e, Some(code1)); |
15 | | - } |
16 | | - println!("\n{}\n", "─".repeat(70)); |
| 9 | + // Test 1: Newline in string |
| 10 | + println!("Test 1: Newline character in string"); |
| 11 | + let code1 = "defn test\n print \"hello\nworld\""; |
| 12 | + println!("Code: {code1:?}\n"); |
| 13 | + if let Err(e) = parse(code1) { |
| 14 | + print_error(&e, Some(code1)); |
| 15 | + } |
| 16 | + println!("\n{}\n", "─".repeat(70)); |
17 | 17 |
|
18 | | - // Test 2: Tab indentation error |
19 | | - println!("Test 2: Tab character causing indentation issue"); |
20 | | - let code2 = "defn test\n\tabc"; // Tab character |
21 | | - println!("Code: {code2:?}\n"); |
22 | | - if let Err(e) = parse(code2) { |
23 | | - print_error(&e, Some(code2)); |
24 | | - } |
25 | | - println!("\n{}\n", "─".repeat(70)); |
| 18 | + // Test 2: Tab indentation error |
| 19 | + println!("Test 2: Tab character causing indentation issue"); |
| 20 | + let code2 = "defn test\n\tabc"; // Tab character |
| 21 | + println!("Code: {code2:?}\n"); |
| 22 | + if let Err(e) = parse(code2) { |
| 23 | + print_error(&e, Some(code2)); |
| 24 | + } |
| 25 | + println!("\n{}\n", "─".repeat(70)); |
26 | 26 |
|
27 | | - // Test 3: Multiple spaces (odd indentation) |
28 | | - println!("Test 3: Odd number of spaces (visible with escape_debug)"); |
29 | | - let code3 = "defn test\n abc\n def"; // 3 spaces |
30 | | - println!("Code: {code3:?}\n"); |
31 | | - if let Err(e) = parse(code3) { |
32 | | - print_error(&e, Some(code3)); |
33 | | - } |
34 | | - println!("\n{}\n", "─".repeat(70)); |
| 27 | + // Test 3: Multiple spaces (odd indentation) |
| 28 | + println!("Test 3: Odd number of spaces (visible with escape_debug)"); |
| 29 | + let code3 = "defn test\n abc\n def"; // 3 spaces |
| 30 | + println!("Code: {code3:?}\n"); |
| 31 | + if let Err(e) = parse(code3) { |
| 32 | + print_error(&e, Some(code3)); |
| 33 | + } |
| 34 | + println!("\n{}\n", "─".repeat(70)); |
35 | 35 |
|
36 | | - // Test 4: Mixed whitespace |
37 | | - println!("Test 4: Carriage return in string"); |
38 | | - let code4 = "print \"hello\rworld\""; |
39 | | - println!("Code: {code4:?}\n"); |
40 | | - match parse(code4) { |
41 | | - Ok(_) => println!("✅ Parsed successfully (\\r is valid in identifier)"), |
42 | | - Err(e) => print_error(&e, Some(code4)), |
43 | | - } |
44 | | - println!("\n{}\n", "─".repeat(70)); |
| 36 | + // Test 4: Mixed whitespace |
| 37 | + println!("Test 4: Carriage return in string"); |
| 38 | + let code4 = "print \"hello\rworld\""; |
| 39 | + println!("Code: {code4:?}\n"); |
| 40 | + match parse(code4) { |
| 41 | + Ok(_) => println!("✅ Parsed successfully (\\r is valid in identifier)"), |
| 42 | + Err(e) => print_error(&e, Some(code4)), |
| 43 | + } |
| 44 | + println!("\n{}\n", "─".repeat(70)); |
45 | 45 |
|
46 | | - // Test 5: Long line with special chars |
47 | | - println!("Test 5: Long line with special characters and error"); |
48 | | - let code5 = "defn process-long-text (data)\n let result \"This is a very long string with \\t tabs and \\n newlines \\x error\""; |
49 | | - println!("Code: {code5:?}\n"); |
50 | | - if let Err(e) = parse(code5) { |
51 | | - print_error(&e, Some(code5)); |
52 | | - } |
53 | | - println!("\n{}\n", "─".repeat(70)); |
| 46 | + // Test 5: Long line with special chars |
| 47 | + println!("Test 5: Long line with special characters and error"); |
| 48 | + let code5 = "defn process-long-text (data)\n let result \"This is a very long string with \\t tabs and \\n newlines \\x error\""; |
| 49 | + println!("Code: {code5:?}\n"); |
| 50 | + if let Err(e) = parse(code5) { |
| 51 | + print_error(&e, Some(code5)); |
| 52 | + } |
| 53 | + println!("\n{}\n", "─".repeat(70)); |
54 | 54 |
|
55 | | - // Test 6: Unicode with newline |
56 | | - println!("Test 6: Unicode escape with newline nearby"); |
57 | | - let code6 = "print \"emoji \\u{1F600}\ntext\""; |
58 | | - println!("Code: {code6:?}\n"); |
59 | | - if let Err(e) = parse(code6) { |
60 | | - print_error(&e, Some(code6)); |
61 | | - } |
62 | | - println!("\n{}\n", "─".repeat(70)); |
| 55 | + // Test 6: Unicode with newline |
| 56 | + println!("Test 6: Unicode escape with newline nearby"); |
| 57 | + let code6 = "print \"emoji \\u{1F600}\ntext\""; |
| 58 | + println!("Code: {code6:?}\n"); |
| 59 | + if let Err(e) = parse(code6) { |
| 60 | + print_error(&e, Some(code6)); |
| 61 | + } |
| 62 | + println!("\n{}\n", "─".repeat(70)); |
63 | 63 |
|
64 | | - // Test 7: Indentation with spaces visible |
65 | | - println!("Test 7: Clear space visualization"); |
66 | | - let code7 = "defn main\n line1\n line2\n line3"; // 5 spaces on line3 |
67 | | - println!("Code with explicit spaces: 'defn main\\n line1\\n line2\\n line3'\n"); |
68 | | - if let Err(e) = parse(code7) { |
69 | | - print_error(&e, Some(code7)); |
70 | | - } |
| 64 | + // Test 7: Indentation with spaces visible |
| 65 | + println!("Test 7: Clear space visualization"); |
| 66 | + let code7 = "defn main\n line1\n line2\n line3"; // 5 spaces on line3 |
| 67 | + println!("Code with explicit spaces: 'defn main\\n line1\\n line2\\n line3'\n"); |
| 68 | + if let Err(e) = parse(code7) { |
| 69 | + print_error(&e, Some(code7)); |
| 70 | + } |
71 | 71 |
|
72 | | - println!("\n{}\n", "═".repeat(70)); |
73 | | - println!("✨ Now you can clearly see:"); |
74 | | - println!(" • \\n for newlines"); |
75 | | - println!(" • \\t for tabs"); |
76 | | - println!(" • Spaces are preserved and visible"); |
77 | | - println!(" • Special escape sequences are shown"); |
78 | | - println!(" • Context window is ~60 chars (increased from 40)"); |
| 72 | + println!("\n{}\n", "═".repeat(70)); |
| 73 | + println!("✨ Now you can clearly see:"); |
| 74 | + println!(" • \\n for newlines"); |
| 75 | + println!(" • \\t for tabs"); |
| 76 | + println!(" • Spaces are preserved and visible"); |
| 77 | + println!(" • Special escape sequences are shown"); |
| 78 | + println!(" • Context window is ~60 chars (increased from 40)"); |
79 | 79 | } |
0 commit comments