C backend: Fix array declarations

This commit is contained in:
Annika L
2022-04-01 00:28:46 -07:00
committed by Andrew Kelley
parent 5da0e03553
commit c992b25908
3 changed files with 66 additions and 29 deletions

View File

@@ -148,7 +148,7 @@ test "void arrays" {
try expect(array.len == 4);
}
test "nested arrays" {
test "nested arrays of strings" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
@@ -162,6 +162,22 @@ test "nested arrays" {
}
}
test "nested arrays of integers" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
const array_of_numbers = [_][2]u8{
[2]u8{ 1, 2 },
[2]u8{ 3, 4 },
};
try expect(array_of_numbers[0][0] == 1);
try expect(array_of_numbers[0][1] == 2);
try expect(array_of_numbers[1][0] == 3);
try expect(array_of_numbers[1][1] == 4);
}
test "implicit comptime in array type size" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;