authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-12 21:35:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-02-12 21:35:29-07:00
log0b7347fd18eee7dd829cd9aaed3683123d84859b
tree622e786fb73083368eb287248bd742e2c6aba6d3
parentc349191b75811f8a21e26f8b175483449fae1638

move more behavior tests to the "passing" section


7 files changed, 51 insertions(+), 8 deletions(-)

test/behavior.zig+7-7
...@@ -31,18 +31,23 @@ test {...@@ -31,18 +31,23 @@ test {
31 _ = @import("behavior/bugs/7250.zig");31 _ = @import("behavior/bugs/7250.zig");
32 _ = @import("behavior/cast.zig");32 _ = @import("behavior/cast.zig");
33 _ = @import("behavior/comptime_memory.zig");33 _ = @import("behavior/comptime_memory.zig");
34 _ = @import("behavior/fn_delegation.zig");
34 _ = @import("behavior/fn_in_struct_in_comptime.zig");35 _ = @import("behavior/fn_in_struct_in_comptime.zig");
35 _ = @import("behavior/hasdecl.zig");36 _ = @import("behavior/hasdecl.zig");
36 _ = @import("behavior/hasfield.zig");37 _ = @import("behavior/hasfield.zig");
38 _ = @import("behavior/ir_block_deps.zig");
37 _ = @import("behavior/namespace_depends_on_compile_var.zig");39 _ = @import("behavior/namespace_depends_on_compile_var.zig");
38 _ = @import("behavior/optional.zig");40 _ = @import("behavior/optional.zig");
39 _ = @import("behavior/prefetch.zig");41 _ = @import("behavior/prefetch.zig");
40 _ = @import("behavior/pub_enum.zig");42 _ = @import("behavior/pub_enum.zig");
43 _ = @import("behavior/reflection.zig");
41 _ = @import("behavior/slice.zig");44 _ = @import("behavior/slice.zig");
42 _ = @import("behavior/slice_sentinel_comptime.zig");45 _ = @import("behavior/slice_sentinel_comptime.zig");
43 _ = @import("behavior/type.zig");
44 _ = @import("behavior/truncate.zig");
45 _ = @import("behavior/struct.zig");46 _ = @import("behavior/struct.zig");
47 _ = @import("behavior/truncate.zig");
48 _ = @import("behavior/tuple.zig");
49 _ = @import("behavior/type.zig");
50 _ = @import("behavior/var_args.zig");
4651
47 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {52 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
48 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.53 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
...@@ -145,21 +150,16 @@ test {...@@ -145,21 +150,16 @@ test {
145 _ = @import("behavior/const_slice_child.zig");150 _ = @import("behavior/const_slice_child.zig");
146 _ = @import("behavior/export_self_referential_type_info.zig");151 _ = @import("behavior/export_self_referential_type_info.zig");
147 _ = @import("behavior/field_parent_ptr.zig");152 _ = @import("behavior/field_parent_ptr.zig");
148 _ = @import("behavior/fn_delegation.zig");
149 _ = @import("behavior/ir_block_deps.zig");
150 _ = @import("behavior/misc.zig");153 _ = @import("behavior/misc.zig");
151 _ = @import("behavior/muladd.zig");154 _ = @import("behavior/muladd.zig");
152 _ = @import("behavior/reflection.zig");
153 _ = @import("behavior/select.zig");155 _ = @import("behavior/select.zig");
154 _ = @import("behavior/shuffle.zig");156 _ = @import("behavior/shuffle.zig");
155 _ = @import("behavior/struct_contains_null_ptr_itself.zig");157 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
156 _ = @import("behavior/struct_contains_slice_of_itself.zig");158 _ = @import("behavior/struct_contains_slice_of_itself.zig");
157 _ = @import("behavior/switch_prong_err_enum.zig");159 _ = @import("behavior/switch_prong_err_enum.zig");
158 _ = @import("behavior/switch_prong_implicit_cast.zig");160 _ = @import("behavior/switch_prong_implicit_cast.zig");
159 _ = @import("behavior/tuple.zig");
160 _ = @import("behavior/typename.zig");161 _ = @import("behavior/typename.zig");
161 _ = @import("behavior/union_with_members.zig");162 _ = @import("behavior/union_with_members.zig");
162 _ = @import("behavior/var_args.zig");
163 _ = @import("behavior/vector.zig");163 _ = @import("behavior/vector.zig");
164 if (builtin.target.cpu.arch == .wasm32) {164 if (builtin.target.cpu.arch == .wasm32) {
165 _ = @import("behavior/wasm.zig");165 _ = @import("behavior/wasm.zig");
test/behavior/fn_delegation.zig+3
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const expect = @import("std").testing.expect;2const expect = @import("std").testing.expect;
23
3const Foo = struct {4const Foo = struct {
...@@ -31,6 +32,8 @@ fn custom(comptime T: type, comptime num: u64) fn (T) u64 {...@@ -31,6 +32,8 @@ fn custom(comptime T: type, comptime num: u64) fn (T) u64 {
31}32}
3233
33test "fn delegation" {34test "fn delegation" {
35 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
36
34 const foo = Foo{};37 const foo = Foo{};
35 try expect(foo.one() == 11);38 try expect(foo.one() == 11);
36 try expect(foo.two() == 12);39 try expect(foo.two() == 12);
test/behavior/ir_block_deps.zig+4
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const expect = @import("std").testing.expect;2const expect = @import("std").testing.expect;
23
3fn foo(id: u64) !i32 {4fn foo(id: u64) !i32 {
...@@ -17,6 +18,9 @@ fn getErrInt() anyerror!i32 {...@@ -17,6 +18,9 @@ fn getErrInt() anyerror!i32 {
17}18}
1819
19test "ir block deps" {20test "ir block deps" {
21 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
22 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
23
20 try expect((foo(1) catch unreachable) == 0);24 try expect((foo(1) catch unreachable) == 0);
21 try expect((foo(2) catch unreachable) == 0);25 try expect((foo(2) catch unreachable) == 0);
22}26}
test/behavior/reflection.zig+6
...@@ -1,9 +1,12 @@...@@ -1,9 +1,12 @@
1const builtin = @import("builtin");
1const std = @import("std");2const std = @import("std");
2const expect = std.testing.expect;3const expect = std.testing.expect;
3const mem = std.mem;4const mem = std.mem;
4const reflection = @This();5const reflection = @This();
56
6test "reflection: function return type, var args, and param types" {7test "reflection: function return type, var args, and param types" {
8 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
9
7 comptime {10 comptime {
8 const info = @typeInfo(@TypeOf(dummy)).Fn;11 const info = @typeInfo(@TypeOf(dummy)).Fn;
9 try expect(info.return_type.? == i32);12 try expect(info.return_type.? == i32);
...@@ -25,6 +28,9 @@ fn dummy(a: bool, b: i32, c: f32) i32 {...@@ -25,6 +28,9 @@ fn dummy(a: bool, b: i32, c: f32) i32 {
25}28}
2629
27test "reflection: @field" {30test "reflection: @field" {
31 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
32 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
33
28 var f = Foo{34 var f = Foo{
29 .one = 42,35 .one = 42,
30 .two = true,36 .two = true,
test/behavior/tuple.zig+11
...@@ -1,9 +1,12 @@...@@ -1,9 +1,12 @@
1const builtin = @import("builtin");
1const std = @import("std");2const std = @import("std");
2const testing = std.testing;3const testing = std.testing;
3const expect = testing.expect;4const expect = testing.expect;
4const expectEqual = testing.expectEqual;5const expectEqual = testing.expectEqual;
56
6test "tuple concatenation" {7test "tuple concatenation" {
8 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
9
7 const S = struct {10 const S = struct {
8 fn doTheTest() !void {11 fn doTheTest() !void {
9 var a: i32 = 1;12 var a: i32 = 1;
...@@ -20,6 +23,8 @@ test "tuple concatenation" {...@@ -20,6 +23,8 @@ test "tuple concatenation" {
20}23}
2124
22test "tuple multiplication" {25test "tuple multiplication" {
26 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
27
23 const S = struct {28 const S = struct {
24 fn doTheTest() !void {29 fn doTheTest() !void {
25 {30 {
...@@ -81,6 +86,8 @@ test "tuple multiplication" {...@@ -81,6 +86,8 @@ test "tuple multiplication" {
81}86}
8287
83test "pass tuple to comptime var parameter" {88test "pass tuple to comptime var parameter" {
89 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
90
84 const S = struct {91 const S = struct {
85 fn Foo(comptime args: anytype) !void {92 fn Foo(comptime args: anytype) !void {
86 try expect(args[0] == 1);93 try expect(args[0] == 1);
...@@ -95,6 +102,8 @@ test "pass tuple to comptime var parameter" {...@@ -95,6 +102,8 @@ test "pass tuple to comptime var parameter" {
95}102}
96103
97test "tuple initializer for var" {104test "tuple initializer for var" {
105 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
106
98 const S = struct {107 const S = struct {
99 fn doTheTest() void {108 fn doTheTest() void {
100 const Bytes = struct {109 const Bytes = struct {
...@@ -114,6 +123,8 @@ test "tuple initializer for var" {...@@ -114,6 +123,8 @@ test "tuple initializer for var" {
114}123}
115124
116test "array-like initializer for tuple types" {125test "array-like initializer for tuple types" {
126 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
127
117 const T = @Type(std.builtin.TypeInfo{128 const T = @Type(std.builtin.TypeInfo{
118 .Struct = std.builtin.TypeInfo.Struct{129 .Struct = std.builtin.TypeInfo.Struct{
119 .is_tuple = true,130 .is_tuple = true,
test/behavior/union.zig+1-1
...@@ -362,7 +362,7 @@ pub const FooUnion = union(enum) {...@@ -362,7 +362,7 @@ pub const FooUnion = union(enum) {
362var glbl_array: [2]FooUnion = undefined;362var glbl_array: [2]FooUnion = undefined;
363363
364test "initialize global array of union" {364test "initialize global array of union" {
365 if (@import("builtin").zig_backend == .stage2_wasm) return error.SkipZigTest;365 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
366366
367 glbl_array[1] = FooUnion{ .U1 = 2 };367 glbl_array[1] = FooUnion{ .U1 = 2 };
368 glbl_array[0] = FooUnion{ .U0 = 1 };368 glbl_array[0] = FooUnion{ .U0 = 1 };
test/behavior/var_args.zig+19
...@@ -1,3 +1,4 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const expect = @import("std").testing.expect;2const expect = @import("std").testing.expect;
23
3fn add(args: anytype) i32 {4fn add(args: anytype) i32 {
...@@ -12,6 +13,8 @@ fn add(args: anytype) i32 {...@@ -12,6 +13,8 @@ fn add(args: anytype) i32 {
12}13}
1314
14test "add arbitrary args" {15test "add arbitrary args" {
16 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
17
15 try expect(add(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);18 try expect(add(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);
16 try expect(add(.{@as(i32, 1234)}) == 1234);19 try expect(add(.{@as(i32, 1234)}) == 1234);
17 try expect(add(.{}) == 0);20 try expect(add(.{}) == 0);
...@@ -22,10 +25,16 @@ fn readFirstVarArg(args: anytype) void {...@@ -22,10 +25,16 @@ fn readFirstVarArg(args: anytype) void {
22}25}
2326
24test "send void arg to var args" {27test "send void arg to var args" {
28 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
29 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
30 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
31
25 readFirstVarArg(.{{}});32 readFirstVarArg(.{{}});
26}33}
2734
28test "pass args directly" {35test "pass args directly" {
36 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
37
29 try expect(addSomeStuff(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);38 try expect(addSomeStuff(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);
30 try expect(addSomeStuff(.{@as(i32, 1234)}) == 1234);39 try expect(addSomeStuff(.{@as(i32, 1234)}) == 1234);
31 try expect(addSomeStuff(.{}) == 0);40 try expect(addSomeStuff(.{}) == 0);
...@@ -36,6 +45,8 @@ fn addSomeStuff(args: anytype) i32 {...@@ -36,6 +45,8 @@ fn addSomeStuff(args: anytype) i32 {
36}45}
3746
38test "runtime parameter before var args" {47test "runtime parameter before var args" {
48 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
49
39 try expect((try extraFn(10, .{})) == 0);50 try expect((try extraFn(10, .{})) == 0);
40 try expect((try extraFn(10, .{false})) == 1);51 try expect((try extraFn(10, .{false})) == 1);
41 try expect((try extraFn(10, .{ false, true })) == 2);52 try expect((try extraFn(10, .{ false, true })) == 2);
...@@ -73,11 +84,19 @@ fn foo2(args: anytype) bool {...@@ -73,11 +84,19 @@ fn foo2(args: anytype) bool {
73}84}
7485
75test "array of var args functions" {86test "array of var args functions" {
87 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
88 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
89 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
90
76 try expect(foos[0](.{}));91 try expect(foos[0](.{}));
77 try expect(!foos[1](.{}));92 try expect(!foos[1](.{}));
78}93}
7994
80test "pass zero length array to var args param" {95test "pass zero length array to var args param" {
96 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
97 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
98 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
99
81 doNothingWithFirstArg(.{""});100 doNothingWithFirstArg(.{""});
82}101}
83102