Skip to content

Commit

Permalink
Enable bitcast test now that #13214 is resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
topolarity committed Oct 28, 2022
1 parent 03ed0a5 commit 606915d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/behavior/bitcast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,17 @@ test "comptime @bitCast packed struct to int and back" {
}
}

test "comptime bitcast with fields following a float" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO: https://github.com/ziglang/zig/issues/13214
test "comptime bitcast with fields following f80" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;

const FloatT = extern struct { f: f80, x: u128 };
var x: FloatT = .{ .f = 0.5, .x = 123 };
try expect(@bitCast(u256, x) == comptime @bitCast(u256, @as(FloatT, .{ .f = 0.5, .x = 123 })));
const valid_mask = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_0000_0000_0000_ffff_ffff_ffff_ffff_ffff;
try expect((@bitCast(u256, x) ^ comptime @bitCast(u256, FloatT{ .f = 0.5, .x = 123 })) & valid_mask == 0);
}

test "bitcast vector to integer and back" {
Expand Down

0 comments on commit 606915d

Please sign in to comment.