aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEli Zaretskii2016-09-24 12:53:46 +0300
committerEli Zaretskii2016-09-24 12:53:46 +0300
commit4e71b5b343c92fc587c666b98440cd8d9b36980c (patch)
treec8d5af9afc4c49ada1489d083609a0ffd1808398 /test
parent524a991f884b0c922e5263817d39856dac58c99b (diff)
downloademacs-4e71b5b343c92fc587c666b98440cd8d9b36980c.tar.gz
emacs-4e71b5b343c92fc587c666b98440cd8d9b36980c.zip
Incorporate lexbind-tests.el in bytecomp-test.el
* test/lisp/emacs-lisp/bytecomp-tests.el: Added tests from test/lisp/legacy/lexbind-tests.el. * test/lisp/legacy/lexbind-tests.el: File deleted.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el43
-rw-r--r--test/lisp/legacy/lexbind-tests.el75
2 files changed, 42 insertions, 76 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index 8847c1b59ea..91d438eae0f 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -2,7 +2,8 @@
2 2
3;; Copyright (C) 2008-2016 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2016 Free Software Foundation, Inc.
4 4
5;; Author: Shigeru Fukaya <shigeru.fukaya@gmail.com> 5;; Author: Shigeru Fukaya <shigeru.fukaya@gmail.com>
6;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Created: November 2008 7;; Created: November 2008
7;; Keywords: internal 8;; Keywords: internal
8;; Human-Keywords: internal 9;; Human-Keywords: internal
@@ -420,6 +421,46 @@ Subtests signal errors if something goes wrong."
420 (defun def () (m)))) 421 (defun def () (m))))
421 (should (equal (funcall 'def) 4))) 422 (should (equal (funcall 'def) 4)))
422 423
424(defconst bytecomp-lexbind-tests
425 `(
426 (let ((f #'car))
427 (let ((f (lambda (x) (cons (funcall f x) (cdr x)))))
428 (funcall f '(1 . 2))))
429 )
430 "List of expression for test.
431Each element will be executed by interpreter and with
432bytecompiled code, and their results compared.")
433
434(defun bytecomp-lexbind-check-1 (pat)
435 "Return non-nil if PAT is the same whether directly evalled or compiled."
436 (let ((warning-minimum-log-level :emergency)
437 (byte-compile-warnings nil)
438 (v0 (condition-case nil
439 (eval pat t)
440 (error nil)))
441 (v1 (condition-case nil
442 (funcall (let ((lexical-binding t))
443 (byte-compile `(lambda nil ,pat))))
444 (error nil))))
445 (equal v0 v1)))
446
447(put 'bytecomp-lexbind-check-1 'ert-explainer 'bytecomp-lexbind-explain-1)
448
449(defun bytecomp-lexbind-explain-1 (pat)
450 (let ((v0 (condition-case nil
451 (eval pat t)
452 (error nil)))
453 (v1 (condition-case nil
454 (funcall (let ((lexical-binding t))
455 (byte-compile (list 'lambda nil pat))))
456 (error nil))))
457 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled."
458 pat v0 v1)))
459
460(ert-deftest bytecomp-lexbind-tests ()
461 "Test the Emacs byte compiler lexbind handling."
462 (dolist (pat bytecomp-lexbind-tests)
463 (should (bytecomp-lexbind-check-1 pat))))
423 464
424;; Local Variables: 465;; Local Variables:
425;; no-byte-compile: t 466;; no-byte-compile: t
diff --git a/test/lisp/legacy/lexbind-tests.el b/test/lisp/legacy/lexbind-tests.el
deleted file mode 100644
index 3bf8c1361ad..00000000000
--- a/test/lisp/legacy/lexbind-tests.el
+++ /dev/null
@@ -1,75 +0,0 @@
1;;; lexbind-tests.el --- Testing the lexbind byte-compiler
2
3;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Keywords:
7
8;; This program is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
12
13;; This program is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21;;; Commentary:
22
23;;
24
25;;; Code:
26
27(require 'ert)
28
29(defconst lexbind-tests
30 `(
31 (let ((f #'car))
32 (let ((f (lambda (x) (cons (funcall f x) (cdr x)))))
33 (funcall f '(1 . 2))))
34 )
35 "List of expression for test.
36Each element will be executed by interpreter and with
37bytecompiled code, and their results compared.")
38
39
40
41(defun lexbind-check-1 (pat)
42 "Return non-nil if PAT is the same whether directly evalled or compiled."
43 (let ((warning-minimum-log-level :emergency)
44 (byte-compile-warnings nil)
45 (v0 (condition-case nil
46 (eval pat t)
47 (error nil)))
48 (v1 (condition-case nil
49 (funcall (let ((lexical-binding t))
50 (byte-compile `(lambda nil ,pat))))
51 (error nil))))
52 (equal v0 v1)))
53
54(put 'lexbind-check-1 'ert-explainer 'lexbind-explain-1)
55
56(defun lexbind-explain-1 (pat)
57 (let ((v0 (condition-case nil
58 (eval pat t)
59 (error nil)))
60 (v1 (condition-case nil
61 (funcall (let ((lexical-binding t))
62 (byte-compile (list 'lambda nil pat))))
63 (error nil))))
64 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled."
65 pat v0 v1)))
66
67(ert-deftest lexbind-tests ()
68 "Test the Emacs byte compiler lexbind handling."
69 (dolist (pat lexbind-tests)
70 (should (lexbind-check-1 pat))))
71
72
73
74(provide 'lexbind-tests)
75;;; lexbind-tests.el ends here