Skip to content

Commit

Permalink
test: add tests for passing array of symbolics to registered functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jul 29, 2024
1 parent 0ccca65 commit 550b1c4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ let
@test eltype(gg) == Real
@test symtype(unwrap(gg)) == SymMatrix{Real, 2}
@test promote_symtype(ggg, symtype(unwrap(x))) == Any # no promote_symtype defined

gg = ggg([a, 2a])
@test ndims(gg) == 2
@test size(gg) == (4, 4)
@test eltype(gg) == Real
@test symtype(unwrap(gg)) == SymMatrix{Real, 2}
@test promote_symtype(ggg, Vector{symtype(typeof(a))}) == Any
end
let
# redefine with promote_symtype
Expand Down Expand Up @@ -64,6 +71,12 @@ hh = ccwa(gg, x)
@test eltype(hh) == Real
@test isequal(arguments(unwrap(hh)), unwrap.([gg, x]))

_args = [[a 2a; 4a 6a; 3a 5a], [4a, 6a]]
hh = ccwa(_args...)
@test size(hh) == (3, 2, 10)
@test eltype(hh) == Real
@test isequal(arguments(unwrap(hh)), unwrap.(_args))

@test all(t->getsource(t)[1] === :variables, many_vars)
@test getdefaultval(t) == 0
@test getdefaultval(a) == 1
Expand Down Expand Up @@ -218,3 +231,10 @@ yyy = yy(t)
@test !isequal(yyy, y)
@variables y(..)
@test isequal(yyy, y(t))

spam(x) = 2x
@register_symbolic spam(x::AbstractArray)

sym = spam([a, 2a])
@test sym isa Num
@test unwrap(sym) isa BasicSymbolic{Real}

0 comments on commit 550b1c4

Please sign in to comment.