Skip to content

Commit

Permalink
add test for nested CSE
Browse files Browse the repository at this point in the history
  • Loading branch information
spcornelius committed May 3, 2024
1 parent 0d8eccf commit 07fdc5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/cse.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using SymbolicUtils, SymbolicUtils.Code, Test
@testset "CSE" begin
@syms x
@syms x y
t = cse(hypot(hypot(cos(x), sin(x)), atan(cos(x), sin(x))))

@test t isa Let
@test length(t.pairs) == 2
@test occursin(t.pairs[1].lhs, t.body)
@test occursin(t.pairs[2].lhs, t.body)

t = cse((x*y) + sin(x*y) + sqrt(sin(x*y)))

@test t isa Let
@test length(t.pairs) == 2
@test !occursin(x*y, t.pairs[2].rhs)
end

0 comments on commit 07fdc5f

Please sign in to comment.