Skip to content

Commit 1290352

Browse files
test: fix failing CSE test
1 parent 8a87635 commit 1290352

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/cse.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,16 @@ end
142142
@syms a b c d::Array e f
143143
fn = Func([a, DestructuredArgs([b, c])], [], Let([Assignment(d, [a^2 + b^2, b^2 + c^2]), DestructuredArgs([e, f], term(broadcast, *, 2, d))], a^2 + b^2 + e + f))
144144
csex = cse(fn)
145-
@show csex.body.pairs
146-
display(toexpr(csex))
147-
@test length(csex.body.pairs) == 9
148145
sexprs = csex.body.pairs
149146
assignments = filter(x -> x isa Assignment, sexprs)
150-
@test sexprs[6].lhs === d
147+
didx = findfirst(x -> isequal(x.lhs, d), sexprs)
151148
# the array in the assignment should be CSEd
152-
i, j = findfirst.(isequal.(sexprs[6].rhs), (Code.lhs.(assignments),))
149+
i, j = findfirst.(isequal.(sexprs[didx].rhs), (Code.lhs.(assignments),))
153150
@test i !== nothing
154151
@test j !== nothing
155-
@test sexprs[8] isa DestructuredArgs
156-
@test isequal(sexprs[8].name, sexprs[7].lhs)
152+
didx = findfirst(x -> x isa DestructuredArgs, sexprs)
153+
@test sexprs[didx] isa DestructuredArgs
154+
@test findfirst(isequal(sexprs[didx].name), Code.lhs.(assignments)) !== nothing
157155

158156
rgf = @RuntimeGeneratedFunction(toexpr(csex))
159157
trueval = let a = 1,

0 commit comments

Comments
 (0)