Skip to content

Commit eaf4446

Browse files
committed
Add tests for CSE DAG
1 parent b38a2a6 commit eaf4446

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/cse.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ end
1616
expr = sin(a + b) * (a + b)
1717
sorted_nodes = topological_sort(expr)
1818
@test length(sorted_nodes) == 3
19+
@test isequal(sorted_nodes[1].rhs, a + b)
20+
@test isequal(sin(sorted_nodes[1].lhs), sorted_nodes[2].rhs)
1921
expr = (a + b)^(a + b)
2022
sorted_nodes = topological_sort(expr)
2123
@test length(sorted_nodes) == 2
24+
@test isequal(sorted_nodes[1].rhs, a + b)
25+
ab_node = sorted_nodes[1].lhs
26+
@test isequal(ab_node^ab_node, sorted_nodes[2].rhs)
2227
end

0 commit comments

Comments
 (0)