Add a test for chained assignments
This commit is contained in:
parent
0267faede3
commit
7c5465d266
2 changed files with 63 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ functionaltest("type")
|
|||
functionaltest("if")
|
||||
functionaltest("while")
|
||||
functionaltest("eq")
|
||||
functionaltest("chained-assignments")
|
||||
|
||||
install(TARGETS apfl DESTINATION lib)
|
||||
install(TARGETS apfl-bin DESTINATION bin)
|
||||
|
|
|
|||
62
src/functional-tests/chained-assignments.at
Normal file
62
src/functional-tests/chained-assignments.at
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
===== script =====
|
||||
# Simple chained assignment
|
||||
a = b = "foo"
|
||||
print a
|
||||
print b
|
||||
|
||||
print ""
|
||||
|
||||
# Check return value of chained assignment. Also does local assignment `:=` work?
|
||||
print ({
|
||||
a = b := "bar"
|
||||
})
|
||||
print a
|
||||
print b
|
||||
|
||||
print ""
|
||||
|
||||
# Throw a list matching in there
|
||||
l = [x y] = [1 2]
|
||||
print l
|
||||
print x
|
||||
print y
|
||||
|
||||
print ""
|
||||
|
||||
# Same as first two tests, but force using the matcher mechanism
|
||||
|
||||
[a] = [b] = ["foo"]
|
||||
print a
|
||||
print b
|
||||
|
||||
print ""
|
||||
|
||||
print ({
|
||||
[a] = [b] := ["bar"]
|
||||
})
|
||||
print a
|
||||
print b
|
||||
|
||||
===== output =====
|
||||
foo
|
||||
foo
|
||||
|
||||
bar
|
||||
bar
|
||||
foo
|
||||
|
||||
[
|
||||
1
|
||||
2
|
||||
]
|
||||
1
|
||||
2
|
||||
|
||||
foo
|
||||
foo
|
||||
|
||||
[
|
||||
"bar"
|
||||
]
|
||||
bar
|
||||
foo
|
||||
Loading…
Reference in a new issue