From 676e4f3824054cf39c87d008909b0e57bb9bdcc8 Mon Sep 17 00:00:00 2001 From: kcbanner Date: Wed, 28 Dec 2022 02:05:15 -0500 Subject: cbe: changes to get zig2.c compiling under msvc - Add cpuid / getXCR0 functions for the cbe to use instead of asm blocks - Don't cast between 128 bit types during truncation - Fixup truncation to use functions for shifts / adds - Fixup float casts for undefined values - Add test for 128 bit integer truncation --- test/behavior/basic.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/behavior/basic.zig') diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 6fcef06fc1..e704e190f3 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -37,6 +37,20 @@ test "truncate to non-power-of-two integers" { try testTrunc(i32, i5, std.math.maxInt(i32), -1); } +test "truncate to non-power-of-two integers from 128-bit" { + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + + try testTrunc(u128, u1, 0xffffffff_ffffffff_ffffffff_01010101, 0x01); + try testTrunc(u128, u1, 0xffffffff_ffffffff_ffffffff_01010110, 0x00); + try testTrunc(u128, u2, 0xffffffff_ffffffff_ffffffff_01010101, 0x01); + try testTrunc(u128, u2, 0xffffffff_ffffffff_ffffffff_01010102, 0x02); + try testTrunc(i128, i5, -4, -4); + try testTrunc(i128, i5, 4, 4); + try testTrunc(i128, i5, -28, 4); + try testTrunc(i128, i5, 28, -4); + try testTrunc(i128, i5, std.math.maxInt(i128), -1); +} + fn testTrunc(comptime Big: type, comptime Little: type, big: Big, little: Little) !void { try expect(@truncate(Little, big) == little); } -- cgit v1.2.3