diff --git a/loopy-misc.el b/loopy-misc.el index 4eab4aed..632b46ac 100644 --- a/loopy-misc.el +++ b/loopy-misc.el @@ -146,15 +146,15 @@ 'loopy-bad-desctructuring) (define-error 'loopy-&optional-generalized-variable - "Loopy: `&optional' variables are not `setf'-able" + "Loopy: `&optional' variables not implemented for generalized variables" 'loopy-bad-destructuring) (define-error 'loopy-generalized-default - "Loopy: Default values don't make sense for generalized variables" + "Loopy: Default values not implemented for generalized variables" 'loopy-bad-destructuring) (define-error 'loopy-generalized-supplied - "Loopy: `SUPPLIED-P' variables are not supported for generalized variables" + "Loopy: `SUPPLIED-P' variables not implemented for generalized variables" 'loopy-bad-destructuring) (define-error 'loopy-&rest-multiple diff --git a/tests/misc-tests.el b/tests/misc-tests.el index c9042607..0145a7a8 100644 --- a/tests/misc-tests.el +++ b/tests/misc-tests.el @@ -401,6 +401,16 @@ INPUT is the destructuring usage. OUTPUT-PATTERN is what to match." whole (mapcar #'1+ whole))) l)))))) +(ert-deftest generalized-array-should-error () + (should-error (loopy--destructure-generalized-array [a b &optional c] 'val) + :type 'loopy-&optional-generalized-variable) + + (should-error (loopy--destructure-generalized-array [a b &map ('c c 27)] 'val) + :type 'loopy-generalized-default) + + (should-error (loopy--destructure-generalized-array [a b &map ('c c nil c-supp)] 'val) + :type 'loopy-generalized-supplied)) + (ert-deftest destructure-array-refs () (should (equal [1 2 3] (let ((arr [7 7 7])) @@ -442,6 +452,13 @@ INPUT is the destructuring usage. OUTPUT-PATTERN is what to match." (setf a 1 b 2 c 3 d [4])) arr))) + (should (equal [1 2 3 4 7 0 0 16] + (let ((arr (vector 7 7 7 7 0 0 6))) + (loopy-ref (([a b c &rest d &map (6 idx-6)] arr)) + (setf a 1 b 2 c 3 d [4]) + (cl-incf idx-6 10)) + arr))) + (should (equal [2 3] (let ((arr [7 7])) (loopy-ref (([&whole cat a b] arr))