Skip to content

Commit 8390965

Browse files
committed
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.
1 parent 5490688 commit 8390965

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/std/zig/tokenizer.zig

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,17 +2061,14 @@ test "saturating operators" {
20612061
try testTokenize("-|=", &.{.minus_pipe_equal});
20622062
}
20632063

2064-
fn testTokenize(source: [:0]const u8, expected_tokens: []const Token.Tag) !void {
2064+
fn testTokenize(source: [:0]const u8, expected_token_tags: []const Token.Tag) !void {
20652065
var tokenizer = Tokenizer.init(source);
2066-
for (expected_tokens) |expected_token_id| {
2066+
for (expected_token_tags) |expected_token_tag| {
20672067
const token = tokenizer.next();
2068-
if (token.tag != expected_token_id) {
2069-
std.debug.panic("expected {s}, found {s}\n", .{
2070-
@tagName(expected_token_id), @tagName(token.tag),
2071-
});
2072-
}
2068+
try std.testing.expectEqual(expected_token_tag, token.tag);
20732069
}
20742070
const last_token = tokenizer.next();
20752071
try std.testing.expectEqual(Token.Tag.eof, last_token.tag);
20762072
try std.testing.expectEqual(source.len, last_token.loc.start);
2073+
try std.testing.expectEqual(source.len, last_token.loc.end);
20772074
}

0 commit comments

Comments
 (0)