| 1 | fn cross_assign_anon_fn_one(a int, b bool) string { |
| 2 | return 'one' |
| 3 | } |
| 4 | |
| 5 | fn cross_assign_anon_fn_two(a int, b bool) string { |
| 6 | return 'two' |
| 7 | } |
| 8 | |
| 9 | fn cross_assign_anon_fn_three() (string, string) { |
| 10 | return 'three', 'three' |
| 11 | } |
| 12 | |
| 13 | fn cross_assign_anon_fn_four() (string, string) { |
| 14 | return 'four', 'four' |
| 15 | } |
| 16 | |
| 17 | fn cross_assign_anon_fn_five(a ...int) string { |
| 18 | return 'five' |
| 19 | } |
| 20 | |
| 21 | fn cross_assign_anon_fn_six(a ...int) string { |
| 22 | return 'six' |
| 23 | } |
| 24 | |
| 25 | fn cross_assign_anon_fn_seven(a int, b bool) string { |
| 26 | return 'seven' |
| 27 | } |
| 28 | |
| 29 | fn cross_assign_anon_fn_eight(a int, b bool) string { |
| 30 | return 'eight' |
| 31 | } |
| 32 | |
| 33 | fn test_cross_assign_anon_fn() { |
| 34 | mut one := cross_assign_anon_fn_one |
| 35 | mut two := cross_assign_anon_fn_two |
| 36 | one, two = two, one |
| 37 | foo := two(0, true) + one(0, true) |
| 38 | assert foo == 'onetwo' |
| 39 | |
| 40 | mut three := cross_assign_anon_fn_three |
| 41 | mut four := cross_assign_anon_fn_four |
| 42 | three, four = four, three |
| 43 | mut foo2, mut foo3 := four() |
| 44 | foo4, foo5 := three() |
| 45 | foo2 += foo4 |
| 46 | foo3 += foo5 |
| 47 | assert foo2 == 'threefour' |
| 48 | assert foo3 == 'threefour' |
| 49 | |
| 50 | mut five := cross_assign_anon_fn_five |
| 51 | mut six := cross_assign_anon_fn_six |
| 52 | five, six = six, five |
| 53 | foo6 := six(1, 2, 3) + five(1, 2, 3) |
| 54 | assert foo6 == 'fivesix' |
| 55 | |
| 56 | one, two, three, four, five, six = two, one, four, three, six, five |
| 57 | mut foo7, _ := three() |
| 58 | foo8, _ := four() |
| 59 | foo7 += foo8 |
| 60 | foo9 := one(0, true) + two(0, true) + foo7 + five(1, 2, 3) + six(1, 2, 3) |
| 61 | assert foo9 == 'onetwothreefourfivesix' |
| 62 | |
| 63 | mut seven := cross_assign_anon_fn_seven |
| 64 | mut eight := cross_assign_anon_fn_eight |
| 65 | one, two, seven, eight = two, seven, eight, one |
| 66 | foo10 := one(0, true) + two(0, true) + seven(0, true) + eight(0, true) |
| 67 | assert foo10 == 'twoseveneightone' |
| 68 | } |
| 69 | |