From ef4f1305149f8f2e9fa7dfee8721b144abfe756c Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Mon, 19 Feb 2024 19:29:49 +0100 Subject: [PATCH] test `symstruct` --- test/struct.jl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/struct.jl b/test/struct.jl index adfeb1ee7..1bc337732 100644 --- a/test/struct.jl +++ b/test/struct.jl @@ -23,17 +23,19 @@ struct Fisk end a = StructElement(Int8, :a) b = StructElement(Int, :b) +for s in [Struct(Fisk, [a, b]), symstruct(Fisk)] + sa = s.a + sb = s.b + @test operation(sa) === getfield + @test arguments(sa) == Any[s, 1] + @test arguments(sa) isa Any + @test operation(sb) === getfield + @test arguments(sb) == Any[s, 2] + @test arguments(sb) isa Any + @test juliatype(s) == Fisk +end + s = Struct(Fisk, [a, b]) -sa = s.a -sb = s.b -@test operation(sa) === getfield -@test arguments(sa) == Any[s, 1] -@test arguments(sa) isa Any -@test operation(sb) === getfield -@test arguments(sb) == Any[s, 2] -@test arguments(sb) isa Any -@test juliatype(s) == Fisk -@test symstruct(Fisk) == s sa1 = (setproperty!(s, :a, UInt8(1))) @test operation(sa1) === setfield! @@ -52,4 +54,4 @@ end ss = symstruct(Jörgen) -@test getfield(ss, :v) == [StructElement(Int, :a), StructElement(Float64, :b)] \ No newline at end of file +@test getfield(ss, :v) == [StructElement(Int, :a), StructElement(Float64, :b)]