authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-10-28 08:51:15-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-10-28 12:41:15-07:00
log40b7792a4c815868bafe882cc77d89a67c08571b
treeadb7867f928e1b4a9bb50788aaaf17b0909bc573
parent03ed0a59e337d89c9650cc8a70ff431b66ee8671

Enable bitcast test now that #13214 is resolved.


1 files changed, 12 insertions(+), 5 deletions(-)

test/behavior/bitcast.zig+12-5
...@@ -375,12 +375,19 @@ test "comptime @bitCast packed struct to int and back" {...@@ -375,12 +375,19 @@ test "comptime @bitCast packed struct to int and back" {
375 }375 }
376}376}
377377
378test "comptime bitcast with fields following a float" {378test "comptime bitcast with fields following f80" {
379 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO: https://github.com/ziglang/zig/issues/13214379 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
380 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
381 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
382 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
383 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
384
385 const FloatT = extern struct { f: f80, x: u128 align(16) };
386 const x: FloatT = .{ .f = 0.5, .x = 123 };
387 var x_as_uint: u256 = comptime @bitCast(u256, x);
380388
381 const FloatT = extern struct { f: f80, x: u128 };389 try expect(x.f == @bitCast(FloatT, x_as_uint).f);
382 var x: FloatT = .{ .f = 0.5, .x = 123 };390 try expect(x.x == @bitCast(FloatT, x_as_uint).x);
383 try expect(@bitCast(u256, x) == comptime @bitCast(u256, @as(FloatT, .{ .f = 0.5, .x = 123 })));
384}391}
385392
386test "bitcast vector to integer and back" {393test "bitcast vector to integer and back" {