authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-30 19:48:31-07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-30 19:48:31-07:00
logcf9684ce75d4f9a4dc576d9c2cd490edcb8002df
tree807ff4c81046306d1c9a6940c68370251e8a1f5a
parente878a6633f2447666217a5f9247af7c34507dca0

stage2: add `@rem` tests to llvm and c backends


2 files changed, 34 insertions(+), 0 deletions(-)

test/stage2/cbe.zig+17
...@@ -916,6 +916,23 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -916,6 +916,23 @@ pub fn addCases(ctx: *TestContext) !void {
916 , "");916 , "");
917 }917 }
918918
919 {
920 var case = ctx.exeFromCompiledC("@rem", linux_x64);
921 case.addCompareOutput(
922 \\fn assert(ok: bool) void {
923 \\ if (!ok) unreachable;
924 \\}
925 \\fn rem(lhs: i32, rhs: i32, expected: i32) bool {
926 \\ return @rem(lhs, rhs) == expected;
927 \\}
928 \\pub export fn main() c_int {
929 \\ assert(rem(-5, 3, -2));
930 \\ assert(rem(5, 3, 2));
931 \\ return 0;
932 \\}
933 , "");
934 }
935
919 ctx.h("simple header", linux_x64,936 ctx.h("simple header", linux_x64,
920 \\export fn start() void{}937 \\export fn start() void{}
921 ,938 ,
test/stage2/llvm.zig+17
...@@ -225,4 +225,21 @@ pub fn addCases(ctx: *TestContext) !void {...@@ -225,4 +225,21 @@ pub fn addCases(ctx: *TestContext) !void {
225 \\}225 \\}
226 , "");226 , "");
227 }227 }
228
229 {
230 var case = ctx.exeUsingLlvmBackend("@rem", linux_x64);
231 case.addCompareOutput(
232 \\fn assert(ok: bool) void {
233 \\ if (!ok) unreachable;
234 \\}
235 \\fn rem(lhs: i32, rhs: i32, expected: i32) bool {
236 \\ return @rem(lhs, rhs) == expected;
237 \\}
238 \\pub export fn main() c_int {
239 \\ assert(rem(-5, 3, -2));
240 \\ assert(rem(5, 3, 2));
241 \\ return 0;
242 \\}
243 , "");
244 }
228}245}