1 ;;; syntax-tests.el --- Testing syntax rules and basic movement -*- lexical-binding: t -*-
3 ;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
5 ;; Author: Daniel Colascione <dancol@dancol.org>
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.
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.
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/>.
29 (defun run-up-list-test (fn data start instructions
)
30 (cl-labels ((posof (thing)
32 (= (length (symbol-name thing
)) 1)
33 (- (aref (symbol-name thing
) 0) ?a -
1))))
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
39 (modify-syntax-entry ?
\' "\"")
41 (goto-char (posof start
))
42 (dolist (instruction instructions
)
43 (cond ((posof instruction
)
45 (should (eql (point) (posof instruction
))))
46 ((symbolp instruction
)
47 (should-error (funcall fn
)
49 (t (cl-assert nil nil
"unknown ins")))))))
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
)))
55 (define-up-list-test up-list-basic
57 (or "(1 1 (1 1) 1 (1 1) 1)")
58 ;; abcdefghijklmnopqrstuv
61 (define-up-list-test up-list-with-forward-sexp-function
63 (let ((forward-sexp-function
64 (lambda (&optional arg
)
65 (let ((forward-sexp-function nil
))
66 (forward-sexp arg
)))))
68 (or "(1 1 (1 1) 1 (1 1) 1)")
69 ;; abcdefghijklmnopqrstuv
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
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
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
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
96 (provide 'syntax-tests
)
97 ;;; syntax-tests.el ends here