File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 18
18
@test length (sorted_nodes) == 3
19
19
@test isequal (sorted_nodes[1 ]. rhs, a + b)
20
20
@test isequal (sin (sorted_nodes[1 ]. lhs), sorted_nodes[2 ]. rhs)
21
+
21
22
expr = (a + b)^ (a + b)
22
23
sorted_nodes = topological_sort (expr)
23
24
@test length (sorted_nodes) == 2
24
25
@test isequal (sorted_nodes[1 ]. rhs, a + b)
25
26
ab_node = sorted_nodes[1 ]. lhs
26
27
@test isequal (ab_node^ ab_node, sorted_nodes[2 ]. rhs)
28
+ let_expr = cse (expr)
29
+ @test length (let_expr. pairs) == 1
30
+ @test isequal (let_expr. pairs[1 ]. rhs, a + b)
31
+ corresponding_sym = let_expr. pairs[1 ]. lhs
32
+ @test isequal (let_expr. body, corresponding_sym^ corresponding_sym)
33
+
34
+ expr = a + b
35
+ sorted_nodes = topological_sort (expr)
36
+ @test length (sorted_nodes) == 1
37
+ @test isequal (sorted_nodes[1 ]. rhs, a + b)
38
+ let_expr = cse (expr)
39
+ @test isempty (let_expr. pairs)
40
+ @test isequal (let_expr. body, a + b)
41
+
42
+ expr = a
43
+ sorted_nodes = topological_sort (expr)
44
+ @test isempty (sorted_nodes)
45
+ let_expr = cse (expr)
46
+ @test isempty (let_expr. pairs)
47
+ @test isequal (let_expr. body, a)
27
48
end
You can’t perform that action at this time.
0 commit comments