@@ -2,19 +2,18 @@ using TypedCodeUtils
2
2
using Test
3
3
4
4
import TypedCodeUtils: reflect, filter, lookthrough,
5
- DefaultConsumer, Reflection, Callsite,
5
+ DefaultConsumer, Reflection,
6
6
identify_invoke, identify_call,
7
7
process_invoke, process_call
8
8
9
9
# Test simple reflection
10
10
f (x, y) = x + y
11
11
12
- @test reflect (f, Tuple{Int, Int}) != = nothing
13
- @test reflect (f, Tuple{Int, Number}) != = nothing # this probably doesn't do the right thing
14
- # it will give us **a** method instance.
12
+ @test ! isempty (reflect (f, Tuple{Int, Int}))
13
+ @test ! isempty (reflect (f, Tuple{Int, Number}))
15
14
@generated g (x, y) = :(x + y)
16
- @test reflect (g, Tuple{Int, Int}) != = nothing
17
- @test reflect (g, Tuple{Int, Number}) === nothing
15
+ @test ! isempty ( reflect (g, Tuple{Int, Int}))
16
+ @test isempty ( reflect (g, Tuple{Int, Number}))
18
17
19
18
# Cthulhu's inner loop
20
19
function cthulhu (ref:: Reflection )
32
31
33
32
params = TypedCodeUtils. current_params ()
34
33
ref = reflect (f, Tuple{Int, Int}, params= params)
35
- calls = cthulhu (ref)
36
- nextrefs = collect (reflect (c) for c in calls if TypedCodeUtils. canreflect (c))
34
+ @test length (ref) == 1
35
+ calls = cthulhu (first (ref))
36
+ nextrefs = collect (first (reflect (c)) for c in calls if TypedCodeUtils. canreflect (c[2 ]))
37
37
38
38
function h (x)
39
39
if x >= 2
45
45
46
46
params = TypedCodeUtils. current_params ()
47
47
ref = reflect (h, Tuple{Int}, params= params)
48
- calls = cthulhu (ref)
49
- nextrefs = collect (reflect (c) for (id, c) in calls if TypedCodeUtils. canreflect (c))
48
+ @test length (ref) == 1
49
+ calls = cthulhu (first (ref))
50
+ nextrefs = collect (first (reflect (c)) for c in calls if TypedCodeUtils. canreflect (c[2 ]))
50
51
51
52
if VERSION >= v " 1.1.0-DEV.215" && Base. JLOptions (). check_bounds == 0
52
53
Base. @propagate_inbounds function f (x)
@@ -56,6 +57,8 @@ g(x) = @inbounds f(x)
56
57
57
58
params = TypedCodeUtils. current_params ()
58
59
ref = reflect (g, Tuple{Vector{Float64}}, params= params)
60
+ @test length (ref) == 1
61
+ ref = first (ref)
59
62
@show ref. CI. code
60
63
calls = cthulhu (ref)
61
64
@test ! isempty (calls)
0 commit comments