| ... | @@ -27,7 +27,10 @@ comptime { | ... | @@ -27,7 +27,10 @@ comptime { |
| 27 | } | 27 | } |
| 28 | | 28 | |
| 29 | test "slicing" { | 29 | test "slicing" { |
| | 30 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 31 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 30 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 32 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 33 | |
| 31 | var array: [20]i32 = undefined; | 34 | var array: [20]i32 = undefined; |
| 32 | | 35 | |
| 33 | array[5] = 1234; | 36 | array[5] = 1234; |
| ... | @@ -45,6 +48,8 @@ test "slicing" { | ... | @@ -45,6 +48,8 @@ test "slicing" { |
| 45 | | 48 | |
| 46 | test "const slice" { | 49 | test "const slice" { |
| 47 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 50 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 51 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 52 | |
| 48 | comptime { | 53 | comptime { |
| 49 | const a = "1234567890"; | 54 | const a = "1234567890"; |
| 50 | try expect(a.len == 10); | 55 | try expect(a.len == 10); |
| ... | @@ -56,6 +61,8 @@ test "const slice" { | ... | @@ -56,6 +61,8 @@ test "const slice" { |
| 56 | | 61 | |
| 57 | test "comptime slice of undefined pointer of length 0" { | 62 | test "comptime slice of undefined pointer of length 0" { |
| 58 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 63 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 64 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 65 | |
| 59 | const slice1 = @as([*]i32, undefined)[0..0]; | 66 | const slice1 = @as([*]i32, undefined)[0..0]; |
| 60 | try expect(slice1.len == 0); | 67 | try expect(slice1.len == 0); |
| 61 | const slice2 = @as([*]i32, undefined)[100..100]; | 68 | const slice2 = @as([*]i32, undefined)[100..100]; |
| ... | @@ -64,6 +71,8 @@ test "comptime slice of undefined pointer of length 0" { | ... | @@ -64,6 +71,8 @@ test "comptime slice of undefined pointer of length 0" { |
| 64 | | 71 | |
| 65 | test "implicitly cast array of size 0 to slice" { | 72 | test "implicitly cast array of size 0 to slice" { |
| 66 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 73 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 74 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 75 | |
| 67 | var msg = [_]u8{}; | 76 | var msg = [_]u8{}; |
| 68 | try assertLenIsZero(&msg); | 77 | try assertLenIsZero(&msg); |
| 69 | } | 78 | } |
| ... | @@ -74,6 +83,8 @@ fn assertLenIsZero(msg: []const u8) !void { | ... | @@ -74,6 +83,8 @@ fn assertLenIsZero(msg: []const u8) !void { |
| 74 | | 83 | |
| 75 | test "access len index of sentinel-terminated slice" { | 84 | test "access len index of sentinel-terminated slice" { |
| 76 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 85 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 86 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 87 | |
| 77 | const S = struct { | 88 | const S = struct { |
| 78 | fn doTheTest() !void { | 89 | fn doTheTest() !void { |
| 79 | var slice: [:0]const u8 = "hello"; | 90 | var slice: [:0]const u8 = "hello"; |
| ... | @@ -88,6 +99,8 @@ test "access len index of sentinel-terminated slice" { | ... | @@ -88,6 +99,8 @@ test "access len index of sentinel-terminated slice" { |
| 88 | | 99 | |
| 89 | test "comptime slice of slice preserves comptime var" { | 100 | test "comptime slice of slice preserves comptime var" { |
| 90 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 101 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 102 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 103 | |
| 91 | comptime { | 104 | comptime { |
| 92 | var buff: [10]u8 = undefined; | 105 | var buff: [10]u8 = undefined; |
| 93 | buff[0..][0..][0] = 1; | 106 | buff[0..][0..][0] = 1; |
| ... | @@ -97,6 +110,8 @@ test "comptime slice of slice preserves comptime var" { | ... | @@ -97,6 +110,8 @@ test "comptime slice of slice preserves comptime var" { |
| 97 | | 110 | |
| 98 | test "slice of type" { | 111 | test "slice of type" { |
| 99 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 112 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 113 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 114 | |
| 100 | comptime { | 115 | comptime { |
| 101 | var types_array = [_]type{ i32, f64, type }; | 116 | var types_array = [_]type{ i32, f64, type }; |
| 102 | for (types_array) |T, i| { | 117 | for (types_array) |T, i| { |
| ... | @@ -120,6 +135,9 @@ test "slice of type" { | ... | @@ -120,6 +135,9 @@ test "slice of type" { |
| 120 | | 135 | |
| 121 | test "generic malloc free" { | 136 | test "generic malloc free" { |
| 122 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 137 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 138 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 139 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 140 | |
| 123 | const a = memAlloc(u8, 10) catch unreachable; | 141 | const a = memAlloc(u8, 10) catch unreachable; |
| 124 | memFree(u8, a); | 142 | memFree(u8, a); |
| 125 | } | 143 | } |
| ... | @@ -133,6 +151,8 @@ fn memFree(comptime T: type, memory: []T) void { | ... | @@ -133,6 +151,8 @@ fn memFree(comptime T: type, memory: []T) void { |
| 133 | | 151 | |
| 134 | test "slice of hardcoded address to pointer" { | 152 | test "slice of hardcoded address to pointer" { |
| 135 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 153 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 154 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 155 | |
| 136 | const S = struct { | 156 | const S = struct { |
| 137 | fn doTheTest() !void { | 157 | fn doTheTest() !void { |
| 138 | const pointer = @intToPtr([*]u8, 0x04)[0..2]; | 158 | const pointer = @intToPtr([*]u8, 0x04)[0..2]; |
| ... | @@ -148,6 +168,8 @@ test "slice of hardcoded address to pointer" { | ... | @@ -148,6 +168,8 @@ test "slice of hardcoded address to pointer" { |
| 148 | | 168 | |
| 149 | test "comptime slice of pointer preserves comptime var" { | 169 | test "comptime slice of pointer preserves comptime var" { |
| 150 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 170 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 171 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 172 | |
| 151 | comptime { | 173 | comptime { |
| 152 | var buff: [10]u8 = undefined; | 174 | var buff: [10]u8 = undefined; |
| 153 | var a = @ptrCast([*]u8, &buff); | 175 | var a = @ptrCast([*]u8, &buff); |
| ... | @@ -158,6 +180,8 @@ test "comptime slice of pointer preserves comptime var" { | ... | @@ -158,6 +180,8 @@ test "comptime slice of pointer preserves comptime var" { |
| 158 | | 180 | |
| 159 | test "comptime pointer cast array and then slice" { | 181 | test "comptime pointer cast array and then slice" { |
| 160 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 182 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 183 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 184 | |
| 161 | const array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; | 185 | const array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 162 | | 186 | |
| 163 | const ptrA: [*]const u8 = @ptrCast([*]const u8, &array); | 187 | const ptrA: [*]const u8 = @ptrCast([*]const u8, &array); |
| ... | @@ -172,6 +196,9 @@ test "comptime pointer cast array and then slice" { | ... | @@ -172,6 +196,9 @@ test "comptime pointer cast array and then slice" { |
| 172 | | 196 | |
| 173 | test "slicing zero length array" { | 197 | test "slicing zero length array" { |
| 174 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 198 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 199 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 200 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 201 | |
| 175 | const s1 = ""[0..]; | 202 | const s1 = ""[0..]; |
| 176 | const s2 = ([_]u32{})[0..]; | 203 | const s2 = ([_]u32{})[0..]; |
| 177 | try expect(s1.len == 0); | 204 | try expect(s1.len == 0); |
| ... | @@ -185,6 +212,8 @@ const y = x[0x100..]; | ... | @@ -185,6 +212,8 @@ const y = x[0x100..]; |
| 185 | test "compile time slice of pointer to hard coded address" { | 212 | test "compile time slice of pointer to hard coded address" { |
| 186 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 213 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 187 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; | 214 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| | 215 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 216 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 188 | | 217 | |
| 189 | try expect(@ptrToInt(x) == 0x1000); | 218 | try expect(@ptrToInt(x) == 0x1000); |
| 190 | try expect(x.len == 0x500); | 219 | try expect(x.len == 0x500); |
| ... | @@ -194,6 +223,9 @@ test "compile time slice of pointer to hard coded address" { | ... | @@ -194,6 +223,9 @@ test "compile time slice of pointer to hard coded address" { |
| 194 | } | 223 | } |
| 195 | | 224 | |
| 196 | test "slice string literal has correct type" { | 225 | test "slice string literal has correct type" { |
| | 226 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 227 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 228 | |
| 197 | comptime { | 229 | comptime { |
| 198 | try expect(@TypeOf("aoeu"[0..]) == *const [4:0]u8); | 230 | try expect(@TypeOf("aoeu"[0..]) == *const [4:0]u8); |
| 199 | const array = [_]i32{ 1, 2, 3, 4 }; | 231 | const array = [_]i32{ 1, 2, 3, 4 }; |
| ... | @@ -207,6 +239,7 @@ test "slice string literal has correct type" { | ... | @@ -207,6 +239,7 @@ test "slice string literal has correct type" { |
| 207 | | 239 | |
| 208 | test "result location zero sized array inside struct field implicit cast to slice" { | 240 | test "result location zero sized array inside struct field implicit cast to slice" { |
| 209 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 241 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| | 242 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 210 | | 243 | |
| 211 | const E = struct { | 244 | const E = struct { |
| 212 | entries: []u32, | 245 | entries: []u32, |
| ... | @@ -216,6 +249,9 @@ test "result location zero sized array inside struct field implicit cast to slic | ... | @@ -216,6 +249,9 @@ test "result location zero sized array inside struct field implicit cast to slic |
| 216 | } | 249 | } |
| 217 | | 250 | |
| 218 | test "runtime safety lets us slice from len..len" { | 251 | test "runtime safety lets us slice from len..len" { |
| | 252 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 253 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 254 | |
| 219 | var an_array = [_]u8{ 1, 2, 3 }; | 255 | var an_array = [_]u8{ 1, 2, 3 }; |
| 220 | try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), "")); | 256 | try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), "")); |
| 221 | } | 257 | } |
| ... | @@ -225,6 +261,9 @@ fn sliceFromLenToLen(a_slice: []u8, start: usize, end: usize) []u8 { | ... | @@ -225,6 +261,9 @@ fn sliceFromLenToLen(a_slice: []u8, start: usize, end: usize) []u8 { |
| 225 | } | 261 | } |
| 226 | | 262 | |
| 227 | test "C pointer" { | 263 | test "C pointer" { |
| | 264 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 265 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 266 | |
| 228 | var buf: [*c]const u8 = "kjdhfkjdhfdkjhfkfjhdfkjdhfkdjhfdkjhf"; | 267 | var buf: [*c]const u8 = "kjdhfkjdhfdkjhfkfjhdfkjdhfkdjhfdkjhf"; |
| 229 | var len: u32 = 10; | 268 | var len: u32 = 10; |
| 230 | var slice = buf[0..len]; | 269 | var slice = buf[0..len]; |
| ... | @@ -232,6 +271,9 @@ test "C pointer" { | ... | @@ -232,6 +271,9 @@ test "C pointer" { |
| 232 | } | 271 | } |
| 233 | | 272 | |
| 234 | test "C pointer slice access" { | 273 | test "C pointer slice access" { |
| | 274 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 275 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 276 | |
| 235 | var buf: [10]u32 = [1]u32{42} ** 10; | 277 | var buf: [10]u32 = [1]u32{42} ** 10; |
| 236 | const c_ptr = @ptrCast([*c]const u32, &buf); | 278 | const c_ptr = @ptrCast([*c]const u32, &buf); |
| 237 | | 279 | |
| ... | @@ -245,6 +287,8 @@ test "C pointer slice access" { | ... | @@ -245,6 +287,8 @@ test "C pointer slice access" { |
| 245 | } | 287 | } |
| 246 | | 288 | |
| 247 | test "comptime slices are disambiguated" { | 289 | test "comptime slices are disambiguated" { |
| | 290 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 291 | |
| 248 | try expect(sliceSum(&[_]u8{ 1, 2 }) == 3); | 292 | try expect(sliceSum(&[_]u8{ 1, 2 }) == 3); |
| 249 | try expect(sliceSum(&[_]u8{ 3, 4 }) == 7); | 293 | try expect(sliceSum(&[_]u8{ 3, 4 }) == 7); |
| 250 | } | 294 | } |
| ... | @@ -258,6 +302,9 @@ fn sliceSum(comptime q: []const u8) i32 { | ... | @@ -258,6 +302,9 @@ fn sliceSum(comptime q: []const u8) i32 { |
| 258 | } | 302 | } |
| 259 | | 303 | |
| 260 | test "slice type with custom alignment" { | 304 | test "slice type with custom alignment" { |
| | 305 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 306 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 307 | |
| 261 | const LazilyResolvedType = struct { | 308 | const LazilyResolvedType = struct { |
| 262 | anything: i32, | 309 | anything: i32, |
| 263 | }; | 310 | }; |
| ... | @@ -269,6 +316,8 @@ test "slice type with custom alignment" { | ... | @@ -269,6 +316,8 @@ test "slice type with custom alignment" { |
| 269 | } | 316 | } |
| 270 | | 317 | |
| 271 | test "obtaining a null terminated slice" { | 318 | test "obtaining a null terminated slice" { |
| | 319 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 320 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 272 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | 321 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 273 | | 322 | |
| 274 | // here we have a normal array | 323 | // here we have a normal array |
| ... | @@ -294,6 +343,7 @@ test "obtaining a null terminated slice" { | ... | @@ -294,6 +343,7 @@ test "obtaining a null terminated slice" { |
| 294 | | 343 | |
| 295 | test "empty array to slice" { | 344 | test "empty array to slice" { |
| 296 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 345 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 346 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 297 | | 347 | |
| 298 | const S = struct { | 348 | const S = struct { |
| 299 | fn doTheTest() !void { | 349 | fn doTheTest() !void { |
| ... | @@ -312,6 +362,9 @@ test "empty array to slice" { | ... | @@ -312,6 +362,9 @@ test "empty array to slice" { |
| 312 | } | 362 | } |
| 313 | | 363 | |
| 314 | test "@ptrCast slice to pointer" { | 364 | test "@ptrCast slice to pointer" { |
| | 365 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 366 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 367 | |
| 315 | const S = struct { | 368 | const S = struct { |
| 316 | fn doTheTest() !void { | 369 | fn doTheTest() !void { |
| 317 | var array align(@alignOf(u16)) = [5]u8{ 0xff, 0xff, 0xff, 0xff, 0xff }; | 370 | var array align(@alignOf(u16)) = [5]u8{ 0xff, 0xff, 0xff, 0xff, 0xff }; |
| ... | @@ -327,6 +380,7 @@ test "@ptrCast slice to pointer" { | ... | @@ -327,6 +380,7 @@ test "@ptrCast slice to pointer" { |
| 327 | | 380 | |
| 328 | test "slice syntax resulting in pointer-to-array" { | 381 | test "slice syntax resulting in pointer-to-array" { |
| 329 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 382 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 383 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 330 | | 384 | |
| 331 | const S = struct { | 385 | const S = struct { |
| 332 | fn doTheTest() !void { | 386 | fn doTheTest() !void { |
| ... | @@ -475,6 +529,7 @@ test "slice syntax resulting in pointer-to-array" { | ... | @@ -475,6 +529,7 @@ test "slice syntax resulting in pointer-to-array" { |
| 475 | | 529 | |
| 476 | test "type coercion of pointer to anon struct literal to pointer to slice" { | 530 | test "type coercion of pointer to anon struct literal to pointer to slice" { |
| 477 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 531 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 532 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 478 | | 533 | |
| 479 | const S = struct { | 534 | const S = struct { |
| 480 | const U = union { | 535 | const U = union { |
| ... | @@ -508,6 +563,7 @@ test "type coercion of pointer to anon struct literal to pointer to slice" { | ... | @@ -508,6 +563,7 @@ test "type coercion of pointer to anon struct literal to pointer to slice" { |
| 508 | | 563 | |
| 509 | test "array concat of slices gives slice" { | 564 | test "array concat of slices gives slice" { |
| 510 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 565 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 566 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 511 | | 567 | |
| 512 | comptime { | 568 | comptime { |
| 513 | var a: []const u8 = "aoeu"; | 569 | var a: []const u8 = "aoeu"; |
| ... | @@ -519,6 +575,7 @@ test "array concat of slices gives slice" { | ... | @@ -519,6 +575,7 @@ test "array concat of slices gives slice" { |
| 519 | | 575 | |
| 520 | test "slice bounds in comptime concatenation" { | 576 | test "slice bounds in comptime concatenation" { |
| 521 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 577 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 578 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 522 | | 579 | |
| 523 | const bs = comptime blk: { | 580 | const bs = comptime blk: { |
| 524 | const b = "........1........"; | 581 | const b = "........1........"; |
| ... | @@ -535,6 +592,7 @@ test "slice bounds in comptime concatenation" { | ... | @@ -535,6 +592,7 @@ test "slice bounds in comptime concatenation" { |
| 535 | | 592 | |
| 536 | test "slice sentinel access at comptime" { | 593 | test "slice sentinel access at comptime" { |
| 537 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | 594 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| | 595 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 538 | | 596 | |
| 539 | { | 597 | { |
| 540 | const str0 = &[_:0]u8{ '1', '2', '3' }; | 598 | const str0 = &[_:0]u8{ '1', '2', '3' }; |