aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index c41832e47d..1038983d2e 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -710,7 +710,7 @@ pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
add_simple_case("maybe type", R"SOURCE(
use "std.zig";
-pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
+pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
const x : ?bool = true;
if (const y ?= x) {
@@ -722,6 +722,23 @@ pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
} else {
print_str("x is none\n");
}
+
+ const next_x : ?i32 = null;
+
+ const z = next_x ?? 1234;
+
+ if (z != 1234) {
+ print_str("BAD\n");
+ }
+
+ const final_x : ?i32 = 13;
+
+ const num = final_x ?? unreachable;
+
+ if (num != 13) {
+ print_str("BAD\n");
+ }
+
return 0;
}
)SOURCE", "x is true\n");