diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 09ce660a2fd..85230447148 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | ;;; ANSI 6.1.1.7 Destructuring | 31 | ;;; ANSI 6.1.1.7 Destructuring |
| 32 | (ert-deftest cl-macs-loop-and-assignment () | 32 | (ert-deftest cl-macs-loop-and-assignment () |
| 33 | ;; Bug#6583 | 33 | "Bug#6583" |
| 34 | :expected-result :failed | 34 | :expected-result :failed |
| 35 | (should (equal (cl-loop for numlist in '((1 2 4.0) (5 6 8.3) (8 9 10.4)) | 35 | (should (equal (cl-loop for numlist in '((1 2 4.0) (5 6 8.3) (8 9 10.4)) |
| 36 | for a = (cl-first numlist) | 36 | for a = (cl-first numlist) |
| @@ -61,7 +61,6 @@ | |||
| 61 | ;;; 6.1.2.1.1 The for-as-arithmetic subclause | 61 | ;;; 6.1.2.1.1 The for-as-arithmetic subclause |
| 62 | (ert-deftest cl-macs-loop-for-as-arith () | 62 | (ert-deftest cl-macs-loop-for-as-arith () |
| 63 | "Test various for-as-arithmetic subclauses." | 63 | "Test various for-as-arithmetic subclauses." |
| 64 | :expected-result :failed | ||
| 65 | (should (equal (cl-loop for i to 10 by 3 collect i) | 64 | (should (equal (cl-loop for i to 10 by 3 collect i) |
| 66 | '(0 3 6 9))) | 65 | '(0 3 6 9))) |
| 67 | (should (equal (cl-loop for i upto 3 collect i) | 66 | (should (equal (cl-loop for i upto 3 collect i) |
| @@ -74,9 +73,9 @@ | |||
| 74 | '(10 8 6))) | 73 | '(10 8 6))) |
| 75 | (should (equal (cl-loop for i from 10 downto 1 by 3 collect i) | 74 | (should (equal (cl-loop for i from 10 downto 1 by 3 collect i) |
| 76 | '(10 7 4 1))) | 75 | '(10 7 4 1))) |
| 77 | (should (equal (cl-loop for i above 0 by 2 downfrom 10 collect i) | 76 | (should (equal (cl-loop for i downfrom 10 above 0 by 2 collect i) |
| 78 | '(10 8 6 4 2))) | 77 | '(10 8 6 4 2))) |
| 79 | (should (equal (cl-loop for i downto 10 from 15 collect i) | 78 | (should (equal (cl-loop for i from 15 downto 10 collect i) |
| 80 | '(15 14 13 12 11 10)))) | 79 | '(15 14 13 12 11 10)))) |
| 81 | 80 | ||
| 82 | (ert-deftest cl-macs-loop-for-as-arith-order-side-effects () | 81 | (ert-deftest cl-macs-loop-for-as-arith-order-side-effects () |
| @@ -530,4 +529,65 @@ collection clause." | |||
| 530 | l) | 529 | l) |
| 531 | '(1)))) | 530 | '(1)))) |
| 532 | 531 | ||
| 532 | (ert-deftest cl-macs-loop-conditional-step-clauses () | ||
| 533 | "These tests failed under the initial fixes in #bug#29799." | ||
| 534 | (should (cl-loop for i from 1 upto 100 and j = 1 then (1+ j) | ||
| 535 | if (not (= i j)) | ||
| 536 | return nil | ||
| 537 | end | ||
| 538 | until (> j 10) | ||
| 539 | finally return t)) | ||
| 540 | |||
| 541 | (should (equal (let* ((size 7) | ||
| 542 | (arr (make-vector size 0))) | ||
| 543 | (cl-loop for k below size | ||
| 544 | for x = (* 2 k) and y = (1+ (elt arr k)) | ||
| 545 | collect (list k x y))) | ||
| 546 | '((0 0 1) (1 2 1) (2 4 1) (3 6 1) (4 8 1) (5 10 1) (6 12 1)))) | ||
| 547 | |||
| 548 | (should (equal (cl-loop for x below 3 | ||
| 549 | for y below 2 and z = 1 | ||
| 550 | collect x) | ||
| 551 | '(0 1))) | ||
| 552 | |||
| 553 | (should (equal (cl-loop for x below 3 | ||
| 554 | and y below 2 | ||
| 555 | collect x) | ||
| 556 | '(0 1))) | ||
| 557 | |||
| 558 | ;; this is actually disallowed in clisp, but is semantically consistent | ||
| 559 | (should (equal (cl-loop with result | ||
| 560 | for x below 3 | ||
| 561 | for y = (progn (push x result) x) and z = 1 | ||
| 562 | append (list x y) into result1 | ||
| 563 | finally return (append result result1)) | ||
| 564 | '(2 1 0 0 0 1 1 2 2))) | ||
| 565 | |||
| 566 | (should (equal (cl-loop with result | ||
| 567 | for x below 3 | ||
| 568 | for _y = (progn (push x result)) | ||
| 569 | finally return result) | ||
| 570 | '(2 1 0))) | ||
| 571 | |||
| 572 | ;; this nonintuitive result is replicated by clisp | ||
| 573 | (should (equal (cl-loop with result | ||
| 574 | for x below 3 | ||
| 575 | and y = (progn (push x result)) | ||
| 576 | finally return result) | ||
| 577 | '(2 1 0 0))) | ||
| 578 | |||
| 579 | ;; this nonintuitive result is replicated by clisp | ||
| 580 | (should (equal (cl-loop with result | ||
| 581 | for x below 3 | ||
| 582 | and y = (progn (push x result)) then (progn (push (1+ x) result)) | ||
| 583 | finally return result) | ||
| 584 | '(3 2 1 0))) | ||
| 585 | |||
| 586 | (should (cl-loop with result | ||
| 587 | for x below 3 | ||
| 588 | for y = (progn (push x result) x) then (progn (push (1+ x) result) (1+ x)) | ||
| 589 | and z = 1 | ||
| 590 | collect y into result1 | ||
| 591 | finally return (equal (nreverse result) result1)))) | ||
| 592 | |||
| 533 | ;;; cl-macs-tests.el ends here | 593 | ;;; cl-macs-tests.el ends here |