Skip to content

Commit

Permalink
Add a constructor test
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Mar 11, 2024
1 parent acec4bc commit db932e4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/struct.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Test, Symbolics
using Symbolics: Struct, juliatype, symbolic_getproperty, symbolic_setproperty!
using Symbolics: symstruct, juliatype, symbolic_getproperty, symbolic_setproperty!, symbolic_constructor

struct Jörgen
a::Int
b::Float64
end

S = Struct(Jörgen)
S = symstruct(Jörgen)
@variables x::S
xa = Symbolics.unwrap(symbolic_getproperty(x, :a))
@test Symbolics.symtype(xa) == Int
Expand All @@ -21,3 +21,6 @@ xb = Symbolics.unwrap(symbolic_setproperty!(x, :b, 10))
@test Symbolics.operation(xb) == setfield!
@test isequal(Symbolics.arguments(xb), [Symbolics.unwrap(x), Meta.quot(:b), 10])
@test Symbolics.symtype(xb) == Float64

s = Symbolics.symbolic_constructor(S, 1, 1.0)
@test Symbolics.symtype(s) == S

0 comments on commit db932e4

Please sign in to comment.