From 6f73c465a8990560fedb1c9897c893056b4b04ef Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 17 Mar 2015 14:30:42 -0400 Subject: * cl-macs.el (cl--transform-lambda): Refine last change. Fixes: debbugs:20125 * test/automated/cl-lib-tests.el: Use lexical-binding. (cl-lib-arglist-performance): Refine test to the case where one of the fields has a non-nil default value. Use existing `mystruct' defstruct. (cl-lib-struct-accessors): Use `pcase' to be a bit more flexible in the accepted outputs. --- test/ChangeLog | 20 ++++++++++++++------ test/automated/cl-lib-tests.el | 30 ++++++++++++++++-------------- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'test') diff --git a/test/ChangeLog b/test/ChangeLog index a7d1dfdceae..e150aba2874 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,7 +1,15 @@ +2015-03-17 Stefan Monnier + + * automated/cl-lib-tests.el: Use lexical-binding. + (cl-lib-arglist-performance): Refine test to the case where one of the + fields has a non-nil default value. Use existing `mystruct' defstruct. + (cl-lib-struct-accessors): Use `pcase' to be a bit more flexible in the + accepted outputs. + 2015-03-16 Ken Brown - * automated/tramp-tests.el (tramp--test-special-characters): Don't - test "\t" in file names on Cygwin. (Bug#20119) + * automated/tramp-tests.el (tramp--test-special-characters): + Don't test "\t" in file names on Cygwin. (Bug#20119) 2015-03-10 Jackson Ray Hamilton @@ -78,8 +86,8 @@ 2015-03-03 Daniel Colascione - * automated/generator-tests.el (cps-testcase): Use - `cps-inhibit-atomic-optimization' instead of + * automated/generator-tests.el (cps-testcase): + Use `cps-inhibit-atomic-optimization' instead of `cps-disable-atomic-optimization'. (cps-test-declarations-preserved): New test. @@ -184,8 +192,8 @@ 2015-02-07 Dmitry Gutov - * automated/vc-tests.el (vc-test--working-revision): Fix - `vc-working-revision' checks to be compared against nil, which is + * automated/vc-tests.el (vc-test--working-revision): + Fix `vc-working-revision' checks to be compared against nil, which is what is should return for unregistered files. 2015-02-06 Nicolas Petton diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el index 2c188a40059..ce0e5918653 100644 --- a/test/automated/cl-lib-tests.el +++ b/test/automated/cl-lib-tests.el @@ -1,4 +1,4 @@ -;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el +;;; cl-lib.el --- tests for emacs-lisp/cl-lib.el -*- lexical-binding:t -*- ;; Copyright (C) 2013-2015 Free Software Foundation, Inc. @@ -204,7 +204,10 @@ :b :a :a 42) '(42 :a)))) -(cl-defstruct mystruct (abc :readonly t) def) +(cl-defstruct (mystruct + (:constructor cl-lib--con-1 (&aux (abc 1))) + (:constructor cl-lib--con-2 (&optional def))) + (abc 5 :readonly t) (def nil)) (ert-deftest cl-lib-struct-accessors () (let ((x (make-mystruct :abc 1 :def 2))) (should (eql (cl-struct-slot-value 'mystruct 'abc x) 1)) @@ -213,8 +216,17 @@ (should (eql (cl-struct-slot-value 'mystruct 'def x) -1)) (should (eql (cl-struct-slot-offset 'mystruct 'abc) 1)) (should-error (cl-struct-slot-offset 'mystruct 'marypoppins)) - (should (equal (cl-struct-slot-info 'mystruct) - '((cl-tag-slot) (abc :readonly t) (def)))))) + (should (pcase (cl-struct-slot-info 'mystruct) + (`((cl-tag-slot) (abc 5 :readonly t) + (def . ,(or `nil `(nil)))) + t))))) + +(ert-deftest cl-lib-arglist-performance () + ;; An `&aux' should not cause lambda's arglist to be turned into an &rest + ;; that's parsed by hand. + (should (equal () (help-function-arglist 'cl-lib--con-1))) + (should (pcase (help-function-arglist 'cl-lib--con-2) + (`(&optional ,_) t)))) (ert-deftest cl-the () (should (eql (cl-the integer 42) 42)) @@ -434,14 +446,4 @@ (should (cl-typep '* 'cl-lib-test-type)) (should-not (cl-typep 1 'cl-lib-test-type))) -(ert-deftest cl-lib-arglist-performance () - ;; An `&aux' should not cause lambda's arglist to be turned into an &rest - ;; that's parsed by hand. - (should (eq () (nth 1 (nth 1 (macroexpand - '(cl-function (lambda (&aux (x 1)) x))))))) - (cl-defstruct (cl-lib--s (:constructor cl-lib--s-make (&optional a))) a) - ;; Similarly the &cl-defs thingy shouldn't cause fallback to manual parsing - ;; of args if the default for optional args is nil. - (should (equal '(&optional a) (help-function-arglist 'cl-lib--s-make)))) - ;;; cl-lib.el ends here -- cgit v1.2.1