aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-08-24 22:05:39 +0200
committerJulien Dessaux2022-08-24 22:07:06 +0200
commit128f1a74cb70c0f642719f0da25ef007f586d254 (patch)
tree93d311332e6dd96dbe43f485316f86ea3cb23637 /src/main.zig
parentFixed arguments printing order in y command (diff)
downloadzigfunge98-128f1a74cb70c0f642719f0da25ef007f586d254.tar.gz
zigfunge98-128f1a74cb70c0f642719f0da25ef007f586d254.tar.bz2
zigfunge98-128f1a74cb70c0f642719f0da25ef007f586d254.zip
Automated the mycology test suite
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
index 4b70489..29ed083 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -44,3 +44,21 @@ test "sanity" {
try std.testing.expectEqual(try i.run(&ioContext), 0);
try std.testing.expectEqual(std.mem.eql(u8, stdout.items, expected), true);
}
+test "mycology" {
+ var file = try std.fs.cwd().openFile("mycology/mycology.b98", .{});
+ defer file.close();
+ var stdin = std.io.fixedBufferStream("");
+ var stdout = std.ArrayList(u8).init(std.testing.allocator);
+ defer stdout.deinit();
+ var expected = try std.fs.cwd().openFile("tests/mycology.stdout", .{});
+ defer expected.close();
+ const expectedOutput = try expected.reader().readAllAlloc(std.testing.allocator, 8192);
+ defer std.testing.allocator.free(expectedOutput);
+ const args = [_][]const u8{ "test", "sanity" };
+ const env = [_][*:0]const u8{ "ENV=TEST", "FOO=BAR" };
+ var i = try interpreter.Interpreter.init(std.testing.allocator, file.reader(), testTimestamp, args[0..], env[0..]);
+ defer i.deinit();
+ var ioContext = io.context(stdin.reader(), stdout.writer());
+ try std.testing.expectEqual(try i.run(&ioContext), 15);
+ try std.testing.expectEqual(std.mem.eql(u8, stdout.items, expectedOutput), true);
+}