|
29 | 29 | @test convert(Dict, Composite{Dict}(Dict(4 => 3))) == Dict(4 => 3) |
30 | 30 | end |
31 | 31 |
|
| 32 | + @testset "==" begin |
| 33 | + @test Composite{Foo}(x=0.1, y=2.5) == Composite{Foo}(x=0.1, y=2.5) |
| 34 | + @test Composite{Foo}(x=0.1, y=2.5) == Composite{Foo}(y=2.5, x=0.1) |
| 35 | + @test Composite{Foo}(y=2.5, x=Zero()) == Composite{Foo}(y=2.5) |
| 36 | + |
| 37 | + @test Composite{Tuple{Float64,}}(2.0) == Composite{Tuple{Float64,}}(2.0) |
| 38 | + @test Composite{Dict}(Dict(4 => 3) == Composite{Dict}(Dict(4 => 3) |
| 39 | + |
| 40 | + end |
| 41 | + |
| 42 | + @testset "hash" begin |
| 43 | + @test hash(Composite{Foo}(x=0.1, y=2.5)) == hash(Composite{Foo}(y=2.5, x=0.1)) |
| 44 | + @test hash(Composite{Foo}(y=2.5, x=Zero())) == hash(Composite{Foo}(y=2.5)) |
| 45 | + end |
| 46 | + |
| 47 | + |
32 | 48 | @testset "indexing, iterating, and properties" begin |
33 | 49 | @test keys(Composite{Foo}(x=2.5)) == (:x,) |
34 | 50 | @test propertynames(Composite{Foo}(x=2.5)) == (:x,) |
|
78 | 94 |
|
79 | 95 | @testset "canonicalize" begin |
80 | 96 | # Testing iterate via collect |
81 | | - @test collect(Composite{Tuple{Float64,}}(2.0)) == [2.0] |
| 97 | + @test ==( |
| 98 | + canonicalize(Composite{Tuple{Float64,}}(2.0)) |
| 99 | + Composite{Tuple{Float64,}}(2.0) |
| 100 | + ) |
| 101 | + |
| 102 | + @test ==( |
| 103 | + canonicalize(Composite{Dict}(Dict(4 => 3)))) |
| 104 | + Composite{Dict}(Dict(4 => 3))) |
| 105 | + ) |
82 | 106 |
|
83 | 107 | # For structure it needs to match order and Zero() fill to match primal |
84 | 108 | CFoo = Composite{Foo} |
|
219 | 243 |
|
220 | 244 | @testset "show" begin |
221 | 245 | @test repr(Composite{Foo}(x=1,)) == "Composite{Foo}(x = 1,)" |
222 | | - # check for exact regex match not occurence( `^...$`) |
| 246 | + # check for exact regex match not occurence( `^...$`) |
223 | 247 | # and allowing optional whitespace (`\s?`) |
224 | 248 | @test occursin( |
225 | 249 | r"^Composite{Tuple{Int64,\s?Int64}}\(1,\s?2\)$", |
|
0 commit comments