| author | |
| committer | |
| log | 588b88b98753f02061e562a9c15c2396bcd95dee |
| tree | 2d7a80c842558608392926cf1ddd244fcdf2cd6c |
| parent | e35414bf5c356798f201be85303101f59220326c |
| signature |
Singular tests (such as in the bug ones) are moved to top level with exclusions for non-passing backends.
The big behavior tests such as array_llvm and slice are moved to the inner scope with the C backend disabled.
They all pass for the wasm backend now7 files changed, 52 insertions(+), 7 deletions(-)
src/arch/wasm/CodeGen.zig+1-1| ... | @@ -1198,7 +1198,7 @@ pub const DeclGen = struct { | ... | @@ -1198,7 +1198,7 @@ pub const DeclGen = struct { |
| 1198 | const elem_ptr = val.castTag(.elem_ptr).?.data; | 1198 | const elem_ptr = val.castTag(.elem_ptr).?.data; |
| 1199 | const elem_size = ty.childType().abiSize(self.target()); | 1199 | const elem_size = ty.childType().abiSize(self.target()); |
| 1200 | const offset = elem_ptr.index * elem_size; | 1200 | const offset = elem_ptr.index * elem_size; |
| 1201 | return self.lowerParentPtr(elem_ptr.array_ptr, offset); | 1201 | return self.lowerParentPtr(elem_ptr.array_ptr, @intCast(usize, offset)); |
| 1202 | }, | 1202 | }, |
| 1203 | .int_u64 => return self.genTypedValue(Type.usize, val), | 1203 | .int_u64 => return self.genTypedValue(Type.usize, val), |
| 1204 | else => return self.fail("TODO: Implement zig decl gen for pointer type value: '{s}'", .{@tagName(val.tag())}), | 1204 | else => return self.fail("TODO: Implement zig decl gen for pointer type value: '{s}'", .{@tagName(val.tag())}), |
test/behavior.zig+6-6| ... | @@ -10,6 +10,7 @@ test { | ... | @@ -10,6 +10,7 @@ test { |
| 10 | _ = @import("behavior/bugs/655.zig"); | 10 | _ = @import("behavior/bugs/655.zig"); |
| 11 | _ = @import("behavior/bugs/656.zig"); | 11 | _ = @import("behavior/bugs/656.zig"); |
| 12 | _ = @import("behavior/bugs/679.zig"); | 12 | _ = @import("behavior/bugs/679.zig"); |
| 13 | _ = @import("behavior/bugs/1025.zig"); | ||
| 13 | _ = @import("behavior/bugs/1111.zig"); | 14 | _ = @import("behavior/bugs/1111.zig"); |
| 14 | _ = @import("behavior/bugs/1277.zig"); | 15 | _ = @import("behavior/bugs/1277.zig"); |
| 15 | _ = @import("behavior/bugs/1310.zig"); | 16 | _ = @import("behavior/bugs/1310.zig"); |
| ... | @@ -17,6 +18,8 @@ test { | ... | @@ -17,6 +18,8 @@ test { |
| 17 | _ = @import("behavior/bugs/1486.zig"); | 18 | _ = @import("behavior/bugs/1486.zig"); |
| 18 | _ = @import("behavior/bugs/1500.zig"); | 19 | _ = @import("behavior/bugs/1500.zig"); |
| 19 | _ = @import("behavior/bugs/1735.zig"); | 20 | _ = @import("behavior/bugs/1735.zig"); |
| 21 | _ = @import("behavior/bugs/1741.zig"); | ||
| 22 | _ = @import("behavior/bugs/1914.zig"); | ||
| 20 | _ = @import("behavior/bugs/2006.zig"); | 23 | _ = @import("behavior/bugs/2006.zig"); |
| 21 | _ = @import("behavior/bugs/2346.zig"); | 24 | _ = @import("behavior/bugs/2346.zig"); |
| 22 | _ = @import("behavior/bugs/3112.zig"); | 25 | _ = @import("behavior/bugs/3112.zig"); |
| ... | @@ -38,7 +41,8 @@ test { | ... | @@ -38,7 +41,8 @@ test { |
| 38 | _ = @import("behavior/struct.zig"); | 41 | _ = @import("behavior/struct.zig"); |
| 39 | 42 | ||
| 40 | if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) { | 43 | if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) { |
| 41 | // Tests that pass for stage1, llvm backend, C backend, wasm backend. | 44 | // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend. |
| 45 | _ = @import("behavior/array_llvm.zig"); | ||
| 42 | _ = @import("behavior/basic.zig"); | 46 | _ = @import("behavior/basic.zig"); |
| 43 | _ = @import("behavior/bitcast.zig"); | 47 | _ = @import("behavior/bitcast.zig"); |
| 44 | _ = @import("behavior/bugs/624.zig"); | 48 | _ = @import("behavior/bugs/624.zig"); |
| ... | @@ -69,6 +73,7 @@ test { | ... | @@ -69,6 +73,7 @@ test { |
| 69 | _ = @import("behavior/pointers.zig"); | 73 | _ = @import("behavior/pointers.zig"); |
| 70 | _ = @import("behavior/ptrcast.zig"); | 74 | _ = @import("behavior/ptrcast.zig"); |
| 71 | _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig"); | 75 | _ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig"); |
| 76 | _ = @import("behavior/slice.zig"); | ||
| 72 | _ = @import("behavior/src.zig"); | 77 | _ = @import("behavior/src.zig"); |
| 73 | _ = @import("behavior/this.zig"); | 78 | _ = @import("behavior/this.zig"); |
| 74 | _ = @import("behavior/try.zig"); | 79 | _ = @import("behavior/try.zig"); |
| ... | @@ -88,11 +93,7 @@ test { | ... | @@ -88,11 +93,7 @@ test { |
| 88 | 93 | ||
| 89 | if (builtin.zig_backend != .stage2_c) { | 94 | if (builtin.zig_backend != .stage2_c) { |
| 90 | // Tests that pass for stage1 and the llvm backend. | 95 | // Tests that pass for stage1 and the llvm backend. |
| 91 | _ = @import("behavior/array_llvm.zig"); | ||
| 92 | _ = @import("behavior/atomics.zig"); | 96 | _ = @import("behavior/atomics.zig"); |
| 93 | _ = @import("behavior/bugs/1025.zig"); | ||
| 94 | _ = @import("behavior/bugs/1741.zig"); | ||
| 95 | _ = @import("behavior/bugs/1914.zig"); | ||
| 96 | _ = @import("behavior/bugs/2578.zig"); | 97 | _ = @import("behavior/bugs/2578.zig"); |
| 97 | _ = @import("behavior/bugs/3007.zig"); | 98 | _ = @import("behavior/bugs/3007.zig"); |
| 98 | _ = @import("behavior/bugs/9584.zig"); | 99 | _ = @import("behavior/bugs/9584.zig"); |
| ... | @@ -108,7 +109,6 @@ test { | ... | @@ -108,7 +109,6 @@ test { |
| 108 | _ = @import("behavior/popcount.zig"); | 109 | _ = @import("behavior/popcount.zig"); |
| 109 | _ = @import("behavior/saturating_arithmetic.zig"); | 110 | _ = @import("behavior/saturating_arithmetic.zig"); |
| 110 | _ = @import("behavior/sizeof_and_typeof.zig"); | 111 | _ = @import("behavior/sizeof_and_typeof.zig"); |
| 111 | _ = @import("behavior/slice.zig"); | ||
| 112 | _ = @import("behavior/struct_llvm.zig"); | 112 | _ = @import("behavior/struct_llvm.zig"); |
| 113 | _ = @import("behavior/switch.zig"); | 113 | _ = @import("behavior/switch.zig"); |
| 114 | _ = @import("behavior/widening.zig"); | 114 | _ = @import("behavior/widening.zig"); |
test/behavior/array_llvm.zig+18| ... | @@ -7,6 +7,7 @@ var s_array: [8]Sub = undefined; | ... | @@ -7,6 +7,7 @@ var s_array: [8]Sub = undefined; |
| 7 | const Sub = struct { b: u8 }; | 7 | const Sub = struct { b: u8 }; |
| 8 | const Str = struct { a: []Sub }; | 8 | const Str = struct { a: []Sub }; |
| 9 | test "set global var array via slice embedded in struct" { | 9 | test "set global var array via slice embedded in struct" { |
| 10 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 10 | var s = Str{ .a = s_array[0..] }; | 11 | var s = Str{ .a = s_array[0..] }; |
| 11 | 12 | ||
| 12 | s.a[0].b = 1; | 13 | s.a[0].b = 1; |
| ... | @@ -19,6 +20,7 @@ test "set global var array via slice embedded in struct" { | ... | @@ -19,6 +20,7 @@ test "set global var array via slice embedded in struct" { |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | test "read/write through global variable array of struct fields initialized via array mult" { | 22 | test "read/write through global variable array of struct fields initialized via array mult" { |
| 23 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 22 | const S = struct { | 24 | const S = struct { |
| 23 | fn doTheTest() !void { | 25 | fn doTheTest() !void { |
| 24 | try expect(storage[0].term == 1); | 26 | try expect(storage[0].term == 1); |
| ... | @@ -36,6 +38,7 @@ test "read/write through global variable array of struct fields initialized via | ... | @@ -36,6 +38,7 @@ test "read/write through global variable array of struct fields initialized via |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | test "implicit cast single-item pointer" { | 40 | test "implicit cast single-item pointer" { |
| 41 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 39 | try testImplicitCastSingleItemPtr(); | 42 | try testImplicitCastSingleItemPtr(); |
| 40 | comptime try testImplicitCastSingleItemPtr(); | 43 | comptime try testImplicitCastSingleItemPtr(); |
| 41 | } | 44 | } |
| ... | @@ -52,6 +55,7 @@ fn testArrayByValAtComptime(b: [2]u8) u8 { | ... | @@ -52,6 +55,7 @@ fn testArrayByValAtComptime(b: [2]u8) u8 { |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | test "comptime evaluating function that takes array by value" { | 57 | test "comptime evaluating function that takes array by value" { |
| 58 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 55 | const arr = [_]u8{ 1, 2 }; | 59 | const arr = [_]u8{ 1, 2 }; |
| 56 | const x = comptime testArrayByValAtComptime(arr); | 60 | const x = comptime testArrayByValAtComptime(arr); |
| 57 | const y = comptime testArrayByValAtComptime(arr); | 61 | const y = comptime testArrayByValAtComptime(arr); |
| ... | @@ -60,12 +64,14 @@ test "comptime evaluating function that takes array by value" { | ... | @@ -60,12 +64,14 @@ test "comptime evaluating function that takes array by value" { |
| 60 | } | 64 | } |
| 61 | 65 | ||
| 62 | test "runtime initialize array elem and then implicit cast to slice" { | 66 | test "runtime initialize array elem and then implicit cast to slice" { |
| 67 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 63 | var two: i32 = 2; | 68 | var two: i32 = 2; |
| 64 | const x: []const i32 = &[_]i32{two}; | 69 | const x: []const i32 = &[_]i32{two}; |
| 65 | try expect(x[0] == 2); | 70 | try expect(x[0] == 2); |
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | test "array literal as argument to function" { | 73 | test "array literal as argument to function" { |
| 74 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 69 | const S = struct { | 75 | const S = struct { |
| 70 | fn entry(two: i32) !void { | 76 | fn entry(two: i32) !void { |
| 71 | try foo(&[_]i32{ 1, 2, 3 }); | 77 | try foo(&[_]i32{ 1, 2, 3 }); |
| ... | @@ -90,6 +96,7 @@ test "array literal as argument to function" { | ... | @@ -90,6 +96,7 @@ test "array literal as argument to function" { |
| 90 | } | 96 | } |
| 91 | 97 | ||
| 92 | test "double nested array to const slice cast in array literal" { | 98 | test "double nested array to const slice cast in array literal" { |
| 99 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 93 | const S = struct { | 100 | const S = struct { |
| 94 | fn entry(two: i32) !void { | 101 | fn entry(two: i32) !void { |
| 95 | const cases = [_][]const []const i32{ | 102 | const cases = [_][]const []const i32{ |
| ... | @@ -147,6 +154,7 @@ test "double nested array to const slice cast in array literal" { | ... | @@ -147,6 +154,7 @@ test "double nested array to const slice cast in array literal" { |
| 147 | } | 154 | } |
| 148 | 155 | ||
| 149 | test "anonymous literal in array" { | 156 | test "anonymous literal in array" { |
| 157 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 150 | const S = struct { | 158 | const S = struct { |
| 151 | const Foo = struct { | 159 | const Foo = struct { |
| 152 | a: usize = 2, | 160 | a: usize = 2, |
| ... | @@ -168,6 +176,7 @@ test "anonymous literal in array" { | ... | @@ -168,6 +176,7 @@ test "anonymous literal in array" { |
| 168 | } | 176 | } |
| 169 | 177 | ||
| 170 | test "access the null element of a null terminated array" { | 178 | test "access the null element of a null terminated array" { |
| 179 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 171 | const S = struct { | 180 | const S = struct { |
| 172 | fn doTheTest() !void { | 181 | fn doTheTest() !void { |
| 173 | var array: [4:0]u8 = .{ 'a', 'o', 'e', 'u' }; | 182 | var array: [4:0]u8 = .{ 'a', 'o', 'e', 'u' }; |
| ... | @@ -181,6 +190,7 @@ test "access the null element of a null terminated array" { | ... | @@ -181,6 +190,7 @@ test "access the null element of a null terminated array" { |
| 181 | } | 190 | } |
| 182 | 191 | ||
| 183 | test "type deduction for array subscript expression" { | 192 | test "type deduction for array subscript expression" { |
| 193 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 184 | const S = struct { | 194 | const S = struct { |
| 185 | fn doTheTest() !void { | 195 | fn doTheTest() !void { |
| 186 | var array = [_]u8{ 0x55, 0xAA }; | 196 | var array = [_]u8{ 0x55, 0xAA }; |
| ... | @@ -196,6 +206,8 @@ test "type deduction for array subscript expression" { | ... | @@ -196,6 +206,8 @@ test "type deduction for array subscript expression" { |
| 196 | 206 | ||
| 197 | test "sentinel element count towards the ABI size calculation" { | 207 | test "sentinel element count towards the ABI size calculation" { |
| 198 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO | 208 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO |
| 209 | if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 210 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 199 | 211 | ||
| 200 | const S = struct { | 212 | const S = struct { |
| 201 | fn doTheTest() !void { | 213 | fn doTheTest() !void { |
| ... | @@ -218,6 +230,8 @@ test "sentinel element count towards the ABI size calculation" { | ... | @@ -218,6 +230,8 @@ test "sentinel element count towards the ABI size calculation" { |
| 218 | 230 | ||
| 219 | test "zero-sized array with recursive type definition" { | 231 | test "zero-sized array with recursive type definition" { |
| 220 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO | 232 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO |
| 233 | if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 234 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 221 | 235 | ||
| 222 | const U = struct { | 236 | const U = struct { |
| 223 | fn foo(comptime T: type, comptime n: usize) type { | 237 | fn foo(comptime T: type, comptime n: usize) type { |
| ... | @@ -237,6 +251,7 @@ test "zero-sized array with recursive type definition" { | ... | @@ -237,6 +251,7 @@ test "zero-sized array with recursive type definition" { |
| 237 | } | 251 | } |
| 238 | 252 | ||
| 239 | test "type coercion of anon struct literal to array" { | 253 | test "type coercion of anon struct literal to array" { |
| 254 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 240 | const S = struct { | 255 | const S = struct { |
| 241 | const U = union { | 256 | const U = union { |
| 242 | a: u32, | 257 | a: u32, |
| ... | @@ -253,6 +268,7 @@ test "type coercion of anon struct literal to array" { | ... | @@ -253,6 +268,7 @@ test "type coercion of anon struct literal to array" { |
| 253 | try expect(arr1[2] == 54); | 268 | try expect(arr1[2] == 54); |
| 254 | 269 | ||
| 255 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO | 270 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO |
| 271 | if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 256 | 272 | ||
| 257 | var x2: U = .{ .a = 42 }; | 273 | var x2: U = .{ .a = 42 }; |
| 258 | const t2 = .{ x2, .{ .b = true }, .{ .c = "hello" } }; | 274 | const t2 = .{ x2, .{ .b = true }, .{ .c = "hello" } }; |
| ... | @@ -268,6 +284,8 @@ test "type coercion of anon struct literal to array" { | ... | @@ -268,6 +284,8 @@ test "type coercion of anon struct literal to array" { |
| 268 | 284 | ||
| 269 | test "type coercion of pointer to anon struct literal to pointer to array" { | 285 | test "type coercion of pointer to anon struct literal to pointer to array" { |
| 270 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO | 286 | if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO |
| 287 | if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 288 | if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 271 | 289 | ||
| 272 | const S = struct { | 290 | const S = struct { |
| 273 | const U = union { | 291 | const U = union { |
test/behavior/bugs/1025.zig+4| ... | @@ -1,3 +1,5 @@ | ... | @@ -1,3 +1,5 @@ |
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 1 | const A = struct { | 3 | const A = struct { |
| 2 | B: type, | 4 | B: type, |
| 3 | }; | 5 | }; |
| ... | @@ -7,6 +9,8 @@ fn getA() A { | ... | @@ -7,6 +9,8 @@ fn getA() A { |
| 7 | } | 9 | } |
| 8 | 10 | ||
| 9 | test "bug 1025" { | 11 | test "bug 1025" { |
| 12 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 13 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 10 | const a = getA(); | 14 | const a = getA(); |
| 11 | try @import("std").testing.expect(a.B == u8); | 15 | try @import("std").testing.expect(a.B == u8); |
| 12 | } | 16 | } |
test/behavior/bugs/1741.zig+3| ... | @@ -1,6 +1,9 @@ | ... | @@ -1,6 +1,9 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | 3 | ||
| 3 | test "fixed" { | 4 | test "fixed" { |
| 5 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 6 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 4 | const x: f32 align(128) = 12.34; | 7 | const x: f32 align(128) = 12.34; |
| 5 | try std.testing.expect(@ptrToInt(&x) % 128 == 0); | 8 | try std.testing.expect(@ptrToInt(&x) % 128 == 0); |
| 6 | } | 9 | } |
test/behavior/bugs/1914.zig+7| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | ||
| 2 | 3 | ||
| 3 | const A = struct { | 4 | const A = struct { |
| 4 | b_list_pointer: *const []B, | 5 | b_list_pointer: *const []B, |
| ... | @@ -11,6 +12,9 @@ const b_list: []B = &[_]B{}; | ... | @@ -11,6 +12,9 @@ const b_list: []B = &[_]B{}; |
| 11 | const a = A{ .b_list_pointer = &b_list }; | 12 | const a = A{ .b_list_pointer = &b_list }; |
| 12 | 13 | ||
| 13 | test "segfault bug" { | 14 | test "segfault bug" { |
| 15 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 16 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 17 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 14 | const assert = std.debug.assert; | 18 | const assert = std.debug.assert; |
| 15 | const obj = B{ .a_pointer = &a }; | 19 | const obj = B{ .a_pointer = &a }; |
| 16 | assert(obj.a_pointer == &a); // this makes zig crash | 20 | assert(obj.a_pointer == &a); // this makes zig crash |
| ... | @@ -27,5 +31,8 @@ pub const B2 = struct { | ... | @@ -27,5 +31,8 @@ pub const B2 = struct { |
| 27 | var b_value = B2{ .pointer_array = &[_]*A2{} }; | 31 | var b_value = B2{ .pointer_array = &[_]*A2{} }; |
| 28 | 32 | ||
| 29 | test "basic stuff" { | 33 | test "basic stuff" { |
| 34 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | ||
| 35 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | ||
| 36 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 30 | std.debug.assert(&b_value == &b_value); | 37 | std.debug.assert(&b_value == &b_value); |
| 31 | } | 38 | } |
test/behavior/slice.zig+13| ... | @@ -27,6 +27,7 @@ comptime { | ... | @@ -27,6 +27,7 @@ comptime { |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | test "slicing" { | 29 | test "slicing" { |
| 30 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 30 | var array: [20]i32 = undefined; | 31 | var array: [20]i32 = undefined; |
| 31 | 32 | ||
| 32 | array[5] = 1234; | 33 | array[5] = 1234; |
| ... | @@ -43,6 +44,7 @@ test "slicing" { | ... | @@ -43,6 +44,7 @@ test "slicing" { |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | test "const slice" { | 46 | test "const slice" { |
| 47 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 46 | comptime { | 48 | comptime { |
| 47 | const a = "1234567890"; | 49 | const a = "1234567890"; |
| 48 | try expect(a.len == 10); | 50 | try expect(a.len == 10); |
| ... | @@ -53,6 +55,7 @@ test "const slice" { | ... | @@ -53,6 +55,7 @@ test "const slice" { |
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | test "comptime slice of undefined pointer of length 0" { | 57 | test "comptime slice of undefined pointer of length 0" { |
| 58 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 56 | const slice1 = @as([*]i32, undefined)[0..0]; | 59 | const slice1 = @as([*]i32, undefined)[0..0]; |
| 57 | try expect(slice1.len == 0); | 60 | try expect(slice1.len == 0); |
| 58 | const slice2 = @as([*]i32, undefined)[100..100]; | 61 | const slice2 = @as([*]i32, undefined)[100..100]; |
| ... | @@ -60,6 +63,7 @@ test "comptime slice of undefined pointer of length 0" { | ... | @@ -60,6 +63,7 @@ test "comptime slice of undefined pointer of length 0" { |
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | test "implicitly cast array of size 0 to slice" { | 65 | test "implicitly cast array of size 0 to slice" { |
| 66 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 63 | var msg = [_]u8{}; | 67 | var msg = [_]u8{}; |
| 64 | try assertLenIsZero(&msg); | 68 | try assertLenIsZero(&msg); |
| 65 | } | 69 | } |
| ... | @@ -69,6 +73,7 @@ fn assertLenIsZero(msg: []const u8) !void { | ... | @@ -69,6 +73,7 @@ fn assertLenIsZero(msg: []const u8) !void { |
| 69 | } | 73 | } |
| 70 | 74 | ||
| 71 | test "access len index of sentinel-terminated slice" { | 75 | test "access len index of sentinel-terminated slice" { |
| 76 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 72 | const S = struct { | 77 | const S = struct { |
| 73 | fn doTheTest() !void { | 78 | fn doTheTest() !void { |
| 74 | var slice: [:0]const u8 = "hello"; | 79 | var slice: [:0]const u8 = "hello"; |
| ... | @@ -82,6 +87,7 @@ test "access len index of sentinel-terminated slice" { | ... | @@ -82,6 +87,7 @@ test "access len index of sentinel-terminated slice" { |
| 82 | } | 87 | } |
| 83 | 88 | ||
| 84 | test "comptime slice of slice preserves comptime var" { | 89 | test "comptime slice of slice preserves comptime var" { |
| 90 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 85 | comptime { | 91 | comptime { |
| 86 | var buff: [10]u8 = undefined; | 92 | var buff: [10]u8 = undefined; |
| 87 | buff[0..][0..][0] = 1; | 93 | buff[0..][0..][0] = 1; |
| ... | @@ -90,6 +96,7 @@ test "comptime slice of slice preserves comptime var" { | ... | @@ -90,6 +96,7 @@ test "comptime slice of slice preserves comptime var" { |
| 90 | } | 96 | } |
| 91 | 97 | ||
| 92 | test "slice of type" { | 98 | test "slice of type" { |
| 99 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 93 | comptime { | 100 | comptime { |
| 94 | var types_array = [_]type{ i32, f64, type }; | 101 | var types_array = [_]type{ i32, f64, type }; |
| 95 | for (types_array) |T, i| { | 102 | for (types_array) |T, i| { |
| ... | @@ -112,6 +119,7 @@ test "slice of type" { | ... | @@ -112,6 +119,7 @@ test "slice of type" { |
| 112 | } | 119 | } |
| 113 | 120 | ||
| 114 | test "generic malloc free" { | 121 | test "generic malloc free" { |
| 122 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 115 | const a = memAlloc(u8, 10) catch unreachable; | 123 | const a = memAlloc(u8, 10) catch unreachable; |
| 116 | memFree(u8, a); | 124 | memFree(u8, a); |
| 117 | } | 125 | } |
| ... | @@ -124,6 +132,7 @@ fn memFree(comptime T: type, memory: []T) void { | ... | @@ -124,6 +132,7 @@ fn memFree(comptime T: type, memory: []T) void { |
| 124 | } | 132 | } |
| 125 | 133 | ||
| 126 | test "slice of hardcoded address to pointer" { | 134 | test "slice of hardcoded address to pointer" { |
| 135 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 127 | const S = struct { | 136 | const S = struct { |
| 128 | fn doTheTest() !void { | 137 | fn doTheTest() !void { |
| 129 | const pointer = @intToPtr([*]u8, 0x04)[0..2]; | 138 | const pointer = @intToPtr([*]u8, 0x04)[0..2]; |
| ... | @@ -138,6 +147,7 @@ test "slice of hardcoded address to pointer" { | ... | @@ -138,6 +147,7 @@ test "slice of hardcoded address to pointer" { |
| 138 | } | 147 | } |
| 139 | 148 | ||
| 140 | test "comptime slice of pointer preserves comptime var" { | 149 | test "comptime slice of pointer preserves comptime var" { |
| 150 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 141 | comptime { | 151 | comptime { |
| 142 | var buff: [10]u8 = undefined; | 152 | var buff: [10]u8 = undefined; |
| 143 | var a = @ptrCast([*]u8, &buff); | 153 | var a = @ptrCast([*]u8, &buff); |
| ... | @@ -147,6 +157,7 @@ test "comptime slice of pointer preserves comptime var" { | ... | @@ -147,6 +157,7 @@ test "comptime slice of pointer preserves comptime var" { |
| 147 | } | 157 | } |
| 148 | 158 | ||
| 149 | test "comptime pointer cast array and then slice" { | 159 | test "comptime pointer cast array and then slice" { |
| 160 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 150 | const array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; | 161 | const array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 151 | 162 | ||
| 152 | const ptrA: [*]const u8 = @ptrCast([*]const u8, &array); | 163 | const ptrA: [*]const u8 = @ptrCast([*]const u8, &array); |
| ... | @@ -160,6 +171,7 @@ test "comptime pointer cast array and then slice" { | ... | @@ -160,6 +171,7 @@ test "comptime pointer cast array and then slice" { |
| 160 | } | 171 | } |
| 161 | 172 | ||
| 162 | test "slicing zero length array" { | 173 | test "slicing zero length array" { |
| 174 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 163 | const s1 = ""[0..]; | 175 | const s1 = ""[0..]; |
| 164 | const s2 = ([_]u32{})[0..]; | 176 | const s2 = ([_]u32{})[0..]; |
| 165 | try expect(s1.len == 0); | 177 | try expect(s1.len == 0); |
| ... | @@ -171,6 +183,7 @@ test "slicing zero length array" { | ... | @@ -171,6 +183,7 @@ test "slicing zero length array" { |
| 171 | const x = @intToPtr([*]i32, 0x1000)[0..0x500]; | 183 | const x = @intToPtr([*]i32, 0x1000)[0..0x500]; |
| 172 | const y = x[0x100..]; | 184 | const y = x[0x100..]; |
| 173 | test "compile time slice of pointer to hard coded address" { | 185 | test "compile time slice of pointer to hard coded address" { |
| 186 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO | ||
| 174 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; | 187 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 175 | 188 | ||
| 176 | try expect(@ptrToInt(x) == 0x1000); | 189 | try expect(@ptrToInt(x) == 0x1000); |