stage2: bitNot
This commit is contained in:
@@ -235,3 +235,17 @@ test "comptime_int param and return" {
|
||||
fn comptimeAdd(comptime a: comptime_int, comptime b: comptime_int) comptime_int {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
test "binary not" {
|
||||
try expect(comptime x: {
|
||||
break :x ~@as(u16, 0b1010101010101010) == 0b0101010101010101;
|
||||
});
|
||||
try expect(comptime x: {
|
||||
break :x ~@as(u64, 2147483647) == 18446744071562067968;
|
||||
});
|
||||
try testBinaryNot(0b1010101010101010);
|
||||
}
|
||||
|
||||
fn testBinaryNot(x: u16) !void {
|
||||
try expect(~x == 0b0101010101010101);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user