aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bugs
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-02-26 18:06:06 +0200
committerVeikka Tuominen <git@vexu.eu>2022-02-26 18:08:31 +0200
commit315d4e84425ddff888de8d464f657981e4c45da7 (patch)
tree6c5f4bf623b276963cec98ebbf713d2a752e9e01 /test/behavior/bugs
parentff72b8a8194573bc1d7f95cbf3228b363194c775 (diff)
downloadzig-315d4e84425ddff888de8d464f657981e4c45da7.tar.gz
zig-315d4e84425ddff888de8d464f657981e4c45da7.zip
stage2: do not require function when evaluating typeOf
We only care about the instructions type; it will never actually be codegen'd.
Diffstat (limited to 'test/behavior/bugs')
-rw-r--r--test/behavior/bugs/4328.zig23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/behavior/bugs/4328.zig b/test/behavior/bugs/4328.zig
index 26b96d8d6f..cd7386939c 100644
--- a/test/behavior/bugs/4328.zig
+++ b/test/behavior/bugs/4328.zig
@@ -1,4 +1,5 @@
-const expectEqual = @import("std").testing.expectEqual;
+const expect = @import("std").testing.expect;
+const builtin = @import("builtin");
const FILE = extern struct {
dummy_field: u8,
@@ -16,18 +17,20 @@ const S = extern struct {
};
test "Extern function calls in @TypeOf" {
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
+
const Test = struct {
fn test_fn_1(a: anytype, b: anytype) @TypeOf(printf("%d %s\n", a, b)) {
return 0;
}
- fn test_fn_2(a: anytype) @TypeOf((S{ .state = 0 }).s_do_thing(a)) {
+ fn test_fn_2(s: anytype, a: anytype) @TypeOf(s.s_do_thing(a)) {
return 1;
}
fn doTheTest() !void {
- try expectEqual(c_int, @TypeOf(test_fn_1(0, 42)));
- try expectEqual(c_short, @TypeOf(test_fn_2(0)));
+ try expect(@TypeOf(test_fn_1(0, 42)) == c_int);
+ try expect(@TypeOf(test_fn_2(&S{ .state = 1 }, 0)) == c_short);
}
};
@@ -36,13 +39,15 @@ test "Extern function calls in @TypeOf" {
}
test "Peer resolution of extern function calls in @TypeOf" {
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
+
const Test = struct {
fn test_fn() @TypeOf(ftell(null), fputs(null, null)) {
return 0;
}
fn doTheTest() !void {
- try expectEqual(c_long, @TypeOf(test_fn()));
+ try expect(@TypeOf(test_fn()) == c_long);
}
};
@@ -51,6 +56,10 @@ test "Peer resolution of extern function calls in @TypeOf" {
}
test "Extern function calls, dereferences and field access in @TypeOf" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
+
const Test = struct {
fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
_ = a;
@@ -63,8 +72,8 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
}
fn doTheTest() !void {
- try expectEqual(FILE, @TypeOf(test_fn_1(0)));
- try expectEqual(u8, @TypeOf(test_fn_2(0)));
+ try expect(@TypeOf(test_fn_1(0)) == FILE);
+ try expect(@TypeOf(test_fn_2(0)) == u8);
}
};