aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/array.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior/array.zig')
-rw-r--r--test/behavior/array.zig27
1 files changed, 17 insertions, 10 deletions
diff --git a/test/behavior/array.zig b/test/behavior/array.zig
index a5ecd6f115..3d711357f3 100644
--- a/test/behavior/array.zig
+++ b/test/behavior/array.zig
@@ -48,16 +48,23 @@ fn getArrayLen(a: []const u32) usize {
test "array concat with undefined" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
- {
- var array = "hello".* ++ @as([5]u8, undefined);
- array[5..10].* = "world".*;
- try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
- }
- {
- var array = @as([5]u8, undefined) ++ "world".*;
- array[0..5].* = "hello".*;
- try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
- }
+ const S = struct {
+ fn doTheTest() !void {
+ {
+ var array = "hello".* ++ @as([5]u8, undefined);
+ array[5..10].* = "world".*;
+ try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
+ }
+ {
+ var array = @as([5]u8, undefined) ++ "world".*;
+ array[0..5].* = "hello".*;
+ try std.testing.expect(std.mem.eql(u8, &array, "helloworld"));
+ }
+ }
+ };
+
+ try S.doTheTest();
+ comptime try S.doTheTest();
}
test "array concat with tuple" {