authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-02-10 21:30:26+01:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-02-10 21:40:06+01:00
log9c6d416bec10b9edd88545287133921274af1d2f
tree408041de12ad2ba66bb139e2ca10d08297195469
parent0e2fcab334083d3cbc786e891be6c97e9fd81595
signaturelock-open Commit is signed but in an unrecognized format.

Activate passing behavior tests

This moves the single bugs behavior tests to the outer branch and disables the test cases for all non-passing backends. For the larger files, we move it up a single branch and disable it for the c backend. All test cases that do pass for the c backend however, are enabled.

5 files changed, 44 insertions(+), 4 deletions(-)

test/behavior.zig+4-4
...@@ -23,6 +23,8 @@ test {...@@ -23,6 +23,8 @@ test {
23 _ = @import("behavior/bugs/1914.zig");23 _ = @import("behavior/bugs/1914.zig");
24 _ = @import("behavior/bugs/2006.zig");24 _ = @import("behavior/bugs/2006.zig");
25 _ = @import("behavior/bugs/2346.zig");25 _ = @import("behavior/bugs/2346.zig");
26 _ = @import("behavior/bugs/2578.zig");
27 _ = @import("behavior/bugs/3007.zig");
26 _ = @import("behavior/bugs/3112.zig");28 _ = @import("behavior/bugs/3112.zig");
27 _ = @import("behavior/bugs/3367.zig");29 _ = @import("behavior/bugs/3367.zig");
28 _ = @import("behavior/bugs/6850.zig");30 _ = @import("behavior/bugs/6850.zig");
...@@ -58,9 +60,11 @@ test {...@@ -58,9 +60,11 @@ test {
58 _ = @import("behavior/bugs/4954.zig");60 _ = @import("behavior/bugs/4954.zig");
59 _ = @import("behavior/byval_arg_var.zig");61 _ = @import("behavior/byval_arg_var.zig");
60 _ = @import("behavior/call.zig");62 _ = @import("behavior/call.zig");
63 _ = @import("behavior/cast_llvm.zig");
61 _ = @import("behavior/defer.zig");64 _ = @import("behavior/defer.zig");
62 _ = @import("behavior/enum.zig");65 _ = @import("behavior/enum.zig");
63 _ = @import("behavior/error.zig");66 _ = @import("behavior/error.zig");
67 _ = @import("behavior/fn.zig");
64 _ = @import("behavior/for.zig");68 _ = @import("behavior/for.zig");
65 _ = @import("behavior/generics.zig");69 _ = @import("behavior/generics.zig");
66 _ = @import("behavior/if.zig");70 _ = @import("behavior/if.zig");
...@@ -93,14 +97,10 @@ test {...@@ -93,14 +97,10 @@ test {
93 if (builtin.zig_backend != .stage2_c) {97 if (builtin.zig_backend != .stage2_c) {
94 // Tests that pass for stage1 and the llvm backend.98 // Tests that pass for stage1 and the llvm backend.
95 _ = @import("behavior/atomics.zig");99 _ = @import("behavior/atomics.zig");
96 _ = @import("behavior/bugs/2578.zig");
97 _ = @import("behavior/bugs/3007.zig");
98 _ = @import("behavior/bugs/9584.zig");100 _ = @import("behavior/bugs/9584.zig");
99 _ = @import("behavior/cast_llvm.zig");
100 _ = @import("behavior/error_llvm.zig");101 _ = @import("behavior/error_llvm.zig");
101 _ = @import("behavior/eval.zig");102 _ = @import("behavior/eval.zig");
102 _ = @import("behavior/floatop.zig");103 _ = @import("behavior/floatop.zig");
103 _ = @import("behavior/fn.zig");
104 _ = @import("behavior/math.zig");104 _ = @import("behavior/math.zig");
105 _ = @import("behavior/maximum_minimum.zig");105 _ = @import("behavior/maximum_minimum.zig");
106 _ = @import("behavior/merge_error_sets.zig");106 _ = @import("behavior/merge_error_sets.zig");
test/behavior/bugs/2578.zig+6
...@@ -1,3 +1,5 @@...@@ -1,3 +1,5 @@
1const builtin = @import("builtin");
2
1const Foo = struct {3const Foo = struct {
2 y: u8,4 y: u8,
3};5};
...@@ -10,5 +12,9 @@ fn bar(pointer: ?*anyopaque) void {...@@ -10,5 +12,9 @@ fn bar(pointer: ?*anyopaque) void {
10}12}
1113
12test "fixed" {14test "fixed" {
15 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
16 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
17 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
18
13 bar(t);19 bar(t);
14}20}
test/behavior/bugs/3007.zig+5
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
23
3const Foo = struct {4const Foo = struct {
4 free: bool,5 free: bool,
...@@ -18,6 +19,10 @@ fn get_foo() Foo.FooError!*Foo {...@@ -18,6 +19,10 @@ fn get_foo() Foo.FooError!*Foo {
18}19}
1920
20test "fixed" {21test "fixed" {
22 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
23 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
24 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
25
21 default_foo = get_foo() catch null; // This Line26 default_foo = get_foo() catch null; // This Line
22 try std.testing.expect(!default_foo.?.free);27 try std.testing.expect(!default_foo.?.free);
23}28}
test/behavior/cast_llvm.zig+24
...@@ -6,6 +6,8 @@ const maxInt = std.math.maxInt;...@@ -6,6 +6,8 @@ const maxInt = std.math.maxInt;
6const native_endian = builtin.target.cpu.arch.endian();6const native_endian = builtin.target.cpu.arch.endian();
77
8test "pointer reinterpret const float to int" {8test "pointer reinterpret const float to int" {
9 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
10
9 // The hex representation is 0x3fe3333333333303.11 // The hex representation is 0x3fe3333333333303.
10 const float: f64 = 5.99999999999994648725e-01;12 const float: f64 = 5.99999999999994648725e-01;
11 const float_ptr = &float;13 const float_ptr = &float;
...@@ -18,6 +20,8 @@ test "pointer reinterpret const float to int" {...@@ -18,6 +20,8 @@ test "pointer reinterpret const float to int" {
18}20}
1921
20test "@floatToInt" {22test "@floatToInt" {
23 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
24
21 try testFloatToInts();25 try testFloatToInts();
22 comptime try testFloatToInts();26 comptime try testFloatToInts();
23}27}
...@@ -33,6 +37,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void {...@@ -33,6 +37,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void {
33}37}
3438
35test "implicit cast from [*]T to ?*anyopaque" {39test "implicit cast from [*]T to ?*anyopaque" {
40 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
41
36 var a = [_]u8{ 3, 2, 1 };42 var a = [_]u8{ 3, 2, 1 };
37 var runtime_zero: usize = 0;43 var runtime_zero: usize = 0;
38 incrementVoidPtrArray(a[runtime_zero..].ptr, 3);44 incrementVoidPtrArray(a[runtime_zero..].ptr, 3);
...@@ -49,6 +55,7 @@ fn incrementVoidPtrArray(array: ?*anyopaque, len: usize) void {...@@ -49,6 +55,7 @@ fn incrementVoidPtrArray(array: ?*anyopaque, len: usize) void {
49test "compile time int to ptr of function" {55test "compile time int to ptr of function" {
50 if (builtin.zig_backend == .stage1) return error.SkipZigTest;56 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
51 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO57 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO
58 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
5259
53 try foobar(FUNCTION_CONSTANT);60 try foobar(FUNCTION_CONSTANT);
54}61}
...@@ -61,6 +68,8 @@ fn foobar(func: PFN_void) !void {...@@ -61,6 +68,8 @@ fn foobar(func: PFN_void) !void {
61}68}
6269
63test "implicit ptr to *anyopaque" {70test "implicit ptr to *anyopaque" {
71 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
72
64 var a: u32 = 1;73 var a: u32 = 1;
65 var ptr: *align(@alignOf(u32)) anyopaque = &a;74 var ptr: *align(@alignOf(u32)) anyopaque = &a;
66 var b: *u32 = @ptrCast(*u32, ptr);75 var b: *u32 = @ptrCast(*u32, ptr);
...@@ -87,6 +96,7 @@ fn returnNullLitFromOptionalTypeErrorRef() anyerror!?*A {...@@ -87,6 +96,7 @@ fn returnNullLitFromOptionalTypeErrorRef() anyerror!?*A {
87}96}
8897
89test "peer type resolution: [0]u8 and []const u8" {98test "peer type resolution: [0]u8 and []const u8" {
99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
90 try expect(peerTypeEmptyArrayAndSlice(true, "hi").len == 0);100 try expect(peerTypeEmptyArrayAndSlice(true, "hi").len == 0);
91 try expect(peerTypeEmptyArrayAndSlice(false, "hi").len == 1);101 try expect(peerTypeEmptyArrayAndSlice(false, "hi").len == 1);
92 comptime {102 comptime {
...@@ -103,6 +113,7 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 {...@@ -103,6 +113,7 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 {
103}113}
104114
105test "implicitly cast from [N]T to ?[]const T" {115test "implicitly cast from [N]T to ?[]const T" {
116 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
106 try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));117 try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
107 comptime try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));118 comptime try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
108}119}
...@@ -112,6 +123,7 @@ fn castToOptionalSlice() ?[]const u8 {...@@ -112,6 +123,7 @@ fn castToOptionalSlice() ?[]const u8 {
112}123}
113124
114test "cast u128 to f128 and back" {125test "cast u128 to f128 and back" {
126 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
115 comptime try testCast128();127 comptime try testCast128();
116 try testCast128();128 try testCast128();
117}129}
...@@ -129,6 +141,7 @@ fn cast128Float(x: u128) f128 {...@@ -129,6 +141,7 @@ fn cast128Float(x: u128) f128 {
129}141}
130142
131test "implicit cast from *[N]T to ?[*]T" {143test "implicit cast from *[N]T to ?[*]T" {
144 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
132 var x: ?[*]u16 = null;145 var x: ?[*]u16 = null;
133 var y: [4]u16 = [4]u16{ 0, 1, 2, 3 };146 var y: [4]u16 = [4]u16{ 0, 1, 2, 3 };
134147
...@@ -140,6 +153,7 @@ test "implicit cast from *[N]T to ?[*]T" {...@@ -140,6 +153,7 @@ test "implicit cast from *[N]T to ?[*]T" {
140}153}
141154
142test "implicit cast from *T to ?*anyopaque" {155test "implicit cast from *T to ?*anyopaque" {
156 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
143 var a: u8 = 1;157 var a: u8 = 1;
144 incrementVoidPtrValue(&a);158 incrementVoidPtrValue(&a);
145 try std.testing.expect(a == 2);159 try std.testing.expect(a == 2);
...@@ -150,6 +164,7 @@ fn incrementVoidPtrValue(value: ?*anyopaque) void {...@@ -150,6 +164,7 @@ fn incrementVoidPtrValue(value: ?*anyopaque) void {
150}164}
151165
152test "implicit cast *[0]T to E![]const u8" {166test "implicit cast *[0]T to E![]const u8" {
167 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
153 var x = @as(anyerror![]const u8, &[0]u8{});168 var x = @as(anyerror![]const u8, &[0]u8{});
154 try expect((x catch unreachable).len == 0);169 try expect((x catch unreachable).len == 0);
155}170}
...@@ -160,11 +175,13 @@ test "cast from array reference to fn: comptime fn ptr" {...@@ -160,11 +175,13 @@ test "cast from array reference to fn: comptime fn ptr" {
160 try expect(@ptrToInt(f) == @ptrToInt(&global_array));175 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
161}176}
162test "cast from array reference to fn: runtime fn ptr" {177test "cast from array reference to fn: runtime fn ptr" {
178 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
163 var f = @ptrCast(*const fn () callconv(.C) void, &global_array);179 var f = @ptrCast(*const fn () callconv(.C) void, &global_array);
164 try expect(@ptrToInt(f) == @ptrToInt(&global_array));180 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
165}181}
166182
167test "*const [N]null u8 to ?[]const u8" {183test "*const [N]null u8 to ?[]const u8" {
184 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
168 const S = struct {185 const S = struct {
169 fn doTheTest() !void {186 fn doTheTest() !void {
170 var a = "Hello";187 var a = "Hello";
...@@ -196,6 +213,7 @@ test "cast between [*c]T and ?[*:0]T on fn parameter" {...@@ -196,6 +213,7 @@ test "cast between [*c]T and ?[*:0]T on fn parameter" {
196213
197var global_struct: struct { f0: usize } = undefined;214var global_struct: struct { f0: usize } = undefined;
198test "assignment to optional pointer result loc" {215test "assignment to optional pointer result loc" {
216 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
199 var foo: struct { ptr: ?*anyopaque } = .{ .ptr = &global_struct };217 var foo: struct { ptr: ?*anyopaque } = .{ .ptr = &global_struct };
200 try expect(foo.ptr.? == @ptrCast(*anyopaque, &global_struct));218 try expect(foo.ptr.? == @ptrCast(*anyopaque, &global_struct));
201}219}
...@@ -217,6 +235,8 @@ fn boolToStr(b: bool) []const u8 {...@@ -217,6 +235,8 @@ fn boolToStr(b: bool) []const u8 {
217}235}
218236
219test "cast f16 to wider types" {237test "cast f16 to wider types" {
238 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
239 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
220 const S = struct {240 const S = struct {
221 fn doTheTest() !void {241 fn doTheTest() !void {
222 var x: f16 = 1234.0;242 var x: f16 = 1234.0;
...@@ -230,6 +250,9 @@ test "cast f16 to wider types" {...@@ -230,6 +250,9 @@ test "cast f16 to wider types" {
230}250}
231251
232test "cast f128 to narrower types" {252test "cast f128 to narrower types" {
253 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
254 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
255
233 const S = struct {256 const S = struct {
234 fn doTheTest() !void {257 fn doTheTest() !void {
235 var x: f128 = 1234.0;258 var x: f128 = 1234.0;
...@@ -243,6 +266,7 @@ test "cast f128 to narrower types" {...@@ -243,6 +266,7 @@ test "cast f128 to narrower types" {
243}266}
244267
245test "peer type resolution: unreachable, null, slice" {268test "peer type resolution: unreachable, null, slice" {
269 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
246 const S = struct {270 const S = struct {
247 fn doTheTest(num: usize, word: []const u8) !void {271 fn doTheTest(num: usize, word: []const u8) !void {
248 const result = switch (num) {272 const result = switch (num) {
test/behavior/fn.zig+5
...@@ -75,6 +75,7 @@ test "return inner function which references comptime variable of outer function...@@ -75,6 +75,7 @@ test "return inner function which references comptime variable of outer function
75}75}
7676
77test "discard the result of a function that returns a struct" {77test "discard the result of a function that returns a struct" {
78 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
78 const S = struct {79 const S = struct {
79 fn entry() void {80 fn entry() void {
80 _ = func();81 _ = func();
...@@ -94,6 +95,7 @@ test "discard the result of a function that returns a struct" {...@@ -94,6 +95,7 @@ test "discard the result of a function that returns a struct" {
94}95}
9596
96test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" {97test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" {
98 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
97 if (builtin.zig_backend == .stage1) return error.SkipZigTest;99 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
98100
99 const S = struct {101 const S = struct {
...@@ -139,6 +141,7 @@ fn fnWithUnreachable() noreturn {...@@ -139,6 +141,7 @@ fn fnWithUnreachable() noreturn {
139}141}
140142
141test "extern struct with stdcallcc fn pointer" {143test "extern struct with stdcallcc fn pointer" {
144 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
142 if (builtin.zig_backend == .stage1) return error.SkipZigTest;145 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
143146
144 const S = extern struct {147 const S = extern struct {
...@@ -252,6 +255,7 @@ test "implicit cast fn call result to optional in field result" {...@@ -252,6 +255,7 @@ test "implicit cast fn call result to optional in field result" {
252}255}
253256
254test "void parameters" {257test "void parameters" {
258 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
255 try voidFun(1, void{}, 2, {});259 try voidFun(1, void{}, 2, {});
256}260}
257fn voidFun(a: i32, b: void, c: i32, d: void) !void {261fn voidFun(a: i32, b: void, c: i32, d: void) !void {
...@@ -306,6 +310,7 @@ fn numberLiteralArg(a: anytype) !void {...@@ -306,6 +310,7 @@ fn numberLiteralArg(a: anytype) !void {
306}310}
307311
308test "function call with anon list literal" {312test "function call with anon list literal" {
313 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
309 const S = struct {314 const S = struct {
310 fn doTheTest() !void {315 fn doTheTest() !void {
311 try consumeVec(.{ 9, 8, 7 });316 try consumeVec(.{ 9, 8, 7 });