diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-06-15 01:19:17 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2023-06-15 01:23:58 +0100 |
| commit | 57f6e6729f74bc7f43848aff6cd52e89465cc49e (patch) | |
| tree | bdc96ee8df0f51e948686ba7d7dd4c79bd3e48c1 /test/behavior | |
| parent | 45e961772050191ce94becc53dcb86971a5804ab (diff) | |
| download | zig-57f6e6729f74bc7f43848aff6cd52e89465cc49e.tar.gz zig-57f6e6729f74bc7f43848aff6cd52e89465cc49e.zip | |
Sema: allow empty end index in zirSliceSentinel
This fixes a regression, and enables some related behavior tests which
were accidentally disabled.
Diffstat (limited to 'test/behavior')
| -rw-r--r-- | test/behavior/slice.zig | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index 79990feba4..ae5fbf0951 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -378,12 +378,16 @@ test "slice syntax resulting in pointer-to-array" { try testPointer0(); try testPointerAlign(); try testSlice(); + try testSliceZ(); try testSliceOpt(); try testSliceAlign(); + try testConcatStrLiterals(); try testSliceLength(); try testSliceLengthZ(); try testArrayLength(); try testArrayLengthZ(); + try testMultiPointer(); + try testMultiPointerLengthZ(); } fn testArray() !void { @@ -469,8 +473,12 @@ test "slice syntax resulting in pointer-to-array" { var array = [5:0]u8{ 1, 2, 3, 4, 5 }; var slice: [:0]u8 = &array; try comptime expect(@TypeOf(slice[1..3]) == *[2]u8); - try comptime expect(@TypeOf(slice[1..]) == [:0]u8); try comptime expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8); + if (@inComptime()) { + try comptime expect(@TypeOf(slice[1..]) == *[4:0]u8); + } else { + try comptime expect(@TypeOf(slice[1..]) == [:0]u8); + } } fn testSliceOpt() !void { @@ -491,8 +499,8 @@ test "slice syntax resulting in pointer-to-array" { } fn testConcatStrLiterals() !void { - try expectEqualSlices("a"[0..] ++ "b"[0..], "ab"); - try expectEqualSlices("a"[0.. :0] ++ "b"[0.. :0], "ab"); + try expectEqualSlices(u8, "ab", "a"[0..] ++ "b"[0..]); + try expectEqualSlices(u8, "ab", "a"[0.. :0] ++ "b"[0.. :0]); } fn testSliceLength() !void { @@ -541,18 +549,18 @@ test "slice syntax resulting in pointer-to-array" { var array = [5:0]u8{ 1, 2, 3, 4, 5 }; var ptr: [*]u8 = &array; try comptime expect(@TypeOf(ptr[1..][0..2]) == *[2]u8); - try comptime expect(@TypeOf(ptr[1..][0..4]) == *[4:0]u8); + try comptime expect(@TypeOf(ptr[1..][0..4]) == *[4]u8); try comptime expect(@TypeOf(ptr[1..][0..2 :4]) == *[2:4]u8); try comptime expect(@TypeOf(ptr[1.. :0][0..2]) == *[2]u8); - try comptime expect(@TypeOf(ptr[1.. :0][0..4]) == *[4:0]u8); + try comptime expect(@TypeOf(ptr[1.. :0][0..4]) == *[4]u8); try comptime expect(@TypeOf(ptr[1.. :0][0..2 :4]) == *[2:4]u8); var ptr_z: [*:0]u8 = &array; try comptime expect(@TypeOf(ptr_z[1..][0..2]) == *[2]u8); - try comptime expect(@TypeOf(ptr_z[1..][0..4]) == *[4:0]u8); + try comptime expect(@TypeOf(ptr_z[1..][0..4]) == *[4]u8); try comptime expect(@TypeOf(ptr_z[1..][0..2 :4]) == *[2:4]u8); try comptime expect(@TypeOf(ptr_z[1.. :0][0..2]) == *[2]u8); - try comptime expect(@TypeOf(ptr_z[1.. :0][0..4]) == *[4:0]u8); + try comptime expect(@TypeOf(ptr_z[1.. :0][0..4]) == *[4]u8); try comptime expect(@TypeOf(ptr_z[1.. :0][0..2 :4]) == *[2:4]u8); } }; |
