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
signature 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 {
2323 _ = @import("behavior/bugs/1914.zig");
2424 _ = @import("behavior/bugs/2006.zig");
2525 _ = @import("behavior/bugs/2346.zig");
26 _ = @import("behavior/bugs/2578.zig");
27 _ = @import("behavior/bugs/3007.zig");
2628 _ = @import("behavior/bugs/3112.zig");
2729 _ = @import("behavior/bugs/3367.zig");
2830 _ = @import("behavior/bugs/6850.zig");
......@@ -58,9 +60,11 @@ test {
5860 _ = @import("behavior/bugs/4954.zig");
5961 _ = @import("behavior/byval_arg_var.zig");
6062 _ = @import("behavior/call.zig");
63 _ = @import("behavior/cast_llvm.zig");
6164 _ = @import("behavior/defer.zig");
6265 _ = @import("behavior/enum.zig");
6366 _ = @import("behavior/error.zig");
67 _ = @import("behavior/fn.zig");
6468 _ = @import("behavior/for.zig");
6569 _ = @import("behavior/generics.zig");
6670 _ = @import("behavior/if.zig");
......@@ -93,14 +97,10 @@ test {
9397 if (builtin.zig_backend != .stage2_c) {
9498 // Tests that pass for stage1 and the llvm backend.
9599 _ = @import("behavior/atomics.zig");
96 _ = @import("behavior/bugs/2578.zig");
97 _ = @import("behavior/bugs/3007.zig");
98100 _ = @import("behavior/bugs/9584.zig");
99 _ = @import("behavior/cast_llvm.zig");
100101 _ = @import("behavior/error_llvm.zig");
101102 _ = @import("behavior/eval.zig");
102103 _ = @import("behavior/floatop.zig");
103 _ = @import("behavior/fn.zig");
104104 _ = @import("behavior/math.zig");
105105 _ = @import("behavior/maximum_minimum.zig");
106106 _ = @import("behavior/merge_error_sets.zig");
test/behavior/bugs/2578.zig+6
......@@ -1,3 +1,5 @@
1const builtin = @import("builtin");
2
13const Foo = struct {
24 y: u8,
35};
......@@ -10,5 +12,9 @@ fn bar(pointer: ?*anyopaque) void {
1012}
1113
1214test "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
1319 bar(t);
1420}
test/behavior/bugs/3007.zig+5
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const builtin = @import("builtin");
23
34const Foo = struct {
45 free: bool,
......@@ -18,6 +19,10 @@ fn get_foo() Foo.FooError!*Foo {
1819}
1920
2021test "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
2126 default_foo = get_foo() catch null; // This Line
2227 try std.testing.expect(!default_foo.?.free);
2328}
test/behavior/cast_llvm.zig+24
......@@ -6,6 +6,8 @@ const maxInt = std.math.maxInt;
66const native_endian = builtin.target.cpu.arch.endian();
77
88test "pointer reinterpret const float to int" {
9 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
10
911 // The hex representation is 0x3fe3333333333303.
1012 const float: f64 = 5.99999999999994648725e-01;
1113 const float_ptr = &float;
......@@ -18,6 +20,8 @@ test "pointer reinterpret const float to int" {
1820}
1921
2022test "@floatToInt" {
23 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
24
2125 try testFloatToInts();
2226 comptime try testFloatToInts();
2327}
......@@ -33,6 +37,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void {
3337}
3438
3539test "implicit cast from [*]T to ?*anyopaque" {
40 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
41
3642 var a = [_]u8{ 3, 2, 1 };
3743 var runtime_zero: usize = 0;
3844 incrementVoidPtrArray(a[runtime_zero..].ptr, 3);
......@@ -49,6 +55,7 @@ fn incrementVoidPtrArray(array: ?*anyopaque, len: usize) void {
4955test "compile time int to ptr of function" {
5056 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
5157 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
5360 try foobar(FUNCTION_CONSTANT);
5461}
......@@ -61,6 +68,8 @@ fn foobar(func: PFN_void) !void {
6168}
6269
6370test "implicit ptr to *anyopaque" {
71 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
72
6473 var a: u32 = 1;
6574 var ptr: *align(@alignOf(u32)) anyopaque = &a;
6675 var b: *u32 = @ptrCast(*u32, ptr);
......@@ -87,6 +96,7 @@ fn returnNullLitFromOptionalTypeErrorRef() anyerror!?*A {
8796}
8897
8998test "peer type resolution: [0]u8 and []const u8" {
99 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
90100 try expect(peerTypeEmptyArrayAndSlice(true, "hi").len == 0);
91101 try expect(peerTypeEmptyArrayAndSlice(false, "hi").len == 1);
92102 comptime {
......@@ -103,6 +113,7 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 {
103113}
104114
105115test "implicitly cast from [N]T to ?[]const T" {
116 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
106117 try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
107118 comptime try expect(mem.eql(u8, castToOptionalSlice().?, "hi"));
108119}
......@@ -112,6 +123,7 @@ fn castToOptionalSlice() ?[]const u8 {
112123}
113124
114125test "cast u128 to f128 and back" {
126 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
115127 comptime try testCast128();
116128 try testCast128();
117129}
......@@ -129,6 +141,7 @@ fn cast128Float(x: u128) f128 {
129141}
130142
131143test "implicit cast from *[N]T to ?[*]T" {
144 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
132145 var x: ?[*]u16 = null;
133146 var y: [4]u16 = [4]u16{ 0, 1, 2, 3 };
134147
......@@ -140,6 +153,7 @@ test "implicit cast from *[N]T to ?[*]T" {
140153}
141154
142155test "implicit cast from *T to ?*anyopaque" {
156 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
143157 var a: u8 = 1;
144158 incrementVoidPtrValue(&a);
145159 try std.testing.expect(a == 2);
......@@ -150,6 +164,7 @@ fn incrementVoidPtrValue(value: ?*anyopaque) void {
150164}
151165
152166test "implicit cast *[0]T to E![]const u8" {
167 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
153168 var x = @as(anyerror![]const u8, &[0]u8{});
154169 try expect((x catch unreachable).len == 0);
155170}
......@@ -160,11 +175,13 @@ test "cast from array reference to fn: comptime fn ptr" {
160175 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
161176}
162177test "cast from array reference to fn: runtime fn ptr" {
178 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
163179 var f = @ptrCast(*const fn () callconv(.C) void, &global_array);
164180 try expect(@ptrToInt(f) == @ptrToInt(&global_array));
165181}
166182
167183test "*const [N]null u8 to ?[]const u8" {
184 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
168185 const S = struct {
169186 fn doTheTest() !void {
170187 var a = "Hello";
......@@ -196,6 +213,7 @@ test "cast between [*c]T and ?[*:0]T on fn parameter" {
196213
197214var global_struct: struct { f0: usize } = undefined;
198215test "assignment to optional pointer result loc" {
216 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
199217 var foo: struct { ptr: ?*anyopaque } = .{ .ptr = &global_struct };
200218 try expect(foo.ptr.? == @ptrCast(*anyopaque, &global_struct));
201219}
......@@ -217,6 +235,8 @@ fn boolToStr(b: bool) []const u8 {
217235}
218236
219237test "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
220240 const S = struct {
221241 fn doTheTest() !void {
222242 var x: f16 = 1234.0;
......@@ -230,6 +250,9 @@ test "cast f16 to wider types" {
230250}
231251
232252test "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
233256 const S = struct {
234257 fn doTheTest() !void {
235258 var x: f128 = 1234.0;
......@@ -243,6 +266,7 @@ test "cast f128 to narrower types" {
243266}
244267
245268test "peer type resolution: unreachable, null, slice" {
269 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
246270 const S = struct {
247271 fn doTheTest(num: usize, word: []const u8) !void {
248272 const result = switch (num) {
test/behavior/fn.zig+5
......@@ -75,6 +75,7 @@ test "return inner function which references comptime variable of outer function
7575}
7676
7777test "discard the result of a function that returns a struct" {
78 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
7879 const S = struct {
7980 fn entry() void {
8081 _ = func();
......@@ -94,6 +95,7 @@ test "discard the result of a function that returns a struct" {
9495}
9596
9697test "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
9799 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
98100
99101 const S = struct {
......@@ -139,6 +141,7 @@ fn fnWithUnreachable() noreturn {
139141}
140142
141143test "extern struct with stdcallcc fn pointer" {
144 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
142145 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
143146
144147 const S = extern struct {
......@@ -252,6 +255,7 @@ test "implicit cast fn call result to optional in field result" {
252255}
253256
254257test "void parameters" {
258 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
255259 try voidFun(1, void{}, 2, {});
256260}
257261fn voidFun(a: i32, b: void, c: i32, d: void) !void {
......@@ -306,6 +310,7 @@ fn numberLiteralArg(a: anytype) !void {
306310}
307311
308312test "function call with anon list literal" {
313 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
309314 const S = struct {
310315 fn doTheTest() !void {
311316 try consumeVec(.{ 9, 8, 7 });