commit 9d79741fd01f7d3c4093ef6d305c84ff5c183a69 (tree)
parent a1d72fad81c17fcaadd9da782b63f0ce2638f1bb
Author: Luuk de Gram <Luukdegram@users.noreply.github.com>
Date: Thu, 16 Jul 2020 21:17:43 +0200
Stage2: Add support for substraction
Diffstat:
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/test/stage2/compare_output.zig b/test/stage2/compare_output.zig
@@ -169,8 +169,38 @@ pub fn addCases(ctx: *TestContext) !void {
,
"",
);
+ }
- // Tests the assert() function.
+ {
+ // TODO add a test case for comptime substraction of numbers
+ var case = ctx.exe("substracting numbers at runtime", linux_x64);
+ case.addCompareOutput(
+ \\export fn _start() noreturn {
+ \\ sub(7, 8);
+ \\
+ \\ exit();
+ \\}
+ \\
+ \\fn sub(a: u32, b: u32) void {
+ \\ if (a - b != 3) unreachable;
+ \\}
+ \\
+ \\fn exit() noreturn {
+ \\ asm volatile ("syscall"
+ \\ :
+ \\ : [number] "{rax}" (231),
+ \\ [arg1] "{rdi}" (0)
+ \\ : "rcx", "r11", "memory"
+ \\ );
+ \\ unreachable;
+ \\}
+ ,
+ "",
+ );
+ }
+
+ {
+ var case = ctx.exe("assert function", linux_x64);
case.addCompareOutput(
\\export fn _start() noreturn {
\\ add(3, 4);