zig/lib/compiler_rt/multi3_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

54 lines
2.1 KiB
Zig

const __multi3 = @import("multi3.zig").__multi3;
const testing = @import("std").testing;
fn test__multi3(a: i128, b: i128, expected: i128) !void {
const x = __multi3(a, b);
try testing.expect(x == expected);
}
test "multi3" {
try test__multi3(0, 0, 0);
try test__multi3(0, 1, 0);
try test__multi3(1, 0, 0);
try test__multi3(0, 10, 0);
try test__multi3(10, 0, 0);
try test__multi3(0, 81985529216486895, 0);
try test__multi3(81985529216486895, 0, 0);
try test__multi3(0, -1, 0);
try test__multi3(-1, 0, 0);
try test__multi3(0, -10, 0);
try test__multi3(-10, 0, 0);
try test__multi3(0, -81985529216486895, 0);
try test__multi3(-81985529216486895, 0, 0);
try test__multi3(1, 1, 1);
try test__multi3(1, 10, 10);
try test__multi3(10, 1, 10);
try test__multi3(1, 81985529216486895, 81985529216486895);
try test__multi3(81985529216486895, 1, 81985529216486895);
try test__multi3(1, -1, -1);
try test__multi3(1, -10, -10);
try test__multi3(-10, 1, -10);
try test__multi3(1, -81985529216486895, -81985529216486895);
try test__multi3(-81985529216486895, 1, -81985529216486895);
try test__multi3(3037000499, 3037000499, 9223372030926249001);
try test__multi3(-3037000499, 3037000499, -9223372030926249001);
try test__multi3(3037000499, -3037000499, -9223372030926249001);
try test__multi3(-3037000499, -3037000499, 9223372030926249001);
try test__multi3(4398046511103, 2097152, 9223372036852678656);
try test__multi3(-4398046511103, 2097152, -9223372036852678656);
try test__multi3(4398046511103, -2097152, -9223372036852678656);
try test__multi3(-4398046511103, -2097152, 9223372036852678656);
try test__multi3(2097152, 4398046511103, 9223372036852678656);
try test__multi3(-2097152, 4398046511103, -9223372036852678656);
try test__multi3(2097152, -4398046511103, -9223372036852678656);
try test__multi3(-2097152, -4398046511103, 9223372036852678656);
try test__multi3(0x00000000000000B504F333F9DE5BE000, 0x000000000000000000B504F333F9DE5B, 0x7FFFFFFFFFFFF328DF915DA296E8A000);
}