Skip to content

Commit 37bab5c

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

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

test/model_parsing.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,32 @@ 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), [description = "l is more than 1D, with arbitrary length"]
291+
(l3(t)[1:3] = 3), [description = "l2 is 1D"]
292+
(l4(t)[1:N] = 4), [description = "l2 is 1D, with arbitrary length"]
293+
(l5(t)[1:3]::Int = 5), [description = "l3 is 1D and has a type"]
294+
(l6(t)[1:N]::Int = 6), [description = "l3 is 1D and has a type, with arbitrary length"]
288295
end
289296
end
290297

291-
@named arr = TupleInArrayDef()
298+
N, M = 4, 5
299+
@named arr = TupleInArrayDef(; N, M)
292300
@test getdefault(arr.l) == 1
293301
@test getdefault(arr.l2) == 2
294302
@test getdefault(arr.l3) == 3
303+
@test getdefault(arr.l4) == 4
304+
@test getdefault(arr.l5) == 5
305+
@test getdefault(arr.l6) == 6
306+
307+
@test size(arr.l2) == (N, M)
308+
@test size(arr.l4) == (N,)
309+
@test size(arr.l6) == (N,)
295310
end
296311

297312
@testset "Type annotation" begin

0 commit comments

Comments
 (0)