Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.

Commit 2e52d4b

Browse files
committed
fix tests
1 parent a16f038 commit 2e52d4b

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/reflection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function reflect(@nospecialize(sig); optimize=true, params=current_params())
5151
methds = Base._methods_by_ftype(sig, -1, params.world)
5252
(methds === false || length(methds) < 1) && return nothing
5353
reflections = Reflection[]
54-
for x = methds[1]
54+
for x in methds
5555
atypes = x[1]
5656
sparams = x[2]
5757
meth = x[3]

test/runtests.jl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ using TypedCodeUtils
22
using Test
33

44
import TypedCodeUtils: reflect, filter, lookthrough,
5-
DefaultConsumer, Reflection, Callsite,
5+
DefaultConsumer, Reflection,
66
identify_invoke, identify_call,
77
process_invoke, process_call
88

99
# Test simple reflection
1010
f(x, y) = x + y
1111

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}))
1514
@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}))
1817

1918
# Cthulhu's inner loop
2019
function cthulhu(ref::Reflection)
@@ -32,8 +31,9 @@ end
3231

3332
params = TypedCodeUtils.current_params()
3433
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]))
3737

3838
function h(x)
3939
if x >= 2
@@ -45,8 +45,9 @@ end
4545

4646
params = TypedCodeUtils.current_params()
4747
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]))
5051

5152
if VERSION >= v"1.1.0-DEV.215" && Base.JLOptions().check_bounds == 0
5253
Base.@propagate_inbounds function f(x)
@@ -56,6 +57,8 @@ g(x) = @inbounds f(x)
5657

5758
params = TypedCodeUtils.current_params()
5859
ref = reflect(g, Tuple{Vector{Float64}}, params=params)
60+
@test length(ref) == 1
61+
ref = first(ref)
5962
@show ref.CI.code
6063
calls = cthulhu(ref)
6164
@test !isempty(calls)

0 commit comments

Comments
 (0)