aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2022-08-13 11:44:19 +0200
committerr00ster91 <r00ster91@proton.me>2022-08-16 00:20:19 +0200
commit83909651ea99eb45c67ead40b5fcb5773d1998d5 (patch)
tree94575a7b0109a9124a22f42f9d2da4e6729a4953 /lib
parent5490688d658973982d111ad5ad52bc497ef15d84 (diff)
downloadzig-83909651ea99eb45c67ead40b5fcb5773d1998d5.tar.gz
zig-83909651ea99eb45c67ead40b5fcb5773d1998d5.zip
test: simplify testTokenize
What this does is already done by `expectEqual`. Now the trace seems to be shorter and more concise so the errors should be easier to read now.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/zig/tokenizer.zig11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig
index 89d4ee59d9..eaa0ddd716 100644
--- a/lib/std/zig/tokenizer.zig
+++ b/lib/std/zig/tokenizer.zig
@@ -2061,17 +2061,14 @@ test "saturating operators" {
try testTokenize("-|=", &.{.minus_pipe_equal});
}
-fn testTokenize(source: [:0]const u8, expected_tokens: []const Token.Tag) !void {
+fn testTokenize(source: [:0]const u8, expected_token_tags: []const Token.Tag) !void {
var tokenizer = Tokenizer.init(source);
- for (expected_tokens) |expected_token_id| {
+ for (expected_token_tags) |expected_token_tag| {
const token = tokenizer.next();
- if (token.tag != expected_token_id) {
- std.debug.panic("expected {s}, found {s}\n", .{
- @tagName(expected_token_id), @tagName(token.tag),
- });
- }
+ try std.testing.expectEqual(expected_token_tag, token.tag);
}
const last_token = tokenizer.next();
try std.testing.expectEqual(Token.Tag.eof, last_token.tag);
try std.testing.expectEqual(source.len, last_token.loc.start);
+ try std.testing.expectEqual(source.len, last_token.loc.end);
}