Skip to content

Commit b11fbec

Browse files
author
Alessandro
committed
add tests
1 parent 4284270 commit b11fbec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/basics.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,22 @@ end
233233
s = SymbolicUtils.maketerm(typeof(a^b), *, [a * b, 3], metadata)
234234
@test hasmetadata(s, Ctx1)
235235
@test getmetadata(s, Ctx1) == "meta_1"
236+
237+
# Correct symtype propagation
238+
ref_expr = a * b
239+
@test symtype(ref_expr) == Number
240+
new_expr = SymbolicUtils.maketerm(typeof(ref_expr), (==), [a, b], nothing)
241+
@test symtype(new_expr) == Bool
242+
243+
# Doesn't know return type, promoted symtype is Any
244+
foo(x,y) = x^2 + x
245+
new_expr = SymbolicUtils.maketerm(typeof(ref_expr), foo, [a, b], nothing)
246+
@test symtype(new_expr) == Number
247+
248+
# Promoted symtype is a subtype of referred
249+
@syms x::Int y::Int
250+
new_expr = SymbolicUtils.maketerm(typeof(ref_expr), (+), [x, y], nothing)
251+
@test symtype(new_expr) == Int64
236252
end
237253

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

0 commit comments

Comments
 (0)