zig/lib/compiler_rt/divti3_test.zig
Andrew Kelley ec95e00e28 flatten lib/std/special and improve "pkg inside another" logic
stage2: change logic for detecting whether the main package is inside
the std package. Previously it relied on realpath() which is not portable.
This uses resolve() which is how imports already work.

 * stage2: fix cleanup bug when creating Module
 * flatten lib/std/special/* to lib/*
   - this was motivated by making main_pkg_is_inside_std false for
     compiler_rt & friends.
 * rename "mini libc" to "universal libc"
2022-05-06 22:41:00 -07:00

22 lines
846 B
Zig

const __divti3 = @import("divti3.zig").__divti3;
const testing = @import("std").testing;
fn test__divti3(a: i128, b: i128, expected: i128) !void {
const x = __divti3(a, b);
try testing.expect(x == expected);
}
test "divti3" {
try test__divti3(0, 1, 0);
try test__divti3(0, -1, 0);
try test__divti3(2, 1, 2);
try test__divti3(2, -1, -2);
try test__divti3(-2, 1, -2);
try test__divti3(-2, -1, 2);
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), 1, @bitCast(i128, @as(u128, 0x8 << 124)));
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), -1, @bitCast(i128, @as(u128, 0x8 << 124)));
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), -2, @bitCast(i128, @as(u128, 0x4 << 124)));
try test__divti3(@bitCast(i128, @as(u128, 0x8 << 124)), 2, @bitCast(i128, @as(u128, 0xc << 124)));
}