authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-02-03 22:25:46+01:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-02-03 22:31:29+01:00
log588b88b98753f02061e562a9c15c2396bcd95dee
tree2d7a80c842558608392926cf1ddd244fcdf2cd6c
parente35414bf5c356798f201be85303101f59220326c
signaturelock-open Commit is signed but in an unrecognized format.

Move passing behavior tests

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 now

7 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");
3942
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 {
8893
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;
7const Sub = struct { b: u8 };7const Sub = struct { b: u8 };
8const Str = struct { a: []Sub };8const Str = struct { a: []Sub };
9test "set global var array via slice embedded in struct" {9test "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..] };
1112
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}
2021
21test "read/write through global variable array of struct fields initialized via array mult" {22test "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}
3739
38test "implicit cast single-item pointer" {40test "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}
5356
54test "comptime evaluating function that takes array by value" {57test "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}
6165
62test "runtime initialize array elem and then implicit cast to slice" {66test "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}
6772
68test "array literal as argument to function" {73test "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}
9197
92test "double nested array to const slice cast in array literal" {98test "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}
148155
149test "anonymous literal in array" {156test "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}
169177
170test "access the null element of a null terminated array" {178test "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}
182191
183test "type deduction for array subscript expression" {192test "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" {
196206
197test "sentinel element count towards the ABI size calculation" {207test "sentinel element count towards the ABI size calculation" {
198 if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO208 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
199211
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" {
218230
219test "zero-sized array with recursive type definition" {231test "zero-sized array with recursive type definition" {
220 if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO232 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
221235
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}
238252
239test "type coercion of anon struct literal to array" {253test "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);
254269
255 if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO270 if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO
271 if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
256272
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" {
268284
269test "type coercion of pointer to anon struct literal to pointer to array" {285test "type coercion of pointer to anon struct literal to pointer to array" {
270 if (@import("builtin").zig_backend == .stage2_llvm) return error.SkipZigTest; // TODO286 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
271289
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 @@
1const builtin = @import("builtin");
2
1const A = struct {3const 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}
810
9test "bug 1025" {11test "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 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3test "fixed" {4test "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 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3const A = struct {4const 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{};
11const a = A{ .b_list_pointer = &b_list };12const a = A{ .b_list_pointer = &b_list };
1213
13test "segfault bug" {14test "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 crash20 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 {
27var b_value = B2{ .pointer_array = &[_]*A2{} };31var b_value = B2{ .pointer_array = &[_]*A2{} };
2832
29test "basic stuff" {33test "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}
2828
29test "slicing" {29test "slicing" {
30 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
30 var array: [20]i32 = undefined;31 var array: [20]i32 = undefined;
3132
32 array[5] = 1234;33 array[5] = 1234;
...@@ -43,6 +44,7 @@ test "slicing" {...@@ -43,6 +44,7 @@ test "slicing" {
43}44}
4445
45test "const slice" {46test "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}
5456
55test "comptime slice of undefined pointer of length 0" {57test "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}
6164
62test "implicitly cast array of size 0 to slice" {65test "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}
7074
71test "access len index of sentinel-terminated slice" {75test "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}
8388
84test "comptime slice of slice preserves comptime var" {89test "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}
9197
92test "slice of type" {98test "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}
113120
114test "generic malloc free" {121test "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}
125133
126test "slice of hardcoded address to pointer" {134test "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}
139148
140test "comptime slice of pointer preserves comptime var" {149test "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}
148158
149test "comptime pointer cast array and then slice" {159test "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 };
151162
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}
161172
162test "slicing zero length array" {173test "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" {
171const x = @intToPtr([*]i32, 0x1000)[0..0x500];183const x = @intToPtr([*]i32, 0x1000)[0..0x500];
172const y = x[0x100..];184const y = x[0x100..];
173test "compile time slice of pointer to hard coded address" {185test "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;
175188
176 try expect(@ptrToInt(x) == 0x1000);189 try expect(@ptrToInt(x) == 0x1000);