aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/array.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-12-24 02:32:13 -0500
committerJacob Young <jacobly0@users.noreply.github.com>2022-12-24 02:40:33 -0500
commit0559cdb5542a2acb50ce49363c1973f3ca70365e (patch)
tree3c44549cc3b1b6aaff0b98893ee0585199d2b49f /test/behavior/array.zig
parentc9e3524d0b12e11488519bb377e7dcf60047963a (diff)
downloadzig-0559cdb5542a2acb50ce49363c1973f3ca70365e.tar.gz
zig-0559cdb5542a2acb50ce49363c1973f3ca70365e.zip
Sema: support concat of tuple and array
Closes #14041
Diffstat (limited to 'test/behavior/array.zig')
-rw-r--r--test/behavior/array.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/behavior/array.zig b/test/behavior/array.zig
index b886869be1..155ac294cf 100644
--- a/test/behavior/array.zig
+++ b/test/behavior/array.zig
@@ -45,6 +45,24 @@ fn getArrayLen(a: []const u32) usize {
return a.len;
}
+test "array concat with tuple" {
+ const array: [2]u8 = .{ 1, 2 };
+ {
+ const seq = array ++ .{ 3, 4 };
+ try std.testing.expectEqualSlices(u8, &.{ 1, 2, 3, 4 }, &seq);
+ }
+ {
+ const seq = .{ 3, 4 } ++ array;
+ try std.testing.expectEqualSlices(u8, &.{ 3, 4, 1, 2 }, &seq);
+ }
+}
+
+test "array init with concat" {
+ const a = 'a';
+ var i: [4]u8 = [2]u8{ a, 'b' } ++ [2]u8{ 'c', 'd' };
+ try expect(std.mem.eql(u8, &i, "abcd"));
+}
+
test "array init with mult" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO