aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs/421.zig
blob: 800d4e72c2a534fdf93a148c1fff2d499b3271a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const builtin = @import("builtin");
const expect = @import("std").testing.expect;

test "bitCast to array" {
    if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
    if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
    if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO

    comptime try testBitCastArray();
    try testBitCastArray();
}

fn testBitCastArray() !void {
    try expect(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
}

fn extractOne64(a: u128) u64 {
    const x = @bitCast([2]u64, a);
    return x[1];
}