diff options
author | Julien Dessaux | 2022-06-09 23:17:53 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-06-09 23:18:27 +0200 |
commit | 75fc1506e59c1eaa52971d20df72c7cbeca5ac82 (patch) | |
tree | 09ac84d955f9fc1f7c8bc5a11415f765296de42b /src/main.zig | |
parent | Added submodules for the spec and the mycology test suite (diff) | |
download | zigfunge98-75fc1506e59c1eaa52971d20df72c7cbeca5ac82.tar.gz zigfunge98-75fc1506e59c1eaa52971d20df72c7cbeca5ac82.tar.bz2 zigfunge98-75fc1506e59c1eaa52971d20df72c7cbeca5ac82.zip |
Pass the sanity test
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 14bada3..7460c60 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,5 +1,6 @@ const std = @import("std"); const field = @import("field.zig"); +const interpreter = @import("interpreter.zig"); const pointer = @import("pointer.zig"); const stackStack = @import("stackStack.zig"); @@ -10,3 +11,51 @@ pub fn main() anyerror!void { test "all" { std.testing.refAllDecls(@This()); } +test "minimal" { + const minimal = std.io.fixedBufferStream("@").reader(); + var f = try field.Field.init(std.testing.allocator); + defer f.deinit(); + try f.load(minimal); + const argv = [_][]const u8{"minimal"}; + var p = try pointer.Pointer.init(std.testing.allocator, f, null, argv[0..]); + defer p.deinit(); + + var i = try interpreter.Interpreter.init(std.testing.allocator, f, p); + defer i.deinit(); + + var code = try i.run(); + try std.testing.expectEqual(code, 0); +} +test "almost minimal" { + const minimal = std.io.fixedBufferStream(" @").reader(); + var f = try field.Field.init(std.testing.allocator); + defer f.deinit(); + try f.load(minimal); + const argv = [_][]const u8{"minimal"}; + var p = try pointer.Pointer.init(std.testing.allocator, f, null, argv[0..]); + defer p.deinit(); + + var i = try interpreter.Interpreter.init(std.testing.allocator, f, p); + defer i.deinit(); + + var code = try i.run(); + try std.testing.expectEqual(code, 0); +} +test "sanity" { + var file = try std.fs.cwd().openFile("mycology/sanity.bf", .{}); + defer file.close(); + + var f = try field.Field.init(std.testing.allocator); + defer f.deinit(); + try f.load(file.reader()); + + const argv = [_][]const u8{"sanity"}; + var p = try pointer.Pointer.init(std.testing.allocator, f, null, argv[0..]); + defer p.deinit(); + + var i = try interpreter.Interpreter.init(std.testing.allocator, f, p); + defer i.deinit(); + + var code = try i.run(); + try std.testing.expectEqual(code, 0); +} |