Implemented multiple return values
This commit is contained in:
28
tests/programs/return-multi.q
Normal file
28
tests/programs/return-multi.q
Normal file
@ -0,0 +1,28 @@
|
||||
main() {
|
||||
a, b := reverse2(1, 2)
|
||||
assert a == 2
|
||||
assert b == 1
|
||||
|
||||
c, d, e := reverse3(1, 2, 3)
|
||||
assert c == 3
|
||||
assert d == 2
|
||||
assert e == 1
|
||||
|
||||
f, g, h, i := mix4(1, 2, 3, 4)
|
||||
assert f == 4 + 1
|
||||
assert g == 3 + 2
|
||||
assert h == 2 + 3
|
||||
assert i == 1 + 4
|
||||
}
|
||||
|
||||
reverse2(a, b) {
|
||||
return b, a
|
||||
}
|
||||
|
||||
reverse3(a, b, c) {
|
||||
return c, b, a
|
||||
}
|
||||
|
||||
mix4(a, b, c, d) {
|
||||
return d + a, c + b, b + c, a + d
|
||||
}
|
@ -24,6 +24,7 @@ var programs = []struct {
|
||||
{"reassign", "", "", 0},
|
||||
{"reuse", "", "", 0},
|
||||
{"return", "", "", 0},
|
||||
{"return-multi", "", "", 0},
|
||||
{"math", "", "", 0},
|
||||
{"precedence", "", "", 0},
|
||||
{"op-assign", "", "", 0},
|
||||
|
Reference in New Issue
Block a user