add test for parse errors

This commit is contained in:
Luna 2021-04-04 18:15:42 -03:00
parent b28f208e65
commit ea3850b99d

View file

@ -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;
}