(t *testing.T)
| 240 | } |
| 241 | |
| 242 | func TestEscapeStringLiterals(t *testing.T) { |
| 243 | // Test single-quoted strings |
| 244 | testEscapeStringLiterals(t, `'\1\2'`, `'\\1\\2'`) |
| 245 | testEscapeStringLiterals(t, `'\n\t'`, `'\\n\\t'`) |
| 246 | testEscapeStringLiterals(t, `'\\already\\escaped'`, `'\\\\already\\\\escaped'`) |
| 247 | |
| 248 | // Test double-quoted strings |
| 249 | testEscapeStringLiterals(t, `"\1\2"`, `"\\1\\2"`) |
| 250 | testEscapeStringLiterals(t, `"\n\t"`, `"\\n\\t"`) |
| 251 | |
| 252 | // Test expressions with string literals |
| 253 | testEscapeStringLiterals(t, `regexMatch('\1\2', p.obj)`, `regexMatch('\\1\\2', p.obj)`) |
| 254 | testEscapeStringLiterals(t, `regexMatch("\1\2", p.obj)`, `regexMatch("\\1\\2", p.obj)`) |
| 255 | testEscapeStringLiterals(t, `r.sub == '\test'`, `r.sub == '\\test'`) |
| 256 | |
| 257 | // Test expressions without string literals |
| 258 | testEscapeStringLiterals(t, `r.sub == p.sub`, `r.sub == p.sub`) |
| 259 | testEscapeStringLiterals(t, `keyMatch(r.obj, p.obj)`, `keyMatch(r.obj, p.obj)`) |
| 260 | |
| 261 | // Test multiple strings in one expression |
| 262 | testEscapeStringLiterals(t, `regexMatch('\1', '\2')`, `regexMatch('\\1', '\\2')`) |
| 263 | |
| 264 | // Test empty strings |
| 265 | testEscapeStringLiterals(t, `''`, `''`) |
| 266 | testEscapeStringLiterals(t, `""`, `""`) |
| 267 | |
| 268 | // Test strings with no backslashes |
| 269 | testEscapeStringLiterals(t, `'hello'`, `'hello'`) |
| 270 | testEscapeStringLiterals(t, `"world"`, `"world"`) |
| 271 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…