| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | const expectEqual = @import("std").testing.expectEqual; | 1 | const expect = @import("std").testing.expect; |
| | 2 | const builtin = @import("builtin"); |
| 2 | | 3 | |
| 3 | const FILE = extern struct { | 4 | const FILE = extern struct { |
| 4 | dummy_field: u8, | 5 | dummy_field: u8, |
| ... | @@ -16,18 +17,20 @@ const S = extern struct { | ... | @@ -16,18 +17,20 @@ const S = extern struct { |
| 16 | }; | 17 | }; |
| 17 | | 18 | |
| 18 | test "Extern function calls in @TypeOf" { | 19 | test "Extern function calls in @TypeOf" { |
| | 20 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| | 21 | |
| 19 | const Test = struct { | 22 | const Test = struct { |
| 20 | fn test_fn_1(a: anytype, b: anytype) @TypeOf(printf("%d %s\n", a, b)) { | 23 | fn test_fn_1(a: anytype, b: anytype) @TypeOf(printf("%d %s\n", a, b)) { |
| 21 | return 0; | 24 | return 0; |
| 22 | } | 25 | } |
| 23 | | 26 | |
| 24 | fn test_fn_2(a: anytype) @TypeOf((S{ .state = 0 }).s_do_thing(a)) { | 27 | fn test_fn_2(s: anytype, a: anytype) @TypeOf(s.s_do_thing(a)) { |
| 25 | return 1; | 28 | return 1; |
| 26 | } | 29 | } |
| 27 | | 30 | |
| 28 | fn doTheTest() !void { | 31 | fn doTheTest() !void { |
| 29 | try expectEqual(c_int, @TypeOf(test_fn_1(0, 42))); | 32 | try expect(@TypeOf(test_fn_1(0, 42)) == c_int); |
| 30 | try expectEqual(c_short, @TypeOf(test_fn_2(0))); | 33 | try expect(@TypeOf(test_fn_2(&S{ .state = 1 }, 0)) == c_short); |
| 31 | } | 34 | } |
| 32 | }; | 35 | }; |
| 33 | | 36 | |
| ... | @@ -36,13 +39,15 @@ test "Extern function calls in @TypeOf" { | ... | @@ -36,13 +39,15 @@ test "Extern function calls in @TypeOf" { |
| 36 | } | 39 | } |
| 37 | | 40 | |
| 38 | test "Peer resolution of extern function calls in @TypeOf" { | 41 | test "Peer resolution of extern function calls in @TypeOf" { |
| | 42 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| | 43 | |
| 39 | const Test = struct { | 44 | const Test = struct { |
| 40 | fn test_fn() @TypeOf(ftell(null), fputs(null, null)) { | 45 | fn test_fn() @TypeOf(ftell(null), fputs(null, null)) { |
| 41 | return 0; | 46 | return 0; |
| 42 | } | 47 | } |
| 43 | | 48 | |
| 44 | fn doTheTest() !void { | 49 | fn doTheTest() !void { |
| 45 | try expectEqual(c_long, @TypeOf(test_fn())); | 50 | try expect(@TypeOf(test_fn()) == c_long); |
| 46 | } | 51 | } |
| 47 | }; | 52 | }; |
| 48 | | 53 | |
| ... | @@ -51,6 +56,10 @@ test "Peer resolution of extern function calls in @TypeOf" { | ... | @@ -51,6 +56,10 @@ test "Peer resolution of extern function calls in @TypeOf" { |
| 51 | } | 56 | } |
| 52 | | 57 | |
| 53 | test "Extern function calls, dereferences and field access in @TypeOf" { | 58 | test "Extern function calls, dereferences and field access in @TypeOf" { |
| | 59 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| | 60 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 61 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| | 62 | |
| 54 | const Test = struct { | 63 | const Test = struct { |
| 55 | fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) { | 64 | fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) { |
| 56 | _ = a; | 65 | _ = a; |
| ... | @@ -63,8 +72,8 @@ test "Extern function calls, dereferences and field access in @TypeOf" { | ... | @@ -63,8 +72,8 @@ test "Extern function calls, dereferences and field access in @TypeOf" { |
| 63 | } | 72 | } |
| 64 | | 73 | |
| 65 | fn doTheTest() !void { | 74 | fn doTheTest() !void { |
| 66 | try expectEqual(FILE, @TypeOf(test_fn_1(0))); | 75 | try expect(@TypeOf(test_fn_1(0)) == FILE); |
| 67 | try expectEqual(u8, @TypeOf(test_fn_2(0))); | 76 | try expect(@TypeOf(test_fn_2(0)) == u8); |
| 68 | } | 77 | } |
| 69 | }; | 78 | }; |
| 70 | | 79 | |