rename types
This commit is contained in:
@@ -138,6 +138,15 @@ fn zigToken(token: c_uint) Token.Tag {
|
||||
|
||||
// Copy-pasted from lib/std/zig/tokenizer.zig
|
||||
fn testTokenize(source: [:0]const u8, expected_token_tags: []const Token.Tag) !void {
|
||||
// Do the C thing
|
||||
var ctokenizer = c.tokenizerInit(source.ptr, @intCast(source.len));
|
||||
for (expected_token_tags) |expected_token_tag| {
|
||||
const token = c.tokenizerNext(&ctokenizer);
|
||||
try std.testing.expectEqual(expected_token_tag, zigToken(token.tag));
|
||||
}
|
||||
const last_token = c.tokenizerNext(&ctokenizer);
|
||||
try std.testing.expectEqual(Token.Tag.eof, zigToken(last_token.tag));
|
||||
|
||||
// uncomment when Zig source and compiler get in sync (e.g. with 0.14)
|
||||
//var tokenizer = Tokenizer.init(source);
|
||||
//for (expected_token_tags) |expected_token_tag| {
|
||||
@@ -149,17 +158,6 @@ fn testTokenize(source: [:0]const u8, expected_token_tags: []const Token.Tag) !v
|
||||
//// recovered by opinionated means outside the scope of this implementation.
|
||||
//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);
|
||||
|
||||
// Do the C thing
|
||||
var ctokenizer = c.tokenizer_init(source.ptr, @intCast(source.len));
|
||||
for (expected_token_tags) |expected_token_tag| {
|
||||
const token = c.tokenizer_next(&ctokenizer);
|
||||
try std.testing.expectEqual(expected_token_tag, zigToken(token.tag));
|
||||
}
|
||||
const last_token = c.tokenizer_next(&ctokenizer);
|
||||
try std.testing.expectEqual(Token.Tag.eof, zigToken(last_token.tag));
|
||||
try std.testing.expectEqual(source.len, last_token.loc.start);
|
||||
try std.testing.expectEqual(source.len, last_token.loc.end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user