diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 02:00:23 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-23 02:00:23 -0400 |
| commit | 46eb77dbb200756b96bfae4c5166397fefba66d0 (patch) | |
| tree | 618f0117563dfabbe0e4253f6fa817e526b5a64c /test | |
| parent | 4b902b44a244e29106637f9777aa71b1cd4c22d2 (diff) | |
| download | zig-46eb77dbb200756b96bfae4c5166397fefba66d0.tar.gz zig-46eb77dbb200756b96bfae4c5166397fefba66d0.zip | |
stack trace is able to figure out compilation unit
each address is contained within
also fix a bug having to do with codegen for enum value
initialization expressions
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/switch_prong_err_enum.zig | 29 | ||||
| -rw-r--r-- | test/self_hosted.zig | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/test/cases/switch_prong_err_enum.zig b/test/cases/switch_prong_err_enum.zig new file mode 100644 index 0000000000..cb8c864357 --- /dev/null +++ b/test/cases/switch_prong_err_enum.zig @@ -0,0 +1,29 @@ +const assert = @import("std").debug.assert; + +var read_count: u64 = 0; + +fn readOnce() -> %u64 { + read_count += 1; + return read_count; +} + +error InvalidDebugInfo; + +enum FormValue { + Address: u64, + Other: bool, +} + +#static_eval_enable(false) +fn doThing(form_id: u64) -> %FormValue { + return switch (form_id) { + 17 => FormValue.Address { %return readOnce() }, + else => error.InvalidDebugInfo, + } +} + +#attribute("test") +fn switchProngReturnsErrorEnum() { + %%doThing(17); + assert(read_count == 1); +} diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 2a8814b17a..7b58684b05 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -12,6 +12,7 @@ const test_max_value_type = @import("cases/max_value_type.zig"); const test_var_params = @import("cases/var_params.zig"); const test_const_slice_child = @import("cases/const_slice_child.zig"); const test_switch_prong_implicit_cast = @import("cases/switch_prong_implicit_cast.zig"); +const test_switch_prong_err_enum = @import("cases/switch_prong_err_enum.zig"); // normal comment /// this is a documentation comment |
