authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-27 12:37:16-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-27 12:43:34-07:00
log9f0fd72321bf04654042a2191274cb31ba8f9110
tree72f189f0ba138af58921a7f8a0849e65ae620632
parent3fb301b16a51504bea1aa89efe856a2c2df6f293

categorize nan behavior test

move it from bugs/xxx.zig to its own category

3 files changed, 43 insertions(+), 36 deletions(-)

test/behavior.zig+1-1
...@@ -189,6 +189,7 @@ test {...@@ -189,6 +189,7 @@ test {
189 _ = @import("behavior/merge_error_sets.zig");189 _ = @import("behavior/merge_error_sets.zig");
190 _ = @import("behavior/muladd.zig");190 _ = @import("behavior/muladd.zig");
191 _ = @import("behavior/namespace_depends_on_compile_var.zig");191 _ = @import("behavior/namespace_depends_on_compile_var.zig");
192 _ = @import("behavior/nan.zig");
192 _ = @import("behavior/null.zig");193 _ = @import("behavior/null.zig");
193 _ = @import("behavior/optional.zig");194 _ = @import("behavior/optional.zig");
194 _ = @import("behavior/packed-struct.zig");195 _ = @import("behavior/packed-struct.zig");
...@@ -253,7 +254,6 @@ test {...@@ -253,7 +254,6 @@ test {
253 builtin.zig_backend != .stage2_c and254 builtin.zig_backend != .stage2_c and
254 builtin.zig_backend != .stage2_spirv64)255 builtin.zig_backend != .stage2_spirv64)
255 {256 {
256 _ = @import("behavior/bugs/14198.zig");
257 _ = @import("behavior/export.zig");257 _ = @import("behavior/export.zig");
258 }258 }
259}259}
test/behavior/bugs/14198.zig deleted-35
...@@ -1,35 +0,0 @@
1const std = @import("std");
2const math = std.math;
3const mem = std.mem;
4const testing = std.testing;
5
6const qnan_u16: u16 = 0x7E00;
7const snan_u16: u16 = 0x7D00;
8const qnan_u32: u32 = 0x7FC00000;
9const snan_u32: u32 = 0x7FA00000;
10const qnan_u64: u64 = 0x7FF8000000000000;
11const snan_u64: u64 = 0x7FF4000000000000;
12const qnan_u128: u128 = 0x7FFF8000000000000000000000000000;
13const snan_u128: u128 = 0x7FFF4000000000000000000000000000;
14const qnan_f16: f16 = math.nan(f16);
15const snan_f16: f16 = math.snan(f16);
16const qnan_f32: f32 = math.nan(f32);
17const snan_f32: f32 = math.snan(f32);
18const qnan_f64: f64 = math.nan(f64);
19const snan_f64: f64 = math.snan(f64);
20const qnan_f128: f128 = math.nan(f128);
21const snan_f128: f128 = math.snan(f128);
22
23test "nan memory equality" {
24 // signaled
25 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u16), mem.asBytes(&snan_f16)));
26 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u32), mem.asBytes(&snan_f32)));
27 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u64), mem.asBytes(&snan_f64)));
28 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u128), mem.asBytes(&snan_f128)));
29
30 // quiet
31 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u16), mem.asBytes(&qnan_f16)));
32 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u32), mem.asBytes(&qnan_f32)));
33 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u64), mem.asBytes(&qnan_f64)));
34 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u128), mem.asBytes(&qnan_f128)));
35}
test/behavior/nan.zig created+42
...@@ -0,0 +1,42 @@
1const builtin = @import("builtin");
2const std = @import("std");
3const math = std.math;
4const mem = std.mem;
5const testing = std.testing;
6
7const qnan_u16: u16 = 0x7E00;
8const snan_u16: u16 = 0x7D00;
9const qnan_u32: u32 = 0x7FC00000;
10const snan_u32: u32 = 0x7FA00000;
11const qnan_u64: u64 = 0x7FF8000000000000;
12const snan_u64: u64 = 0x7FF4000000000000;
13const qnan_u128: u128 = 0x7FFF8000000000000000000000000000;
14const snan_u128: u128 = 0x7FFF4000000000000000000000000000;
15const qnan_f16: f16 = math.nan(f16);
16const snan_f16: f16 = math.snan(f16);
17const qnan_f32: f32 = math.nan(f32);
18const snan_f32: f32 = math.snan(f32);
19const qnan_f64: f64 = math.nan(f64);
20const snan_f64: f64 = math.snan(f64);
21const qnan_f128: f128 = math.nan(f128);
22const snan_f128: f128 = math.snan(f128);
23
24test "nan memory equality" {
25 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
26 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
27 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
28 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
29 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
30
31 // signaled
32 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u16), mem.asBytes(&snan_f16)));
33 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u32), mem.asBytes(&snan_f32)));
34 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u64), mem.asBytes(&snan_f64)));
35 try testing.expect(mem.eql(u8, mem.asBytes(&snan_u128), mem.asBytes(&snan_f128)));
36
37 // quiet
38 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u16), mem.asBytes(&qnan_f16)));
39 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u32), mem.asBytes(&qnan_f32)));
40 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u64), mem.asBytes(&qnan_f64)));
41 try testing.expect(mem.eql(u8, mem.asBytes(&qnan_u128), mem.asBytes(&qnan_f128)));
42}