From 16302578d5a0ca226c7db76bc8e39574dea1dc1d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Mar 2023 14:04:58 -0700 Subject: add behavior test case for previous commit --- test/behavior/slice.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index 435e1887bb..ed5e2a721d 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -747,3 +747,18 @@ test "slice decays to many pointer" { const p: [*:0]const u8 = buf[0..7 :0]; try expectEqualStrings(buf[0..7], std.mem.span(p)); } + +test "write through pointer to optional slice arg" { + const S = struct { + fn bar(foo: *?[]const u8) !void { + foo.* = try baz(); + } + + fn baz() ![]const u8 { + return "ok"; + } + }; + var foo: ?[]const u8 = null; + try S.bar(&foo); + try expectEqualStrings(foo.?, "ok"); +} -- cgit v1.2.3 From 8ea1c1932e7bd869ec77a161da7876d171d4ef1d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 5 Mar 2023 04:25:04 -0500 Subject: behavior: disable failing tests --- test/behavior/slice.zig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index ed5e2a721d..6239de2d76 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -749,6 +749,11 @@ test "slice decays to many pointer" { } test "write through pointer to optional slice arg" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + const S = struct { fn bar(foo: *?[]const u8) !void { foo.* = try baz(); -- cgit v1.2.3