diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-07 15:27:05 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-07 15:27:05 -0700 |
| commit | 76335bc7badd41af0ebb7dd196e1550d7e99d8e7 (patch) | |
| tree | 4057c1def983d9ea39d67e617e52820fed61331f /test/behavior/array.zig | |
| parent | 601ac82041653adc2acbcfd947a54286944df9df (diff) | |
| download | zig-76335bc7badd41af0ebb7dd196e1550d7e99d8e7.tar.gz zig-76335bc7badd41af0ebb7dd196e1550d7e99d8e7.zip | |
stage2: implement array literal with explicit type
New ZIR instruction: elem_ptr_imm
This saves some memory for array literals since the element indexes are
communicated as immediate values rather than as references to other ZIR
instructions.
Diffstat (limited to 'test/behavior/array.zig')
| -rw-r--r-- | test/behavior/array.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 9c7282f0f2..a81ff2f155 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -33,8 +33,13 @@ test "array init with mult" { var i: [8]u8 = [2]u8{ a, 'b' } ** 4; try expect(std.mem.eql(u8, &i, "abababab")); - // this should cause a Value.repeated to be emitted in AIR. - // TODO: find a way to test that this is actually getting emmited var j: [4]u8 = [1]u8{'a'} ** 4; try expect(std.mem.eql(u8, &j, "aaaa")); } + +test "array literal with explicit type" { + const hex_mult: [4]u16 = .{ 4096, 256, 16, 1 }; + + try expect(hex_mult.len == 4); + try expect(hex_mult[1] == 256); +} |
