aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-08-03 23:14:41 +0200
committerJulien Dessaux2022-08-03 23:14:41 +0200
commit8e9f1f3af037374bd4747b6879b8486833449afe (patch)
treeeeead011492d182e1ce53e96e6b48773b85ce166 /src/main.zig
parentImplemented decimalInput io function (diff)
downloadzigfunge98-8e9f1f3af037374bd4747b6879b8486833449afe.tar.gz
zigfunge98-8e9f1f3af037374bd4747b6879b8486833449afe.tar.bz2
zigfunge98-8e9f1f3af037374bd4747b6879b8486833449afe.zip
Simplified io context implementation
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index b85aa6f..32874e5 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -18,9 +18,8 @@ pub fn main() anyerror!void {
var i = try interpreter.Interpreter.init(gpa.allocator(), file.reader(), args);
defer i.deinit();
- var ioContext = try io.context(gpa.allocator(), std.io.getStdIn().reader(), std.io.getStdOut().writer());
- defer ioContext.deinit();
- std.os.exit(@intCast(u8, try i.run(ioContext)));
+ var ioContext = io.context(std.io.getStdIn().reader(), std.io.getStdOut().writer());
+ std.os.exit(@intCast(u8, try i.run(&ioContext)));
}
test "all" {
@@ -36,8 +35,7 @@ test "sanity" {
const args = [_][]const u8{"sanity"};
var i = try interpreter.Interpreter.init(std.testing.allocator, file.reader(), args[0..]);
defer i.deinit();
- var ioContext = try io.context(std.testing.allocator, stdin.reader(), stdout.writer());
- defer ioContext.deinit();
- try std.testing.expectEqual(try i.run(ioContext), 0);
+ var ioContext = io.context(stdin.reader(), stdout.writer());
+ try std.testing.expectEqual(try i.run(&ioContext), 0);
try std.testing.expectEqual(std.mem.eql(u8, stdout.items, expected), true);
}