better escape code support
This commit is contained in:
+30
-7
@@ -1257,6 +1257,29 @@ main func() void {}
|
||||
testing.expect_value(t, module.imports[2].path, "dir\"name\\tail")
|
||||
}
|
||||
|
||||
@(test)
|
||||
honey_hex_byte_string_escapes_decode_to_bytes :: proc(t: ^testing.T) {
|
||||
text := `value :: "\x1b[31m\x00\xFf"
|
||||
main func() void {}
|
||||
`
|
||||
source_file := source.Source{path="test.hon", text=text}
|
||||
diagnostics := source.init_diagnostics(&source_file)
|
||||
defer source.destroy_diagnostics(&diagnostics)
|
||||
symbols := symbol.init_table()
|
||||
defer symbol.destroy_table(&symbols)
|
||||
stream := lexer.lex(&source_file, &diagnostics, &symbols)
|
||||
defer delete(stream.items)
|
||||
module := parser.parse(&stream, &source_file, &diagnostics)
|
||||
defer ast.destroy_module(&module)
|
||||
|
||||
testing.expect_value(t, len(diagnostics.items), 0)
|
||||
testing.expect_value(t, len(module.strings), 1)
|
||||
testing.expect_value(t, len(module.strings[0]), 7)
|
||||
testing.expect_value(t, module.strings[0][0], byte(0x1b))
|
||||
testing.expect_value(t, module.strings[0][5], byte(0))
|
||||
testing.expect_value(t, module.strings[0][6], byte(0xff))
|
||||
}
|
||||
|
||||
@(test)
|
||||
parser_accepts_chained_field_access :: proc(t: ^testing.T) {
|
||||
text := `main func() void {
|
||||
@@ -1278,7 +1301,7 @@ parser_accepts_chained_field_access :: proc(t: ^testing.T) {
|
||||
|
||||
@(test)
|
||||
lexer_diagnoses_invalid_import_strings :: proc(t: ^testing.T) {
|
||||
text := "import \"bad\\q\"\nimport \"unterminated\n"
|
||||
text := "import \"bad\\q\"\nimport \"bad\\xg0\"\nimport \"bad\\x1\"\nimport \"unterminated\n"
|
||||
source_file := source.Source{path="test.bro", text=text}
|
||||
diagnostics := source.init_diagnostics(&source_file)
|
||||
defer source.destroy_diagnostics(&diagnostics)
|
||||
@@ -1287,7 +1310,7 @@ lexer_diagnoses_invalid_import_strings :: proc(t: ^testing.T) {
|
||||
stream := lexer.lex(&source_file, &diagnostics, &symbols)
|
||||
defer delete(stream.items)
|
||||
|
||||
testing.expect_value(t, len(diagnostics.items), 2)
|
||||
testing.expect_value(t, len(diagnostics.items), 4)
|
||||
}
|
||||
|
||||
@(test)
|
||||
@@ -15568,12 +15591,12 @@ dependency_passes test {
|
||||
defer delete(stderr)
|
||||
output := string(stderr)
|
||||
testing.expect_value(t, state.exit_code, 1)
|
||||
testing.expect(t, strings.contains(output, "root.root_passes...[ok]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_fails...[failed]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_passes...[\x1b[92mok\x1b[0m]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_fails...[\x1b[91mfailure\x1b[0m]"))
|
||||
testing.expect(t, strings.contains(output, "expected 42, found 41"))
|
||||
testing.expect(t, strings.contains(output, "root.root_continues...[ok]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_errors...[failed]"))
|
||||
testing.expect(t, strings.contains(output, "dependency.dependency_passes...[ok]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_continues...[\x1b[92mok\x1b[0m]"))
|
||||
testing.expect(t, strings.contains(output, "root.root_errors...[\x1b[91mfailure\x1b[0m]"))
|
||||
testing.expect(t, strings.contains(output, "dependency.dependency_passes...[\x1b[92mok\x1b[0m]"))
|
||||
testing.expect(t, strings.contains(output, root_path))
|
||||
testing.expect(t, strings.contains(output, "3 passed, 2 failed"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user