diff options
Diffstat (limited to 'tests/typ/compiler/ops.typ')
| -rw-r--r-- | tests/typ/compiler/ops.typ | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/typ/compiler/ops.typ b/tests/typ/compiler/ops.typ index a6c64cbd..2bb06e4d 100644 --- a/tests/typ/compiler/ops.typ +++ b/tests/typ/compiler/ops.typ @@ -201,6 +201,48 @@ #(x += "thing") #test(x, "something") --- +// Test destructuring assignments. + +#let a = none +#let b = none +#let c = none +#((a,) = (1,)) +#test(a, 1) + +#((_, a, b, _) = (1, 2, 3, 4)) +#test(a, 2) +#test(b, 3) + +#((a, b, ..c) = (1, 2, 3, 4, 5, 6)) +#test(a, 1) +#test(b, 2) +#test(c, (3, 4, 5, 6)) + +#((a: a, b, x: c) = (a: 1, b: 2, x: 3)) +#test(a, 1) +#test(b, 2) +#test(c, 3) + +#let a = (1, 2) +#((a: a.at(0), b) = (a: 3, b: 4)) +#test(a, (3, 2)) +#test(b, 4) + +#let a = (1, 2) +#((a.at(0), b) = (3, 4)) +#test(a, (3, 2)) +#test(b, 4) + +#((a, ..b) = (1, 2, 3, 4)) +#test(a, 1) +#test(b, (2, 3, 4)) + +#let a = (1, 2) +#((b, ..a.at(0)) = (1, 2, 3, 4)) +#test(a, ((2, 3, 4), 2)) +#test(b, 1) + +--- // Error: 3-6 cannot mutate a constant: box #(box = 1) |
