Skip to content

Commit

Permalink
Added test with typed printing
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeR227 committed Oct 16, 2024
1 parent 7034b18 commit 128c433
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ end
@test_reference "inspect_output/sub14.txt" sprint(io->SymbolicUtils.inspect(io, SymbolicUtils.pluck(ex, 14)))
end

function nameof(::typeof(sq), arg)
let

sq(x) = return SymbolicUtils.Term{Number}(sq, [x])

function Base.nameof(::typeof(sq), arg)
if arg <: Real
return :sqrt_R
elseif arg <: Complex
Expand All @@ -243,6 +247,7 @@ function nameof(::typeof(sq), arg)
return :sqrt
end
end

@testset "call printing" begin
get_print(sym) = begin b = IOBuffer(); print(b, sym); String(take!(b)); end

Expand All @@ -254,8 +259,11 @@ end
@test get_print(g(x,y)) == "g(x, y)"
@test get_print(h(x,y,z)) == "h(x, y, z)"

@nospecialize
sq(x) = return SymbolicUtils.Term{Number}(sq, [x])
@test get_print(sq(x)) == "sqrt_R(x)"
@test get_print(sq(y)) == "sqrt_C(y)"
@test get_print(sq(z)) == "sqrt(z)"
end

end

@testset "maketerm" begin
Expand Down

0 comments on commit 128c433

Please sign in to comment.