Commit 5e56afca authored by Daniel Kochmański's avatar Daniel Kochmański
Browse files

loop8: add a test for destructuring bind Destructuring states

    Destructuring allows binding of a set of variables to a corresponding set
    of values anywhere that a value can normally be bound to a single
    variable. During loop expansion, each variable in the variable list is
    matched with the values in the values list. If there are more variables in
    the variable list than there are values in the values list, the remaining
    variables are given a value of nil. If there are more values than
    variables listed, the extra values are discarded.

These tests check, whether loop accepts destructuring bindings where there is
less values than variables.
parent c4679fdd
......@@ -125,6 +125,20 @@
(loop with x = (expand-in-current-env (%m 1)) do (return x)))
;;; Test that the variable list may be shorter than values list.
(deftest loop.8.25
(loop with (a b) = '(1)
for (c d) = '(2)
do (return (values a b c d)))
1 nil 2 nil)
(deftest loop.8.26
(loop with (a b . rest) = '(1)
for (c d) = '(2)
do (return (values a b c d rest)))
1 nil 2 nil nil)
;;; Error cases
;;; The spec says (in section that:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment