feat: execute break and continue in while loops
This commit is contained in:
@@ -79,3 +79,24 @@ scans_logical_operators_without_splitting_identifiers test {
|
||||
try testing.expect_equal(u32(35), state.tokens.items[7].span.end)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
}
|
||||
|
||||
scans_loop_controls_with_exact_keyword_boundaries test {
|
||||
strpool.strings = strpool.init(mem.c_allocator)
|
||||
defer strpool.deinit(&strpool.strings)
|
||||
diagnostic_store := diagnostics.init(mem.c_allocator)
|
||||
defer diagnostics.deinit(&diagnostic_store)
|
||||
state := init(mem.c_allocator)
|
||||
defer deinit(&state)
|
||||
source :: "break continue breakfast continued break_1 continue2"
|
||||
try scan(&state, source, &diagnostic_store)
|
||||
expected [7]TokenKind :: [.break, .continue, .ident, .ident, .ident, .ident, .eof]
|
||||
try testing.expect_equal(expected.len, state.tokens.items.len)
|
||||
for (expected) |kind, index| try testing.expect_equal(kind, state.tokens.items[index].kind)
|
||||
try testing.expect_equal(u32(0), state.tokens.items[0].span.start)
|
||||
try testing.expect_equal(u32(5), state.tokens.items[0].span.end)
|
||||
try testing.expect_equal(u32(6), state.tokens.items[1].span.start)
|
||||
try testing.expect_equal(u32(14), state.tokens.items[1].span.end)
|
||||
try testing.expect_equal("breakfast", strpool.get_str(&strpool.strings, state.tokens.items[2].data.str_id)?)
|
||||
try testing.expect_equal("continued", strpool.get_str(&strpool.strings, state.tokens.items[3].data.str_id)?)
|
||||
try testing.expect_equal(0, diagnostics.count(&diagnostic_store))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user