Skip to content

Commit 09de190

Browse files
committed
test: for vanilla-@variable syntax with arbitrary length
1 parent 1290985 commit 09de190

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/model_parsing.jl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,34 @@ end
281281

282282
@testset "Arrays using vanilla-@variable syntax" begin
283283
@mtkmodel TupleInArrayDef begin
284+
@structural_parameters begin
285+
N
286+
M
287+
end
284288
@parameters begin
285289
(l(t)[1:2, 1:3] = 1), [description = "l is more than 1D"]
286-
(l2(t)[1:3] = 2), [description = "l2 is 1D"]
287-
(l3(t)[1:3]::Int = 3), [description = "l3 is 1D and has a type"]
290+
(l2(t)[1:N, 1:M] = 2),
291+
[description = "l is more than 1D, with arbitrary length"]
292+
(l3(t)[1:3] = 3), [description = "l2 is 1D"]
293+
(l4(t)[1:N] = 4), [description = "l2 is 1D, with arbitrary length"]
294+
(l5(t)[1:3]::Int = 5), [description = "l3 is 1D and has a type"]
295+
(l6(t)[1:N]::Int = 6),
296+
[description = "l3 is 1D and has a type, with arbitrary length"]
288297
end
289298
end
290299

291-
@named arr = TupleInArrayDef()
300+
N, M = 4, 5
301+
@named arr = TupleInArrayDef(; N, M)
292302
@test getdefault(arr.l) == 1
293303
@test getdefault(arr.l2) == 2
294304
@test getdefault(arr.l3) == 3
305+
@test getdefault(arr.l4) == 4
306+
@test getdefault(arr.l5) == 5
307+
@test getdefault(arr.l6) == 6
308+
309+
@test size(arr.l2) == (N, M)
310+
@test size(arr.l4) == (N,)
311+
@test size(arr.l6) == (N,)
295312
end
296313

297314
@testset "Type annotation" begin

0 commit comments

Comments
 (0)