aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-17 16:06:48 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-17 16:16:17 -0500
commit12fcbecbf8a1c8496354b909e0de2a69600115a9 (patch)
tree4c625d36661db5860196763f8d952753f12d1fd4 /test
parent3a3cc7bf76eab3ef239991e686c114baeaf4672e (diff)
downloadzig-12fcbecbf8a1c8496354b909e0de2a69600115a9.tar.gz
zig-12fcbecbf8a1c8496354b909e0de2a69600115a9.zip
IR: add more instructions
* MaybeWrap * TestErr * UnwrapErrCode * UnwrapErrPayload * ErrUnionTypeChild * ErrWrapCode * ErrWrapPayload
Diffstat (limited to 'test')
-rw-r--r--test/cases/err_wrapping.zig13
-rw-r--r--test/self_hosted2.zig5
2 files changed, 18 insertions, 0 deletions
diff --git a/test/cases/err_wrapping.zig b/test/cases/err_wrapping.zig
new file mode 100644
index 0000000000..083d6a40cc
--- /dev/null
+++ b/test/cases/err_wrapping.zig
@@ -0,0 +1,13 @@
+pub fn foo() -> %i32 {
+ const x = %return bar();
+ return x + 1
+}
+
+pub fn bar() -> %i32 {
+ return 13;
+}
+
+pub fn baz() -> %i32 {
+ const y = foo() %% 1234;
+ return y + 1;
+}
diff --git a/test/self_hosted2.zig b/test/self_hosted2.zig
index 214b59dd6c..517567271e 100644
--- a/test/self_hosted2.zig
+++ b/test/self_hosted2.zig
@@ -1,4 +1,5 @@
const case_namespace_fn_call = @import("cases/namespace_fn_call.zig");
+const case_err_wrapping = @import("cases/err_wrapping.zig");
pub const SYS_write = 1;
pub const SYS_exit = 60;
@@ -354,6 +355,9 @@ fn assignToIfVarPtr() {
assert(??maybe_bool == false);
}
+fn errorWrapping() {
+ assert(%%case_err_wrapping.baz() == 15);
+}
fn assert(ok: bool) {
if (!ok)
@@ -390,6 +394,7 @@ fn runAllTests() {
overflowIntrinsics();
shlWithOverflow();
assignToIfVarPtr();
+ errorWrapping();
}
export nakedcc fn _start() -> unreachable {