add test for parse errors
This commit is contained in:
parent
b28f208e65
commit
ea3850b99d
1 changed files with 18 additions and 0 deletions
18
src/lang.zig
18
src/lang.zig
|
@ -507,6 +507,7 @@ pub const Lang = struct {
|
|||
self.has_error = false;
|
||||
self.line = 0;
|
||||
}
|
||||
|
||||
fn doError(self: *Lang, comptime fmt: []const u8, args: anytype) void {
|
||||
std.debug.warn("ERROR! at line {}: ", .{self.line});
|
||||
std.debug.warn(fmt, args);
|
||||
|
@ -700,3 +701,20 @@ test "load, phaser, quicksave" {
|
|||
std.testing.expectEqual(cmds.list.items[1].tag, .phaser);
|
||||
std.testing.expectEqual(cmds.list.items[2].tag, .quicksave);
|
||||
}
|
||||
|
||||
test "load, phaser with errors, quicksave" {
|
||||
var lang = Lang.init(std.testing.allocator);
|
||||
defer lang.deinit();
|
||||
|
||||
const prog =
|
||||
\\load :0;
|
||||
\\phaser 3 1 25;
|
||||
\\quicksave;
|
||||
;
|
||||
|
||||
var cmds = lang.parse(prog) catch |err| {
|
||||
return;
|
||||
};
|
||||
|
||||
unreachable;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue