aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-09-24 13:20:19 +0300
committerEli Zaretskii2016-09-24 13:20:19 +0300
commit7f287b7f780849ca32cddaf69dac83a435f92300 (patch)
treeb786de65a234622dc33add0ee7fbe05c4a80b7bd
parent25d66a430e45b4df1d8bb8c8e559f86dcdbcb4c3 (diff)
downloademacs-7f287b7f780849ca32cddaf69dac83a435f92300.tar.gz
emacs-7f287b7f780849ca32cddaf69dac83a435f92300.zip
Incorporate syntax-tests in lisp-tests.
* test/lisp/emacs-lisp/lisp-tests.el: Add tests from test/lisp/legacy/syntax-tests.el. * test/lisp/legacy/syntax-tests.el: File deleted.
-rw-r--r--test/lisp/emacs-lisp/lisp-tests.el71
-rw-r--r--test/lisp/legacy/syntax-tests.el97
2 files changed, 69 insertions, 99 deletions
diff --git a/test/lisp/emacs-lisp/lisp-tests.el b/test/lisp/emacs-lisp/lisp-tests.el
index d83f4a052cb..2dadae95536 100644
--- a/test/lisp/emacs-lisp/lisp-tests.el
+++ b/test/lisp/emacs-lisp/lisp-tests.el
@@ -4,6 +4,7 @@
4 4
5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> 5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com>
6;; Author: Stefan Monnier <monnier@iro.umontreal.ca> 6;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
7;; Author: Daniel Colascione <dancol@dancol.org>
7;; Keywords: internal 8;; Keywords: internal
8 9
9;; GNU Emacs is free software: you can redistribute it and/or modify 10;; GNU Emacs is free software: you can redistribute it and/or modify
@@ -27,6 +28,7 @@
27 28
28(require 'ert) 29(require 'ert)
29(require 'python) 30(require 'python)
31(require 'cl-lib)
30 32
31(ert-deftest lisp-forward-sexp-1-empty-parens () 33(ert-deftest lisp-forward-sexp-1-empty-parens ()
32 "Test basics of \\[forward-sexp]." 34 "Test basics of \\[forward-sexp]."
@@ -233,8 +235,73 @@
233(ert-deftest core-elisp-tests-3-backquote () 235(ert-deftest core-elisp-tests-3-backquote ()
234 (should (eq 3 (eval ``,,'(+ 1 2))))) 236 (should (eq 3 (eval ``,,'(+ 1 2)))))
235 237
236(provide 'core-elisp-tests) 238;; Test up-list and backward-up-list.
237;;; core-elisp-tests.el ends here 239(defun lisp-run-up-list-test (fn data start instructions)
240 (cl-labels ((posof (thing)
241 (and (symbolp thing)
242 (= (length (symbol-name thing)) 1)
243 (- (aref (symbol-name thing) 0) ?a -1))))
244 (with-temp-buffer
245 (set-syntax-table (make-syntax-table))
246 ;; Use a syntax table in which single quote is a string
247 ;; character so that we can embed the test data in a lisp string
248 ;; literal.
249 (modify-syntax-entry ?\' "\"")
250 (insert data)
251 (goto-char (posof start))
252 (dolist (instruction instructions)
253 (cond ((posof instruction)
254 (funcall fn)
255 (should (eql (point) (posof instruction))))
256 ((symbolp instruction)
257 (should-error (funcall fn)
258 :type instruction))
259 (t (cl-assert nil nil "unknown ins")))))))
260
261(defmacro define-lisp-up-list-test (name fn data start &rest expected)
262 `(ert-deftest ,name ()
263 (lisp-run-up-list-test ,fn ,data ',start ',expected)))
264
265(define-lisp-up-list-test up-list-basic
266 (lambda () (up-list))
267 (or "(1 1 (1 1) 1 (1 1) 1)")
268 ;; abcdefghijklmnopqrstuv
269 i k v scan-error)
270
271(define-lisp-up-list-test up-list-with-forward-sexp-function
272 (lambda ()
273 (let ((forward-sexp-function
274 (lambda (&optional arg)
275 (let ((forward-sexp-function nil))
276 (forward-sexp arg)))))
277 (up-list)))
278 (or "(1 1 (1 1) 1 (1 1) 1)")
279 ;; abcdefghijklmnopqrstuv
280 i k v scan-error)
281
282(define-lisp-up-list-test up-list-out-of-string
283 (lambda () (up-list 1 t))
284 (or "1 (1 '2 2 (2 2 2' 1) 1")
285 ;; abcdefghijklmnopqrstuvwxy
286 o r u scan-error)
287
288(define-lisp-up-list-test up-list-cross-string
289 (lambda () (up-list 1 t))
290 (or "(1 '2 ( 2' 1 '2 ) 2' 1)")
291 ;; abcdefghijklmnopqrstuvwxy
292 i r u x scan-error)
293
294(define-lisp-up-list-test up-list-no-cross-string
295 (lambda () (up-list 1 t t))
296 (or "(1 '2 ( 2' 1 '2 ) 2' 1)")
297 ;; abcdefghijklmnopqrstuvwxy
298 i k x scan-error)
299
300(define-lisp-up-list-test backward-up-list-basic
301 (lambda () (backward-up-list))
302 (or "(1 1 (1 1) 1 (1 1) 1)")
303 ;; abcdefghijklmnopqrstuv
304 i f a scan-error)
238 305
239(provide 'lisp-tests) 306(provide 'lisp-tests)
240;;; lisp-tests.el ends here 307;;; lisp-tests.el ends here
diff --git a/test/lisp/legacy/syntax-tests.el b/test/lisp/legacy/syntax-tests.el
deleted file mode 100644
index d4af80e8ebe..00000000000
--- a/test/lisp/legacy/syntax-tests.el
+++ /dev/null
@@ -1,97 +0,0 @@
1;;; syntax-tests.el --- Testing syntax rules and basic movement -*- lexical-binding: t -*-
2
3;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
4
5;; Author: Daniel Colascione <dancol@dancol.org>
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(require 'ert)
27(require 'cl-lib)
28
29(defun run-up-list-test (fn data start instructions)
30 (cl-labels ((posof (thing)
31 (and (symbolp thing)
32 (= (length (symbol-name thing)) 1)
33 (- (aref (symbol-name thing) 0) ?a -1))))
34 (with-temp-buffer
35 (set-syntax-table (make-syntax-table))
36 ;; Use a syntax table in which single quote is a string
37 ;; character so that we can embed the test data in a lisp string
38 ;; literal.
39 (modify-syntax-entry ?\' "\"")
40 (insert data)
41 (goto-char (posof start))
42 (dolist (instruction instructions)
43 (cond ((posof instruction)
44 (funcall fn)
45 (should (eql (point) (posof instruction))))
46 ((symbolp instruction)
47 (should-error (funcall fn)
48 :type instruction))
49 (t (cl-assert nil nil "unknown ins")))))))
50
51(defmacro define-up-list-test (name fn data start &rest expected)
52 `(ert-deftest ,name ()
53 (run-up-list-test ,fn ,data ',start ',expected)))
54
55(define-up-list-test up-list-basic
56 (lambda () (up-list))
57 (or "(1 1 (1 1) 1 (1 1) 1)")
58 ;; abcdefghijklmnopqrstuv
59 i k v scan-error)
60
61(define-up-list-test up-list-with-forward-sexp-function
62 (lambda ()
63 (let ((forward-sexp-function
64 (lambda (&optional arg)
65 (let ((forward-sexp-function nil))
66 (forward-sexp arg)))))
67 (up-list)))
68 (or "(1 1 (1 1) 1 (1 1) 1)")
69 ;; abcdefghijklmnopqrstuv
70 i k v scan-error)
71
72(define-up-list-test up-list-out-of-string
73 (lambda () (up-list 1 t))
74 (or "1 (1 '2 2 (2 2 2' 1) 1")
75 ;; abcdefghijklmnopqrstuvwxy
76 o r u scan-error)
77
78(define-up-list-test up-list-cross-string
79 (lambda () (up-list 1 t))
80 (or "(1 '2 ( 2' 1 '2 ) 2' 1)")
81 ;; abcdefghijklmnopqrstuvwxy
82 i r u x scan-error)
83
84(define-up-list-test up-list-no-cross-string
85 (lambda () (up-list 1 t t))
86 (or "(1 '2 ( 2' 1 '2 ) 2' 1)")
87 ;; abcdefghijklmnopqrstuvwxy
88 i k x scan-error)
89
90(define-up-list-test backward-up-list-basic
91 (lambda () (backward-up-list))
92 (or "(1 1 (1 1) 1 (1 1) 1)")
93 ;; abcdefghijklmnopqrstuv
94 i f a scan-error)
95
96(provide 'syntax-tests)
97;;; syntax-tests.el ends here