diff options
| author | Meghan Denny <hello@nektro.net> | 2021-08-30 19:48:31 -0700 |
|---|---|---|
| committer | Meghan Denny <hello@nektro.net> | 2021-08-30 19:48:31 -0700 |
| commit | cf9684ce75d4f9a4dc576d9c2cd490edcb8002df (patch) | |
| tree | 807ff4c81046306d1c9a6940c68370251e8a1f5a /test | |
| parent | e878a6633f2447666217a5f9247af7c34507dca0 (diff) | |
| download | zig-cf9684ce75d4f9a4dc576d9c2cd490edcb8002df.tar.gz zig-cf9684ce75d4f9a4dc576d9c2cd490edcb8002df.zip | |
stage2: add `@rem` tests to llvm and c backends
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/cbe.zig | 17 | ||||
| -rw-r--r-- | test/stage2/llvm.zig | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index 21270f130b..12bc21b741 100644 --- a/test/stage2/cbe.zig +++ b/test/stage2/cbe.zig @@ -916,6 +916,23 @@ pub fn addCases(ctx: *TestContext) !void { , ""); } + { + var case = ctx.exeFromCompiledC("@rem", linux_x64); + case.addCompareOutput( + \\fn assert(ok: bool) void { + \\ if (!ok) unreachable; + \\} + \\fn rem(lhs: i32, rhs: i32, expected: i32) bool { + \\ return @rem(lhs, rhs) == expected; + \\} + \\pub export fn main() c_int { + \\ assert(rem(-5, 3, -2)); + \\ assert(rem(5, 3, 2)); + \\ return 0; + \\} + , ""); + } + ctx.h("simple header", linux_x64, \\export fn start() void{} , diff --git a/test/stage2/llvm.zig b/test/stage2/llvm.zig index 09649f518c..34f73b01c7 100644 --- a/test/stage2/llvm.zig +++ b/test/stage2/llvm.zig @@ -225,4 +225,21 @@ pub fn addCases(ctx: *TestContext) !void { \\} , ""); } + + { + var case = ctx.exeUsingLlvmBackend("@rem", linux_x64); + case.addCompareOutput( + \\fn assert(ok: bool) void { + \\ if (!ok) unreachable; + \\} + \\fn rem(lhs: i32, rhs: i32, expected: i32) bool { + \\ return @rem(lhs, rhs) == expected; + \\} + \\pub export fn main() c_int { + \\ assert(rem(-5, 3, -2)); + \\ assert(rem(5, 3, 2)); + \\ return 0; + \\} + , ""); + } } |
