aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2022-12-28 02:05:15 -0500
committerkcbanner <kcbanner@gmail.com>2023-01-01 16:44:29 -0500
commit676e4f3824054cf39c87d008909b0e57bb9bdcc8 (patch)
tree5d00fe5e028d1bee54aac16303a2824053c57abf /test/behavior/basic.zig
parentf07d33f54b3448019f5e7c74c1f9063a5079b961 (diff)
downloadzig-676e4f3824054cf39c87d008909b0e57bb9bdcc8.tar.gz
zig-676e4f3824054cf39c87d008909b0e57bb9bdcc8.zip
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
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig14
1 files changed, 14 insertions, 0 deletions
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);
}