| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const expect = std.testing.expect; | 2 | const expect = std.testing.expect; |
| | 3 | const expectEqual = std.testing.expectEqual; |
| 3 | | 4 | |
| 4 | test "basic invocations" { | 5 | test "basic invocations" { |
| 5 | const foo = struct { | 6 | const foo = struct { |
| ... | @@ -53,3 +54,21 @@ test "tuple parameters" { | ... | @@ -53,3 +54,21 @@ test "tuple parameters" { |
| 53 | expect(@call(.{ .modifier = .always_inline }, add, separate_args3) == 46); | 54 | expect(@call(.{ .modifier = .always_inline }, add, separate_args3) == 46); |
| 54 | } | 55 | } |
| 55 | } | 56 | } |
| | 57 | |
| | 58 | test "comptime call with bound function as parameter" { |
| | 59 | const S = struct { |
| | 60 | fn ReturnType(func: var) type { |
| | 61 | return switch (@typeInfo(@TypeOf(func))) { |
| | 62 | .BoundFn => |info| info, |
| | 63 | else => unreachable, |
| | 64 | }.return_type orelse void; |
| | 65 | } |
| | 66 | |
| | 67 | fn call_me_maybe() ?i32 { |
| | 68 | return 123; |
| | 69 | } |
| | 70 | }; |
| | 71 | |
| | 72 | var inst: S = undefined; |
| | 73 | expectEqual(?i32, S.ReturnType(inst.call_me_maybe)); |
| | 74 | } |