aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-10-27 12:26:18 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-10-27 12:43:34 -0700
commit3fb301b16a51504bea1aa89efe856a2c2df6f293 (patch)
tree5a870e2d4de60466cbd1278627605257a1296c41 /test/behavior
parentdfe9cae4eb9ebd1409759f82a6f7ab9336a6da6b (diff)
downloadzig-3fb301b16a51504bea1aa89efe856a2c2df6f293.tar.gz
zig-3fb301b16a51504bea1aa89efe856a2c2df6f293.zip
categorize fn ptr behavior test
move a function pointer test from bugs/xxx.zig to fn.zig
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/bugs/11227.zig11
-rw-r--r--test/behavior/fn.zig17
2 files changed, 17 insertions, 11 deletions
diff --git a/test/behavior/bugs/11227.zig b/test/behavior/bugs/11227.zig
deleted file mode 100644
index b65a64c69c..0000000000
--- a/test/behavior/bugs/11227.zig
+++ /dev/null
@@ -1,11 +0,0 @@
-const std = @import("std");
-const builtin = @import("builtin");
-
-fn foo() u32 {
- return 11227;
-}
-const bar = foo;
-test "pointer to alias behaves same as pointer to function" {
- var a = &bar;
- try std.testing.expect(foo() == a());
-}
diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig
index 859be1efda..3792087426 100644
--- a/test/behavior/fn.zig
+++ b/test/behavior/fn.zig
@@ -574,3 +574,20 @@ test "pass and return comptime-only types" {
try expectEqual(null, S.returnNull(null));
try expectEqual(@as(u0, 0), S.returnUndefined(undefined));
}
+
+test "pointer to alias behaves same as pointer to function" {
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
+
+ const S = struct {
+ fn foo() u32 {
+ return 11227;
+ }
+ const bar = foo;
+ };
+ var a = &S.bar;
+ try std.testing.expect(S.foo() == a());
+}