aboutsummaryrefslogtreecommitdiff
path: root/test/runtime_safety.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-18 18:48:29 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-18 18:48:29 -0400
commit626b73e8beeaae1cab23f883f877d89d64bbfa39 (patch)
tree4ed0ee57e00134f34656e759282b5c0e771726b2 /test/runtime_safety.zig
parenta430853a48a5e4dbcd0094c632957e28898159f3 (diff)
downloadzig-626b73e8beeaae1cab23f883f877d89d64bbfa39.tar.gz
zig-626b73e8beeaae1cab23f883f877d89d64bbfa39.zip
remove error to/from int casting syntax; add `@errorToInt`/`@intToError`
See #1061
Diffstat (limited to 'test/runtime_safety.zig')
-rw-r--r--test/runtime_safety.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig
index 96384066e5..ea5beafe8d 100644
--- a/test/runtime_safety.zig
+++ b/test/runtime_safety.zig
@@ -175,7 +175,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\ if (x.len == 0) return error.Whatever;
\\}
\\fn widenSlice(slice: []align(1) const u8) []align(1) const i32 {
- \\ return ([]align(1) const i32)(slice);
+ \\ return @bytesToSlice(i32, slice);
\\}
);
@@ -227,12 +227,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\pub fn main() void {
\\ _ = bar(9999);
\\}
- \\fn bar(x: u32) error {
- \\ return error(x);
+ \\fn bar(x: u16) error {
+ \\ return @intToError(x);
\\}
);
- cases.addRuntimeSafety("cast integer to non-global error set and no match",
+ cases.addRuntimeSafety("@errSetCast error not present in destination",
\\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
\\ @import("std").os.exit(126);
\\}
@@ -242,7 +242,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\ _ = foo(Set1.B);
\\}
\\fn foo(set1: Set1) Set2 {
- \\ return Set2(set1);
+ \\ return @errSetCast(Set2, set1);
\\}
);
@@ -252,12 +252,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
\\}
\\pub fn main() !void {
\\ var array align(4) = []u32{0x11111111, 0x11111111};
- \\ const bytes = ([]u8)(array[0..]);
+ \\ const bytes = @sliceToBytes(array[0..]);
\\ if (foo(bytes) != 0x11111111) return error.Wrong;
\\}
\\fn foo(bytes: []u8) u32 {
\\ const slice4 = bytes[1..5];
- \\ const int_slice = ([]u32)(@alignCast(4, slice4));
+ \\ const int_slice = @bytesToSlice(u32, @alignCast(4, slice4));
\\ return int_slice[0];
\\}
);