mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
categorize fn ptr behavior test
move a function pointer test from bugs/xxx.zig to fn.zig
This commit is contained in:
parent
dfe9cae4eb
commit
3fb301b16a
3 changed files with 17 additions and 12 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue