aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/math.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-10-16 14:47:55 +0200
committerRobin Voetter <robin@voetter.nl>2021-10-17 20:33:04 +0200
commit9336a87452eda87c19cb707484d0b6dfb4140b57 (patch)
tree72d50163e2ad1389d5752de0e841b8f68755f3d5 /test/behavior/math.zig
parent6a3659c4e005d9730fb824b77b416ef33200dbfe (diff)
downloadzig-9336a87452eda87c19cb707484d0b6dfb4140b57.tar.gz
zig-9336a87452eda87c19cb707484d0b6dfb4140b57.zip
stage2: bitNot
Diffstat (limited to 'test/behavior/math.zig')
-rw-r--r--test/behavior/math.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/behavior/math.zig b/test/behavior/math.zig
index 56fbdc124d..8ca757b0cc 100644
--- a/test/behavior/math.zig
+++ b/test/behavior/math.zig
@@ -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);
+}