| author | |
| committer | |
| log | 5257643d3ddd35b0fb40b82988a9ccf9f859a779 |
| tree | f75b18bd128f9bae37b6f82171b6e3c6f86a6ce0 |
| parent | aecdf6ad50fef3ef68d699c2ef72b5904fdd3553 |
| parent | 24d9438bccde57a838df861aba394077b0c2a5cc |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
categorize behavior tests10 files changed, 220 insertions(+), 166 deletions(-)
test/behavior.zig+4-4| ... | @@ -161,6 +161,7 @@ test { | ... | @@ -161,6 +161,7 @@ test { |
| 161 | _ = @import("behavior/enum.zig"); | 161 | _ = @import("behavior/enum.zig"); |
| 162 | _ = @import("behavior/error.zig"); | 162 | _ = @import("behavior/error.zig"); |
| 163 | _ = @import("behavior/eval.zig"); | 163 | _ = @import("behavior/eval.zig"); |
| 164 | _ = @import("behavior/export_builtin.zig"); | ||
| 164 | _ = @import("behavior/export_self_referential_type_info.zig"); | 165 | _ = @import("behavior/export_self_referential_type_info.zig"); |
| 165 | _ = @import("behavior/field_parent_ptr.zig"); | 166 | _ = @import("behavior/field_parent_ptr.zig"); |
| 166 | _ = @import("behavior/floatop.zig"); | 167 | _ = @import("behavior/floatop.zig"); |
| ... | @@ -169,6 +170,7 @@ test { | ... | @@ -169,6 +170,7 @@ test { |
| 169 | _ = @import("behavior/fn_in_struct_in_comptime.zig"); | 170 | _ = @import("behavior/fn_in_struct_in_comptime.zig"); |
| 170 | _ = @import("behavior/for.zig"); | 171 | _ = @import("behavior/for.zig"); |
| 171 | _ = @import("behavior/generics.zig"); | 172 | _ = @import("behavior/generics.zig"); |
| 173 | _ = @import("behavior/globals.zig"); | ||
| 172 | _ = @import("behavior/hasdecl.zig"); | 174 | _ = @import("behavior/hasdecl.zig"); |
| 173 | _ = @import("behavior/hasfield.zig"); | 175 | _ = @import("behavior/hasfield.zig"); |
| 174 | _ = @import("behavior/if.zig"); | 176 | _ = @import("behavior/if.zig"); |
| ... | @@ -188,6 +190,7 @@ test { | ... | @@ -188,6 +190,7 @@ test { |
| 188 | _ = @import("behavior/merge_error_sets.zig"); | 190 | _ = @import("behavior/merge_error_sets.zig"); |
| 189 | _ = @import("behavior/muladd.zig"); | 191 | _ = @import("behavior/muladd.zig"); |
| 190 | _ = @import("behavior/namespace_depends_on_compile_var.zig"); | 192 | _ = @import("behavior/namespace_depends_on_compile_var.zig"); |
| 193 | _ = @import("behavior/nan.zig"); | ||
| 191 | _ = @import("behavior/null.zig"); | 194 | _ = @import("behavior/null.zig"); |
| 192 | _ = @import("behavior/optional.zig"); | 195 | _ = @import("behavior/optional.zig"); |
| 193 | _ = @import("behavior/packed-struct.zig"); | 196 | _ = @import("behavior/packed-struct.zig"); |
| ... | @@ -252,9 +255,6 @@ test { | ... | @@ -252,9 +255,6 @@ test { |
| 252 | builtin.zig_backend != .stage2_c and | 255 | builtin.zig_backend != .stage2_c and |
| 253 | builtin.zig_backend != .stage2_spirv64) | 256 | builtin.zig_backend != .stage2_spirv64) |
| 254 | { | 257 | { |
| 255 | _ = @import("behavior/bugs/13063.zig"); | 258 | _ = @import("behavior/export_keyword.zig"); |
| 256 | _ = @import("behavior/bugs/11227.zig"); | ||
| 257 | _ = @import("behavior/bugs/14198.zig"); | ||
| 258 | _ = @import("behavior/export.zig"); | ||
| 259 | } | 259 | } |
| 260 | } | 260 | } |
test/behavior/bugs/11227.zig deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | |||
| 4 | fn foo() u32 { | ||
| 5 | return 11227; | ||
| 6 | } | ||
| 7 | const bar = foo; | ||
| 8 | test "pointer to alias behaves same as pointer to function" { | ||
| 9 | var a = &bar; | ||
| 10 | try std.testing.expect(foo() == a()); | ||
| 11 | } | ||
test/behavior/bugs/13063.zig deleted-21| ... | @@ -1,21 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const expect = std.testing.expect; | ||
| 4 | |||
| 5 | var pos = [2]f32{ 0.0, 0.0 }; | ||
| 6 | test "store to global array" { | ||
| 7 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | ||
| 8 | |||
| 9 | try expect(pos[1] == 0.0); | ||
| 10 | pos = [2]f32{ 0.0, 1.0 }; | ||
| 11 | try expect(pos[1] == 1.0); | ||
| 12 | } | ||
| 13 | |||
| 14 | var vpos = @Vector(2, f32){ 0.0, 0.0 }; | ||
| 15 | test "store to global vector" { | ||
| 16 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | ||
| 17 | |||
| 18 | try expect(vpos[1] == 0.0); | ||
| 19 | vpos = @Vector(2, f32){ 0.0, 1.0 }; | ||
| 20 | try expect(vpos[1] == 1.0); | ||
| 21 | } | ||
test/behavior/bugs/14198.zig deleted-35| ... | @@ -1,35 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const math = std.math; | ||
| 3 | const mem = std.mem; | ||
| 4 | const testing = std.testing; | ||
| 5 | |||
| 6 | const qnan_u16: u16 = 0x7E00; | ||
| 7 | const snan_u16: u16 = 0x7D00; | ||
| 8 | const qnan_u32: u32 = 0x7FC00000; | ||
| 9 | const snan_u32: u32 = 0x7FA00000; | ||
| 10 | const qnan_u64: u64 = 0x7FF8000000000000; | ||
| 11 | const snan_u64: u64 = 0x7FF4000000000000; | ||
| 12 | const qnan_u128: u128 = 0x7FFF8000000000000000000000000000; | ||
| 13 | const snan_u128: u128 = 0x7FFF4000000000000000000000000000; | ||
| 14 | const qnan_f16: f16 = math.nan(f16); | ||
| 15 | const snan_f16: f16 = math.snan(f16); | ||
| 16 | const qnan_f32: f32 = math.nan(f32); | ||
| 17 | const snan_f32: f32 = math.snan(f32); | ||
| 18 | const qnan_f64: f64 = math.nan(f64); | ||
| 19 | const snan_f64: f64 = math.snan(f64); | ||
| 20 | const qnan_f128: f128 = math.nan(f128); | ||
| 21 | const snan_f128: f128 = math.snan(f128); | ||
| 22 | |||
| 23 | test "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/export.zig deleted-95| ... | @@ -1,95 +0,0 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const expect = std.testing.expect; | ||
| 3 | const expectEqualSlices = std.testing.expectEqualSlices; | ||
| 4 | const expectEqualStrings = std.testing.expectEqualStrings; | ||
| 5 | const mem = std.mem; | ||
| 6 | const builtin = @import("builtin"); | ||
| 7 | |||
| 8 | // can't really run this test but we can make sure it has no compile error | ||
| 9 | // and generates code | ||
| 10 | const vram = @as([*]volatile u8, @ptrFromInt(0x20000000))[0..0x8000]; | ||
| 11 | export fn writeToVRam() void { | ||
| 12 | vram[0] = 'X'; | ||
| 13 | } | ||
| 14 | |||
| 15 | const PackedStruct = packed struct { | ||
| 16 | a: u8, | ||
| 17 | b: u8, | ||
| 18 | }; | ||
| 19 | const PackedUnion = packed union { | ||
| 20 | a: u8, | ||
| 21 | b: u32, | ||
| 22 | }; | ||
| 23 | |||
| 24 | test "packed struct, enum, union parameters in extern function" { | ||
| 25 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | ||
| 26 | |||
| 27 | testPackedStuff(&(PackedStruct{ | ||
| 28 | .a = 1, | ||
| 29 | .b = 2, | ||
| 30 | }), &(PackedUnion{ .a = 1 })); | ||
| 31 | } | ||
| 32 | |||
| 33 | export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { | ||
| 34 | if (false) { | ||
| 35 | a; | ||
| 36 | b; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | test "exporting enum type and value" { | ||
| 41 | const S = struct { | ||
| 42 | const E = enum(c_int) { one, two }; | ||
| 43 | const e: E = .two; | ||
| 44 | comptime { | ||
| 45 | @export(e, .{ .name = "e" }); | ||
| 46 | } | ||
| 47 | }; | ||
| 48 | try expect(S.e == .two); | ||
| 49 | } | ||
| 50 | |||
| 51 | test "exporting with internal linkage" { | ||
| 52 | const S = struct { | ||
| 53 | fn foo() callconv(.C) void {} | ||
| 54 | comptime { | ||
| 55 | @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal }); | ||
| 56 | } | ||
| 57 | }; | ||
| 58 | S.foo(); | ||
| 59 | } | ||
| 60 | |||
| 61 | test "exporting using field access" { | ||
| 62 | const S = struct { | ||
| 63 | const Inner = struct { | ||
| 64 | const x: u32 = 5; | ||
| 65 | }; | ||
| 66 | comptime { | ||
| 67 | @export(Inner.x, .{ .name = "foo", .linkage = .Internal }); | ||
| 68 | } | ||
| 69 | }; | ||
| 70 | |||
| 71 | _ = S.Inner.x; | ||
| 72 | } | ||
| 73 | |||
| 74 | test "exporting comptime-known value" { | ||
| 75 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | ||
| 76 | |||
| 77 | const x: u32 = 10; | ||
| 78 | @export(x, .{ .name = "exporting_comptime_known_value_foo" }); | ||
| 79 | const S = struct { | ||
| 80 | extern const exporting_comptime_known_value_foo: u32; | ||
| 81 | }; | ||
| 82 | try expect(S.exporting_comptime_known_value_foo == 10); | ||
| 83 | } | ||
| 84 | |||
| 85 | test "exporting comptime var" { | ||
| 86 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | ||
| 87 | |||
| 88 | comptime var x: u32 = 5; | ||
| 89 | @export(x, .{ .name = "exporting_comptime_var_foo" }); | ||
| 90 | x = 7; // modifying this now shouldn't change anything | ||
| 91 | const S = struct { | ||
| 92 | extern const exporting_comptime_var_foo: u32; | ||
| 93 | }; | ||
| 94 | try expect(S.exporting_comptime_var_foo == 5); | ||
| 95 | } | ||
test/behavior/export_builtin.zig created+88| ... | @@ -0,0 +1,88 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | const expect = std.testing.expect; | ||
| 4 | |||
| 5 | test "exporting enum type and value" { | ||
| 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 7 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 8 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 10 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 11 | |||
| 12 | const S = struct { | ||
| 13 | const E = enum(c_int) { one, two }; | ||
| 14 | const e: E = .two; | ||
| 15 | comptime { | ||
| 16 | @export(e, .{ .name = "e" }); | ||
| 17 | } | ||
| 18 | }; | ||
| 19 | try expect(S.e == .two); | ||
| 20 | } | ||
| 21 | |||
| 22 | test "exporting with internal linkage" { | ||
| 23 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 24 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 25 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 26 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 27 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 28 | |||
| 29 | const S = struct { | ||
| 30 | fn foo() callconv(.C) void {} | ||
| 31 | comptime { | ||
| 32 | @export(foo, .{ .name = "exporting_with_internal_linkage_foo", .linkage = .Internal }); | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | S.foo(); | ||
| 36 | } | ||
| 37 | |||
| 38 | test "exporting using field access" { | ||
| 39 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 40 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 41 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 42 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 43 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 44 | |||
| 45 | const S = struct { | ||
| 46 | const Inner = struct { | ||
| 47 | const x: u32 = 5; | ||
| 48 | }; | ||
| 49 | comptime { | ||
| 50 | @export(Inner.x, .{ .name = "foo", .linkage = .Internal }); | ||
| 51 | } | ||
| 52 | }; | ||
| 53 | |||
| 54 | _ = S.Inner.x; | ||
| 55 | } | ||
| 56 | |||
| 57 | test "exporting comptime-known value" { | ||
| 58 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | ||
| 59 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 60 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 61 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 62 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 63 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 64 | |||
| 65 | const x: u32 = 10; | ||
| 66 | @export(x, .{ .name = "exporting_comptime_known_value_foo" }); | ||
| 67 | const S = struct { | ||
| 68 | extern const exporting_comptime_known_value_foo: u32; | ||
| 69 | }; | ||
| 70 | try expect(S.exporting_comptime_known_value_foo == 10); | ||
| 71 | } | ||
| 72 | |||
| 73 | test "exporting comptime var" { | ||
| 74 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; | ||
| 75 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 76 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 77 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 78 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 79 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 80 | |||
| 81 | comptime var x: u32 = 5; | ||
| 82 | @export(x, .{ .name = "exporting_comptime_var_foo" }); | ||
| 83 | x = 7; // modifying this now shouldn't change anything | ||
| 84 | const S = struct { | ||
| 85 | extern const exporting_comptime_var_foo: u32; | ||
| 86 | }; | ||
| 87 | try expect(S.exporting_comptime_var_foo == 5); | ||
| 88 | } | ||
test/behavior/export_keyword.zig created+38| ... | @@ -0,0 +1,38 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const expect = std.testing.expect; | ||
| 3 | const expectEqualSlices = std.testing.expectEqualSlices; | ||
| 4 | const expectEqualStrings = std.testing.expectEqualStrings; | ||
| 5 | const mem = std.mem; | ||
| 6 | const builtin = @import("builtin"); | ||
| 7 | |||
| 8 | // can't really run this test but we can make sure it has no compile error | ||
| 9 | // and generates code | ||
| 10 | const vram = @as([*]volatile u8, @ptrFromInt(0x20000000))[0..0x8000]; | ||
| 11 | export fn writeToVRam() void { | ||
| 12 | vram[0] = 'X'; | ||
| 13 | } | ||
| 14 | |||
| 15 | const PackedStruct = packed struct { | ||
| 16 | a: u8, | ||
| 17 | b: u8, | ||
| 18 | }; | ||
| 19 | const PackedUnion = packed union { | ||
| 20 | a: u8, | ||
| 21 | b: u32, | ||
| 22 | }; | ||
| 23 | |||
| 24 | test "packed struct, enum, union parameters in extern function" { | ||
| 25 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | ||
| 26 | |||
| 27 | testPackedStuff(&(PackedStruct{ | ||
| 28 | .a = 1, | ||
| 29 | .b = 2, | ||
| 30 | }), &(PackedUnion{ .a = 1 })); | ||
| 31 | } | ||
| 32 | |||
| 33 | export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { | ||
| 34 | if (false) { | ||
| 35 | a; | ||
| 36 | b; | ||
| 37 | } | ||
| 38 | } | ||
test/behavior/fn.zig+17| ... | @@ -574,3 +574,20 @@ test "pass and return comptime-only types" { | ... | @@ -574,3 +574,20 @@ test "pass and return comptime-only types" { |
| 574 | try expectEqual(null, S.returnNull(null)); | 574 | try expectEqual(null, S.returnNull(null)); |
| 575 | try expectEqual(@as(u0, 0), S.returnUndefined(undefined)); | 575 | try expectEqual(@as(u0, 0), S.returnUndefined(undefined)); |
| 576 | } | 576 | } |
| 577 | |||
| 578 | test "pointer to alias behaves same as pointer to function" { | ||
| 579 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 580 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 581 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 582 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 583 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 584 | |||
| 585 | const S = struct { | ||
| 586 | fn foo() u32 { | ||
| 587 | return 11227; | ||
| 588 | } | ||
| 589 | const bar = foo; | ||
| 590 | }; | ||
| 591 | var a = &S.bar; | ||
| 592 | try std.testing.expect(S.foo() == a()); | ||
| 593 | } |
test/behavior/globals.zig created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const builtin = @import("builtin"); | ||
| 3 | const expect = std.testing.expect; | ||
| 4 | |||
| 5 | var pos = [2]f32{ 0.0, 0.0 }; | ||
| 6 | test "store to global array" { | ||
| 7 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; | ||
| 8 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 9 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 10 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 11 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 12 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 13 | |||
| 14 | try expect(pos[1] == 0.0); | ||
| 15 | pos = [2]f32{ 0.0, 1.0 }; | ||
| 16 | try expect(pos[1] == 1.0); | ||
| 17 | } | ||
| 18 | |||
| 19 | var vpos = @Vector(2, f32){ 0.0, 0.0 }; | ||
| 20 | test "store to global vector" { | ||
| 21 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; | ||
| 22 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 23 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 24 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | ||
| 25 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | ||
| 26 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 27 | |||
| 28 | try expect(vpos[1] == 0.0); | ||
| 29 | vpos = @Vector(2, f32){ 0.0, 1.0 }; | ||
| 30 | try expect(vpos[1] == 1.0); | ||
| 31 | } | ||
test/behavior/nan.zig created+42| ... | @@ -0,0 +1,42 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | const math = std.math; | ||
| 4 | const mem = std.mem; | ||
| 5 | const testing = std.testing; | ||
| 6 | |||
| 7 | const qnan_u16: u16 = 0x7E00; | ||
| 8 | const snan_u16: u16 = 0x7D00; | ||
| 9 | const qnan_u32: u32 = 0x7FC00000; | ||
| 10 | const snan_u32: u32 = 0x7FA00000; | ||
| 11 | const qnan_u64: u64 = 0x7FF8000000000000; | ||
| 12 | const snan_u64: u64 = 0x7FF4000000000000; | ||
| 13 | const qnan_u128: u128 = 0x7FFF8000000000000000000000000000; | ||
| 14 | const snan_u128: u128 = 0x7FFF4000000000000000000000000000; | ||
| 15 | const qnan_f16: f16 = math.nan(f16); | ||
| 16 | const snan_f16: f16 = math.snan(f16); | ||
| 17 | const qnan_f32: f32 = math.nan(f32); | ||
| 18 | const snan_f32: f32 = math.snan(f32); | ||
| 19 | const qnan_f64: f64 = math.nan(f64); | ||
| 20 | const snan_f64: f64 = math.snan(f64); | ||
| 21 | const qnan_f128: f128 = math.nan(f128); | ||
| 22 | const snan_f128: f128 = math.snan(f128); | ||
| 23 | |||
| 24 | test "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 | } | ||