aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/cast_int.zig
blob: c30039eb524f79770d878782cd78d75fad472da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const builtin = @import("builtin");
const std = @import("std");
const expect = std.testing.expect;
const maxInt = std.math.maxInt;

test "@intCast i32 to u7" {
    if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
    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
    if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO

    var x: u128 = maxInt(u128);
    var y: i32 = 120;
    var z = x >> @intCast(u7, y);
    try expect(z == 0xff);
}