also looking at this
fix(interpreter): decode escape sequences in interpolated strings
#934
2 files
+35
-5
| @@ -89,6 +89,28 @@ test "eval: finite recursive calls remain valid" { | ||
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | test "eval: interpolated strings decode escape sequences" { | |
| 93 | try runProgram( | |
| 94 | \\fn main() { | |
| 95 | \\ let x = 1 | |
| 96 | \\ assert(len("\n${x}") == 2) | |
| 97 | \\ assert("a\t${x}\tb" == "a\t1\tb") | |
| 98 | \\ assert("q: \"${x}\"" == "q: \"1\"") | |
| 99 | \\ assert(len("\${x} is ${x}") == 9) | |
| 100 | \\} | |
| 101 | ); | |
| 102 | } | |
| 103 | ||
| 104 | test "eval: raw and triple-quoted strings keep a backslash before $" { | |
| 105 | try runProgram( | |
| 106 | \\fn main() { | |
| 107 | \\ assert(r"\$".contains("\\")) | |
| 108 | \\ assert(r#"\$"#.contains("\\")) | |
| 109 | \\ assert("""\$""".contains("\\")) | |
| 110 | \\} | |
| 111 | ); | |
| 112 | } | |
| 113 | ||
| 92 | 114 | test "eval: runaway user recursion returns a runtime error" { |
| 93 | 115 | try testing.expectError(error.RuntimeError, runProgram( |
| 94 | 116 | \\fn recurse(n: i32): i32 { |