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 {
3131 _ = @import("behavior/bugs/7250.zig");
3232 _ = @import("behavior/cast.zig");
3333 _ = @import("behavior/comptime_memory.zig");
34 _ = @import("behavior/fn_delegation.zig");
3435 _ = @import("behavior/fn_in_struct_in_comptime.zig");
3536 _ = @import("behavior/hasdecl.zig");
3637 _ = @import("behavior/hasfield.zig");
38 _ = @import("behavior/ir_block_deps.zig");
3739 _ = @import("behavior/namespace_depends_on_compile_var.zig");
3840 _ = @import("behavior/optional.zig");
3941 _ = @import("behavior/prefetch.zig");
4042 _ = @import("behavior/pub_enum.zig");
43 _ = @import("behavior/reflection.zig");
4144 _ = @import("behavior/slice.zig");
4245 _ = @import("behavior/slice_sentinel_comptime.zig");
43 _ = @import("behavior/type.zig");
44 _ = @import("behavior/truncate.zig");
4546 _ = @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
4752 if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64) {
4853 // Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
......@@ -145,21 +150,16 @@ test {
145150 _ = @import("behavior/const_slice_child.zig");
146151 _ = @import("behavior/export_self_referential_type_info.zig");
147152 _ = @import("behavior/field_parent_ptr.zig");
148 _ = @import("behavior/fn_delegation.zig");
149 _ = @import("behavior/ir_block_deps.zig");
150153 _ = @import("behavior/misc.zig");
151154 _ = @import("behavior/muladd.zig");
152 _ = @import("behavior/reflection.zig");
153155 _ = @import("behavior/select.zig");
154156 _ = @import("behavior/shuffle.zig");
155157 _ = @import("behavior/struct_contains_null_ptr_itself.zig");
156158 _ = @import("behavior/struct_contains_slice_of_itself.zig");
157159 _ = @import("behavior/switch_prong_err_enum.zig");
158160 _ = @import("behavior/switch_prong_implicit_cast.zig");
159 _ = @import("behavior/tuple.zig");
160161 _ = @import("behavior/typename.zig");
161162 _ = @import("behavior/union_with_members.zig");
162 _ = @import("behavior/var_args.zig");
163163 _ = @import("behavior/vector.zig");
164164 if (builtin.target.cpu.arch == .wasm32) {
165165 _ = @import("behavior/wasm.zig");
test/behavior/fn_delegation.zig+3
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const expect = @import("std").testing.expect;
23
34const Foo = struct {
......@@ -31,6 +32,8 @@ fn custom(comptime T: type, comptime num: u64) fn (T) u64 {
3132}
3233
3334test "fn delegation" {
35 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
36
3437 const foo = Foo{};
3538 try expect(foo.one() == 11);
3639 try expect(foo.two() == 12);
test/behavior/ir_block_deps.zig+4
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const expect = @import("std").testing.expect;
23
34fn foo(id: u64) !i32 {
......@@ -17,6 +18,9 @@ fn getErrInt() anyerror!i32 {
1718}
1819
1920test "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
2024 try expect((foo(1) catch unreachable) == 0);
2125 try expect((foo(2) catch unreachable) == 0);
2226}
test/behavior/reflection.zig+6
......@@ -1,9 +1,12 @@
1const builtin = @import("builtin");
12const std = @import("std");
23const expect = std.testing.expect;
34const mem = std.mem;
45const reflection = @This();
56
67test "reflection: function return type, var args, and param types" {
8 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
9
710 comptime {
811 const info = @typeInfo(@TypeOf(dummy)).Fn;
912 try expect(info.return_type.? == i32);
......@@ -25,6 +28,9 @@ fn dummy(a: bool, b: i32, c: f32) i32 {
2528}
2629
2730test "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
2834 var f = Foo{
2935 .one = 42,
3036 .two = true,
test/behavior/tuple.zig+11
......@@ -1,9 +1,12 @@
1const builtin = @import("builtin");
12const std = @import("std");
23const testing = std.testing;
34const expect = testing.expect;
45const expectEqual = testing.expectEqual;
56
67test "tuple concatenation" {
8 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
9
710 const S = struct {
811 fn doTheTest() !void {
912 var a: i32 = 1;
......@@ -20,6 +23,8 @@ test "tuple concatenation" {
2023}
2124
2225test "tuple multiplication" {
26 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
27
2328 const S = struct {
2429 fn doTheTest() !void {
2530 {
......@@ -81,6 +86,8 @@ test "tuple multiplication" {
8186}
8287
8388test "pass tuple to comptime var parameter" {
89 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
90
8491 const S = struct {
8592 fn Foo(comptime args: anytype) !void {
8693 try expect(args[0] == 1);
......@@ -95,6 +102,8 @@ test "pass tuple to comptime var parameter" {
95102}
96103
97104test "tuple initializer for var" {
105 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
106
98107 const S = struct {
99108 fn doTheTest() void {
100109 const Bytes = struct {
......@@ -114,6 +123,8 @@ test "tuple initializer for var" {
114123}
115124
116125test "array-like initializer for tuple types" {
126 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
127
117128 const T = @Type(std.builtin.TypeInfo{
118129 .Struct = std.builtin.TypeInfo.Struct{
119130 .is_tuple = true,
test/behavior/union.zig+1-1
......@@ -362,7 +362,7 @@ pub const FooUnion = union(enum) {
362362var glbl_array: [2]FooUnion = undefined;
363363
364364test "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
367367 glbl_array[1] = FooUnion{ .U1 = 2 };
368368 glbl_array[0] = FooUnion{ .U0 = 1 };
test/behavior/var_args.zig+19
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const expect = @import("std").testing.expect;
23
34fn add(args: anytype) i32 {
......@@ -12,6 +13,8 @@ fn add(args: anytype) i32 {
1213}
1314
1415test "add arbitrary args" {
16 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
17
1518 try expect(add(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);
1619 try expect(add(.{@as(i32, 1234)}) == 1234);
1720 try expect(add(.{}) == 0);
......@@ -22,10 +25,16 @@ fn readFirstVarArg(args: anytype) void {
2225}
2326
2427test "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
2532 readFirstVarArg(.{{}});
2633}
2734
2835test "pass args directly" {
36 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
37
2938 try expect(addSomeStuff(.{ @as(i32, 1), @as(i32, 2), @as(i32, 3), @as(i32, 4) }) == 10);
3039 try expect(addSomeStuff(.{@as(i32, 1234)}) == 1234);
3140 try expect(addSomeStuff(.{}) == 0);
......@@ -36,6 +45,8 @@ fn addSomeStuff(args: anytype) i32 {
3645}
3746
3847test "runtime parameter before var args" {
48 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
49
3950 try expect((try extraFn(10, .{})) == 0);
4051 try expect((try extraFn(10, .{false})) == 1);
4152 try expect((try extraFn(10, .{ false, true })) == 2);
......@@ -73,11 +84,19 @@ fn foo2(args: anytype) bool {
7384}
7485
7586test "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
7691 try expect(foos[0](.{}));
7792 try expect(!foos[1](.{}));
7893}
7994
8095test "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
81100 doNothingWithFirstArg(.{""});
82101}
83102