diff options
| author | Daniel Colascione | 2014-04-09 09:58:08 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2014-04-09 09:58:08 -0700 |
| commit | 3f63a9f7de4f252a0309c2143e6d916d734ffe22 (patch) | |
| tree | 01a53bee941983edfc24944f9774741eafa87c81 /test | |
| parent | 6c971fb0f44169d7f77a9575301a4935106c0360 (diff) | |
| download | emacs-3f63a9f7de4f252a0309c2143e6d916d734ffe22.tar.gz emacs-3f63a9f7de4f252a0309c2143e6d916d734ffe22.zip | |
Make up-list and backward-up-list get out of more spots
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/syntax-tests.el | 97 |
2 files changed, 101 insertions, 0 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index c27b9b5f437..ebba4f01e93 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-04-09 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * automated/syntax-tests.el: New file. | ||
| 4 | |||
| 1 | 2014-04-09 Glenn Morris <rgm@gnu.org> | 5 | 2014-04-09 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * automated/python-tests.el (python-triple-quote-pairing): | 7 | * automated/python-tests.el (python-triple-quote-pairing): |
diff --git a/test/automated/syntax-tests.el b/test/automated/syntax-tests.el new file mode 100644 index 00000000000..9b97001a14e --- /dev/null +++ b/test/automated/syntax-tests.el | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | ;;; syntax-tests.el --- Testing syntax rules and basic movement -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2014 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 | ||