categorize fn ptr behavior test

move a function pointer test from bugs/xxx.zig to fn.zig
This commit is contained in:
Andrew Kelley 2023-10-27 12:26:18 -07:00
parent dfe9cae4eb
commit 3fb301b16a
3 changed files with 17 additions and 12 deletions

View file

@ -253,7 +253,6 @@ test {
builtin.zig_backend != .stage2_c and
builtin.zig_backend != .stage2_spirv64)
{
_ = @import("behavior/bugs/11227.zig");
_ = @import("behavior/bugs/14198.zig");
_ = @import("behavior/export.zig");
}

View file

@ -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());
}

View file

@ -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());
}