zig/test/behavior/bugs/2114.zig

20 lines
632 B
Zig
Raw Normal View History

const std = @import("std");
const expect = std.testing.expect;
const math = std.math;
2020-07-11 19:09:04 +08:00
fn ctz(x: anytype) usize {
return @ctz(@TypeOf(x), x);
}
test "fixed" {
try testClz();
comptime try testClz();
}
fn testClz() !void {
try expect(ctz(@as(u128, 0x40000000000000000000000000000000)) == 126);
try expect(math.rotl(u128, @as(u128, 0x40000000000000000000000000000000), @as(u8, 1)) == @as(u128, 0x80000000000000000000000000000000));
try expect(ctz(@as(u128, 0x80000000000000000000000000000000)) == 127);
try expect(ctz(math.rotl(u128, @as(u128, 0x40000000000000000000000000000000), @as(u8, 1))) == 127);
}