| author | |
| committer | |
| log | 3fb301b16a51504bea1aa89efe856a2c2df6f293 |
| tree | 5a870e2d4de60466cbd1278627605257a1296c41 |
| parent | dfe9cae4eb9ebd1409759f82a6f7ab9336a6da6b |
move a function pointer test from bugs/xxx.zig to fn.zig3 files changed, 17 insertions(+), 12 deletions(-)
test/behavior.zig-1| ... | ... | @@ -253,7 +253,6 @@ test { |
| 253 | 253 | builtin.zig_backend != .stage2_c and |
| 254 | 254 | builtin.zig_backend != .stage2_spirv64) |
| 255 | 255 | { |
| 256 | _ = @import("behavior/bugs/11227.zig"); | |
| 257 | 256 | _ = @import("behavior/bugs/14198.zig"); |
| 258 | 257 | _ = @import("behavior/export.zig"); |
| 259 | 258 | } |
test/behavior/bugs/11227.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | ||
| 4 | fn foo() u32 { | |
| 5 | return 11227; | |
| 6 | } | |
| 7 | const bar = foo; | |
| 8 | test "pointer to alias behaves same as pointer to function" { | |
| 9 | var a = &bar; | |
| 10 | try std.testing.expect(foo() == a()); | |
| 11 | } |
test/behavior/fn.zig+17| ... | ... | @@ -574,3 +574,20 @@ test "pass and return comptime-only types" { |
| 574 | 574 | try expectEqual(null, S.returnNull(null)); |
| 575 | 575 | try expectEqual(@as(u0, 0), S.returnUndefined(undefined)); |
| 576 | 576 | } |
| 577 | ||
| 578 | test "pointer to alias behaves same as pointer to function" { | |
| 579 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | |
| 580 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 581 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | |
| 582 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; | |
| 583 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | |
| 584 | ||
| 585 | const S = struct { | |
| 586 | fn foo() u32 { | |
| 587 | return 11227; | |
| 588 | } | |
| 589 | const bar = foo; | |
| 590 | }; | |
| 591 | var a = &S.bar; | |
| 592 | try std.testing.expect(S.foo() == a()); | |
| 593 | } |