@@ -19,6 +19,23 @@ func TestForEach(t *testing.T) {
1919
2020 is .Equal (results , []int {2 , 4 })
2121
22+ toModify := []int {1 , 2 , 3 }
23+ ForEach (toModify , func (x * int ) { * x = * x * 2 })
24+
25+ is .Equal (toModify , []int {2 , 4 , 6 })
26+
27+ toModify = []int {}
28+ ForEach (toModify , func (x * int ) {})
29+
30+ is .Equal (toModify , []int {})
31+
32+ strModify := []string {"a" , "b" }
33+ ForEach (strModify , func (s * string ) {
34+ * s = * s + * s
35+ })
36+
37+ is .Equal (strModify , []string {"aa" , "bb" })
38+
2239 mapping := map [int ]string {
2340 1 : "Florent" ,
2441 2 : "Gilles" ,
@@ -40,6 +57,23 @@ func TestForEachRight(t *testing.T) {
4057
4158 is .Equal (results , []int {8 , 6 , 4 , 2 })
4259
60+ toModify := []int {1 , 2 , 3 }
61+ ForEach (toModify , func (x * int ) { * x = * x * 2 })
62+
63+ is .Equal (toModify , []int {2 , 4 , 6 })
64+
65+ toModify = []int {}
66+ ForEach (toModify , func (x * int ) {})
67+
68+ is .Equal (toModify , []int {})
69+
70+ strModify := []string {"a" , "b" }
71+ ForEach (strModify , func (s * string ) {
72+ * s = * s + * s
73+ })
74+
75+ is .Equal (strModify , []string {"aa" , "bb" })
76+
4377 mapping := map [int ]string {
4478 1 : "Florent" ,
4579 2 : "Gilles" ,
0 commit comments