|
1 |
| -module Functions |
2 |
| -using Libtask: produce |
3 |
| -@noinline g3(x) = produce(x) |
4 |
| -@noinline g3(x, y; z) = produce(x + y + z) |
5 |
| -@noinline g3(x, y, z; p, q) = produce(x + y + z + p + q) |
6 |
| -function f3(x) |
7 |
| - g3(x) |
8 |
| - g3(x, 1; z=2) |
9 |
| - return g3(x, 1, 2; p=3, q=4) |
10 |
| -end |
11 |
| -end |
12 |
| - |
13 | 1 | @testset "copyable_task" begin
|
14 | 2 | for case in Libtask.TestUtils.test_cases()
|
15 | 3 | case()
|
@@ -290,16 +278,23 @@ end
|
290 | 278 | @test Libtask.consume(tt) === nothing
|
291 | 279 |
|
292 | 280 | # A function with multiple methods.
|
293 |
| - # Note: f3 and g3 are defined in the module at the top of this file. If |
294 |
| - # they are defined directly in this testset, for reasons that are |
295 |
| - # unclear, the `produce` calls are picked up even without using the |
296 |
| - # `@might_produce` macro, meaning that it's impossible to test that the |
297 |
| - # macro is having the intended behaviour. |
298 |
| - tt = Libtask.TapedTask(nothing, Functions.f3, 0) |
| 281 | + # The function reference is used to ensure that it really doesn't get inlined |
| 282 | + # (otherwise, for reasons that are yet unknown, these functions do get inlined when |
| 283 | + # inside a testset) |
| 284 | + @noinline g3(x) = produce(x) |
| 285 | + @noinline g3(x, y; z) = produce(x + y + z) |
| 286 | + @noinline g3(x, y, z; p, q) = produce(x + y + z + p + q) |
| 287 | + function f3(x, fref) |
| 288 | + fref[](x) |
| 289 | + fref[](x, 1; z=2) |
| 290 | + fref[](x, 1, 2; p=3, q=4) |
| 291 | + return nothing |
| 292 | + end |
| 293 | + tt = Libtask.TapedTask(nothing, f3, 0, Ref(g3)) |
299 | 294 | @test Libtask.consume(tt) === nothing
|
300 | 295 | # Now marking it
|
301 |
| - Libtask.@might_produce(Functions.g3) |
302 |
| - tt = Libtask.TapedTask(nothing, Functions.f3, 0) |
| 296 | + Libtask.@might_produce(g3) |
| 297 | + tt = Libtask.TapedTask(nothing, f3, 0, Ref(g3)) |
303 | 298 | @test Libtask.consume(tt) === 0
|
304 | 299 | @test Libtask.consume(tt) === 3
|
305 | 300 | @test Libtask.consume(tt) === 10
|
|
0 commit comments