aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-27 16:32:35 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-28 12:58:40 -0700
commit2a990d69669c2a2cd16134e8ebbd2750060f8071 (patch)
treeb60796aa1852a533cd23f3a0750957d4dd1ea71a /test/behavior
parent673ae5b457479760ff8e08b3e06917a4b2651436 (diff)
downloadzig-2a990d69669c2a2cd16134e8ebbd2750060f8071.tar.gz
zig-2a990d69669c2a2cd16134e8ebbd2750060f8071.zip
stage1: rework tokenizer to match stage2
* Extracts AstGen logic from ir.cpp into astgen.cpp. Reduces the largest file of stage1 from 33,551 lines to 25,510. * tokenizer: rework it completely to match the stage2 tokenizer logic. They can now be maintained together; when one is changed, the other can be changed in the same way. - Each token now takes up 13 bytes instead of 64 bytes. The tokenizer does not parse char literals, string literals, integer literals, etc into meaningful data. Instead, that happens during parsing or astgen. - no longer store line offsets. Error messages scan source files to find the line/column as needed (same as stage2). - main loop: instead of checking the loop, handle a null byte explicitly in the switch statements. This is a nice improvement that we may want to backport to stage2. - delete some dead tokens, artifacts of past syntax that no longer exists. * Parser: fix a TODO by parsing builtin functions as tokens rather than `@` as a separate token. This is how stage2 does it. * Remove some debugging infrastructure. These will need to be redone, if at all, as the code migrates to match stage2. - remove the ast_render code. - remove the IR debugging stuff - remove teh token printing code
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/misc.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/behavior/misc.zig b/test/behavior/misc.zig
index 0300afcdea..e010644756 100644
--- a/test/behavior/misc.zig
+++ b/test/behavior/misc.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const expect = std.testing.expect;
const expectEqualSlices = std.testing.expectEqualSlices;
+const expectEqualStrings = std.testing.expectEqualStrings;
const mem = std.mem;
const builtin = @import("builtin");
@@ -147,13 +148,13 @@ test "array mult operator" {
}
test "string escapes" {
- try expect(mem.eql(u8, "\"", "\x22"));
- try expect(mem.eql(u8, "\'", "\x27"));
- try expect(mem.eql(u8, "\n", "\x0a"));
- try expect(mem.eql(u8, "\r", "\x0d"));
- try expect(mem.eql(u8, "\t", "\x09"));
- try expect(mem.eql(u8, "\\", "\x5c"));
- try expect(mem.eql(u8, "\u{1234}\u{069}\u{1}", "\xe1\x88\xb4\x69\x01"));
+ try expectEqualStrings("\"", "\x22");
+ try expectEqualStrings("\'", "\x27");
+ try expectEqualStrings("\n", "\x0a");
+ try expectEqualStrings("\r", "\x0d");
+ try expectEqualStrings("\t", "\x09");
+ try expectEqualStrings("\\", "\x5c");
+ try expectEqualStrings("\u{1234}\u{069}\u{1}", "\xe1\x88\xb4\x69\x01");
}
test "multiline string" {