Skip to content

Commit 0ea6676

Browse files
committed
add test for simple += mutations
1 parent 6cca0f3 commit 0ea6676

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/lang/scope.meson

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ add_test(
130130
endfunc
131131
)
132132

133+
add_test(
134+
'a += b and a = a + b are mutations for container types',
135+
func()
136+
a = [1]
137+
b = [2]
138+
139+
func foo(a list[int], b list[int])
140+
a = a + a
141+
b += b
142+
endfunc
143+
144+
foo(a, b)
145+
146+
assert(a == [1], '`a` should not be mutated, = was used')
147+
assert(b == [2, 2], '`b` should be mutated, += was used')
148+
endfunc
149+
)
150+
133151
foreach t : tests
134152
print(f'---- @0@ ----\n'.format(t.desc))
135153
t.fn()

0 commit comments

Comments
 (0)