Skip to content

Commit b6a8946

Browse files
committed
Test if similarterm is consistent with BasicSymbolic arithmetic ops
1 parent ef00c1c commit b6a8946

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/basics.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ end
191191
@syms a b c
192192
@test isequal(SymbolicUtils.similarterm((b + c), +, [a, (b+c)]).dict, Dict(a=>1,b=>1,c=>1))
193193
@test isequal(SymbolicUtils.similarterm(b^2, ^, [b^2, 1//2]), b)
194+
195+
# test that similarterm doesn't hard-code BasicSymbolic subtype
196+
# and is consistent with BasicSymbolic arithmetic operations
197+
@test isequal(SymbolicUtils.similarterm(a / b, *, [a / b, c]), (a / b) * c)
198+
@test isequal(SymbolicUtils.similarterm(a * b, *, [0, c]), 0)
199+
@test isequal(SymbolicUtils.similarterm(a^b, ^, [a * b, 3]), (a * b)^3)
194200
end
195201

196202
toterm(t) = Term{symtype(t)}(operation(t), arguments(t))

0 commit comments

Comments
 (0)