aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-16 16:39:31 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-16 16:39:31 -0500
commit0caee421e38672869dd596e6af732567cfaf2037 (patch)
tree44ccd0e37f9f4b6d3ed984ed5bd20f7326dab79a /test
parent867686af420bab965f63359499a526f35e875c9a (diff)
downloadzig-0caee421e38672869dd596e6af732567cfaf2037.tar.gz
zig-0caee421e38672869dd596e6af732567cfaf2037.zip
ability to equality compare with null
closes #106
Diffstat (limited to 'test')
-rw-r--r--test/cases/null.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/cases/null.zig b/test/cases/null.zig
index 280023a93d..5359f0309f 100644
--- a/test/cases/null.zig
+++ b/test/cases/null.zig
@@ -83,8 +83,11 @@ const Particle = struct {
fn nullLiteralOutsideFunction() {
@setFnTest(this);
- const is_null = if (const _ ?= here_is_a_null_literal.context) false else true;
+ const is_null = here_is_a_null_literal.context == null;
assert(is_null);
+
+ const is_non_null = here_is_a_null_literal.context != null;
+ assert(!is_non_null);
}
const SillyStruct = struct {
context: ?i32,
@@ -99,3 +102,13 @@ fn foo(x: ?i32) -> ?bool {
const value = ?return x;
return value > 1234;
}
+
+fn testNullRuntime() {
+ @setFnTest(this);
+
+ testTestNullRuntime(null);
+}
+fn testTestNullRuntime(x: ?i32) {
+ assert(x == null);
+ assert(!(x != null));
+}