Skip to content

Commit db2a1c2

Browse files
committed
Add test for complex number printing
1 parent 7f21bff commit db2a1c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/test_print.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,20 @@ for binop in [safe_pow, ^]
3838
minitree = Node(5, Node("x1"), Node("x2"))
3939
@test string_tree(minitree, opts) == "(x1 ^ x2)"
4040
end
41+
42+
@testset "Test printing of complex numbers" begin
43+
@eval my_custom_op(x, y) = x + y
44+
operators = OperatorEnum(;
45+
default_params...,
46+
binary_operators=(+, *, /, -, my_custom_op),
47+
unary_operators=(cos, sin),
48+
)
49+
@extend_operators operators
50+
x1, x2, x3 = [Node(; feature=i) for i in 1:3]
51+
tree = sin(x1 * 1.0)
52+
@test string_tree(tree, operators) == "sin(x1 * 1.0)"
53+
tree = sin(x1 * (1.0 + 2.0im))
54+
@test string_tree(tree, operators) == "sin(x1 * (1.0 + 2.0im))"
55+
tree = my_custom_op(x1, 1.0 + 2.0im)
56+
@test string_tree(tree, operators) == "my_custom_op(x1, 1.0 + 2.0im)"
57+
end

0 commit comments

Comments
 (0)