1.1 --- a/templates/native/list.c Tue May 21 16:59:25 2024 +0200
1.2 +++ b/templates/native/list.c Tue May 21 17:02:10 2024 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Native functions for list operations.
1.5
1.6 -Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2016, 2017, 2021, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -120,7 +120,7 @@
1.12 __int i = __TOINT(index);
1.13
1.14 /* Set the element. */
1.15 - elements[i] = value;
1.16 + __set_attr(&elements[i], value);
1.17 return __builtins___none_None;
1.18 }
1.19
2.1 --- a/tests/list.py Tue May 21 16:59:25 2024 +0200
2.2 +++ b/tests/list.py Tue May 21 17:02:10 2024 +0200
2.3 @@ -102,3 +102,6 @@
2.4
2.5 e[0] += e[1]
2.6 print e # [3, 1, 3]
2.7 +
2.8 +e[0] += e[1] + e[2]
2.9 +print e # [7, 1, 3]
3.1 --- a/tests/values.py Tue May 21 16:59:25 2024 +0200
3.2 +++ b/tests/values.py Tue May 21 17:02:10 2024 +0200
3.3 @@ -2,6 +2,28 @@
3.4 a = a - 1.0
3.5 return a
3.6
3.7 +def test_assign(l, x):
3.8 + l[0] = x
3.9 +
3.10 +def test_augmented(l, x):
3.11 + l[0] += x + l[1]
3.12 +
3.13 x = 2.0
3.14 print test(x) # 1.0
3.15 print x # 2.0
3.16 +
3.17 +l = [1, 2, 3]
3.18 +test_assign(l, 4)
3.19 +print l # [4, 2, 3]
3.20 +
3.21 +l2 = [1, 2, 3]
3.22 +test_augmented(l2, 1)
3.23 +print l2 # [4, 2, 3]
3.24 +
3.25 +l3 = [1.0, 2.0, 3.0]
3.26 +test_assign(l3, 4.0)
3.27 +print l3 # [4.0, 2.0, 3.0]
3.28 +
3.29 +l4 = [1.0, 2.0, 3.0]
3.30 +test_augmented(l4, 1.0)
3.31 +print l4 # [4.0, 2.0, 3.0]