diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42c2bb6..87ccecd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/functional-tests/chained-assignments.at b/src/functional-tests/chained-assignments.at new file mode 100644 index 0000000..282f798 --- /dev/null +++ b/src/functional-tests/chained-assignments.at @@ -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