From b11fbec6bfc3a9569c5459c0867a390b40ad9f83 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Sat, 27 Jul 2024 16:56:22 +0200 Subject: [PATCH] add tests --- test/basics.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/basics.jl b/test/basics.jl index 73d398cdd..e59b008e3 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -233,6 +233,22 @@ end s = SymbolicUtils.maketerm(typeof(a^b), *, [a * b, 3], metadata) @test hasmetadata(s, Ctx1) @test getmetadata(s, Ctx1) == "meta_1" + + # Correct symtype propagation + ref_expr = a * b + @test symtype(ref_expr) == Number + new_expr = SymbolicUtils.maketerm(typeof(ref_expr), (==), [a, b], nothing) + @test symtype(new_expr) == Bool + + # Doesn't know return type, promoted symtype is Any + foo(x,y) = x^2 + x + new_expr = SymbolicUtils.maketerm(typeof(ref_expr), foo, [a, b], nothing) + @test symtype(new_expr) == Number + + # Promoted symtype is a subtype of referred + @syms x::Int y::Int + new_expr = SymbolicUtils.maketerm(typeof(ref_expr), (+), [x, y], nothing) + @test symtype(new_expr) == Int64 end toterm(t) = Term{symtype(t)}(operation(t), arguments(t))