|
| 1 | +using SymbolicIndexingInterface |
| 2 | +using StaticArrays |
| 3 | + |
| 4 | +sys = SymbolCache([:x, :y, :z], [:a, :b, :c], :t) |
| 5 | + |
| 6 | +for (buf, newbuf, newvals) in [ |
| 7 | + # standard operation |
| 8 | + ([1.0, 2.0, 3.0], [2.0, 3.0, 4.0], |
| 9 | + Dict(:x => 2.0, :y => 3.0, :z => 4.0)) |
| 10 | + # type "demotion" |
| 11 | + ([1.0, 2.0, 3.0], [2, 3, 4], |
| 12 | + Dict(:x => 2, :y => 3, :z => 4)) |
| 13 | + # type promotion |
| 14 | + ([1, 2, 3], [2.0, 3.0, 4.0], |
| 15 | + Dict(:x => 2.0, :y => 3.0, :z => 4.0)) |
| 16 | + # union |
| 17 | + ([1, 2, 3], Union{Int, Float64}[2, 3.0, 4.0], |
| 18 | + Dict(:x => 2, :y => 3.0, :z => 4.0)) |
| 19 | + # standard operation |
| 20 | + ([1.0, 2.0, 3.0], [2.0, 3.0, 4.0], |
| 21 | + Dict(:a => 2.0, :b => 3.0, :c => 4.0)) |
| 22 | + # type "demotion" |
| 23 | + ([1.0, 2.0, 3.0], [2, 3, 4], |
| 24 | + Dict(:a => 2, :b => 3, :c => 4)) |
| 25 | + # type promotion |
| 26 | + ([1, 2, 3], [2.0, 3.0, 4.0], |
| 27 | + Dict(:a => 2.0, :b => 3.0, :c => 4.0)) |
| 28 | + # union |
| 29 | + ([1, 2, 3], Union{Int, Float64}[2, 3.0, 4.0], |
| 30 | + Dict(:a => 2, :b => 3.0, :c => 4.0))] |
| 31 | + for arrType in [Vector, SVector{3}, MVector{3}, SizedVector{3}] |
| 32 | + buf = arrType(buf) |
| 33 | + newbuf = arrType(newbuf) |
| 34 | + _newbuf = remake_buffer(sys, buf, newvals) |
| 35 | + |
| 36 | + @test _newbuf != buf # should not alias |
| 37 | + @test newbuf == _newbuf # test values |
| 38 | + @test typeof(newbuf) == typeof(_newbuf) # ensure appropriate type |
| 39 | + end |
| 40 | +end |
0 commit comments