diff options
| author | Tom Tromey | 2013-06-03 12:25:05 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-06-03 12:25:05 -0600 |
| commit | 68359abba96d7ec4db8aab3d3dd9cf1105c3bab5 (patch) | |
| tree | 862703e7e1a1888170136a8296a5750d6b2ae2eb /test | |
| parent | cbcba8ce7f980b01c18c0fd561ef6687b1361507 (diff) | |
| parent | e2d8a6f0a229b4ebe26484b892ec4f14888f58b6 (diff) | |
| download | emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.tar.gz emacs-68359abba96d7ec4db8aab3d3dd9cf1105c3bab5.zip | |
merge from trunk; clean up some issues
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 80 | ||||
| -rw-r--r-- | test/automated/add-log-tests.el | 84 | ||||
| -rw-r--r-- | test/automated/decoder-tests.el | 279 | ||||
| -rw-r--r-- | test/automated/imenu-test.el | 87 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 368 | ||||
| -rw-r--r-- | test/automated/ruby-mode-tests.el | 75 | ||||
| -rw-r--r-- | test/eshell.el | 493 | ||||
| -rw-r--r-- | test/indent/octave.m | 50 | ||||
| -rw-r--r-- | test/indent/pascal.pas | 5 | ||||
| -rwxr-xr-x | test/indent/perl.perl | 15 | ||||
| -rw-r--r-- | test/indent/ruby.rb | 43 |
11 files changed, 1152 insertions, 427 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 43648ad1bb1..98fb2e3da1f 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,73 @@ | |||
| 1 | 2013-05-31 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * automated/ruby-mode-tests.el: New tests, for percent literals | ||
| 4 | and expression expansion. | ||
| 5 | |||
| 6 | 2013-05-29 Leo Liu <sdl.web@gmail.com> | ||
| 7 | |||
| 8 | * indent/octave.m: Tweak. | ||
| 9 | |||
| 10 | 2013-05-26 Aidan Gauland <aidalgol@amuri.net> | ||
| 11 | |||
| 12 | * tests/eshell.el: Rewrite tests using ERT. | ||
| 13 | |||
| 14 | 2013-05-25 Leo Liu <sdl.web@gmail.com> | ||
| 15 | |||
| 16 | * indent/octave.m: Add tests for %!, # and ### comments. | ||
| 17 | |||
| 18 | 2013-05-23 Kenichi Handa <handa@gnu.org> | ||
| 19 | |||
| 20 | * automated/decoder-tests.el: New file. | ||
| 21 | |||
| 22 | 2013-05-19 Dmitry Gutov <dgutov@yandex.ru> | ||
| 23 | |||
| 24 | * indent/ruby.rb: Add multiline regexp example. | ||
| 25 | |||
| 26 | * automated/ruby-mode-tests.el (ruby-heredoc-highlights-interpolations) | ||
| 27 | (ruby-regexp-skips-over-interpolation) | ||
| 28 | (ruby-regexp-continues-till-end-when-unclosed) | ||
| 29 | (ruby-regexp-can-be-multiline) | ||
| 30 | (ruby-interpolation-inside-percent-literal): New tests. | ||
| 31 | |||
| 32 | 2013-05-08 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 33 | |||
| 34 | * indent/ruby.rb: Fix indentation after =; add more cases. | ||
| 35 | |||
| 36 | 2013-05-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 37 | |||
| 38 | * indent/pascal.pas: Add test for mis-identified comments. | ||
| 39 | |||
| 40 | 2013-04-01 Masatake YAMATO <yamato@redhat.com> | ||
| 41 | |||
| 42 | * automated/imenu-tests.el: New file. (Bug#14112) | ||
| 43 | |||
| 44 | 2013-04-19 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 45 | |||
| 46 | * automated/python-tests.el (python-imenu-prev-index-position-1): | ||
| 47 | Remove test. | ||
| 48 | (python-imenu-create-index-1, python-imenu-create-flat-index-1): | ||
| 49 | New tests. | ||
| 50 | |||
| 51 | 2013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 52 | |||
| 53 | * automated/python-tests.el (python-nav-backward-defun-2) | ||
| 54 | (python-nav-backward-defun-3, python-nav-forward-defun-2) | ||
| 55 | (python-nav-forward-defun-3): New tests. | ||
| 56 | |||
| 57 | 2013-04-17 Fabián Ezequiel Gallina <fgallina@gnu.org> | ||
| 58 | |||
| 59 | * automated/python-tests.el (python-nav-backward-defun-1) | ||
| 60 | (python-nav-forward-defun-1): New tests. | ||
| 61 | |||
| 62 | 2013-04-09 Masatake YAMATO <yamato@redhat.com> | ||
| 63 | |||
| 64 | * automated/add-log-tests.el: New file. (Bug#14112) | ||
| 65 | |||
| 66 | 2013-03-30 Fabián Ezequiel Gallina <fabian@anue.biz> | ||
| 67 | |||
| 68 | * automated/python-tests.el (python-indent-block-enders): New test. | ||
| 69 | (python-info-current-defun-2): Fix test. | ||
| 70 | |||
| 1 | 2013-03-05 Paul Eggert <eggert@cs.ucla.edu> | 71 | 2013-03-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 72 | ||
| 3 | * indent/octave.m: Fix encoding error in comment. Add coding tag. | 73 | * indent/octave.m: Fix encoding error in comment. Add coding tag. |
| @@ -31,8 +101,8 @@ | |||
| 31 | (ruby-move-to-block-skips-percent-literal): Add depth-affecting | 101 | (ruby-move-to-block-skips-percent-literal): Add depth-affecting |
| 32 | bits inside the examples. | 102 | bits inside the examples. |
| 33 | (ruby-move-to-block-skips-heredoc): New test. | 103 | (ruby-move-to-block-skips-heredoc): New test. |
| 34 | (ruby-add-log-current-method-after-inner-class): Lower | 104 | (ruby-add-log-current-method-after-inner-class): |
| 35 | expectations: move point inside a method, initially. | 105 | Lower expectations: move point inside a method, initially. |
| 36 | 106 | ||
| 37 | 2013-02-13 Dmitry Gutov <dgutov@yandex.ru> | 107 | 2013-02-13 Dmitry Gutov <dgutov@yandex.ru> |
| 38 | 108 | ||
| @@ -45,8 +115,8 @@ | |||
| 45 | 115 | ||
| 46 | 2013-02-03 Chong Yidong <cyd@gnu.org> | 116 | 2013-02-03 Chong Yidong <cyd@gnu.org> |
| 47 | 117 | ||
| 48 | * automated/files.el (file-test--do-local-variables-test): Avoid | 118 | * automated/files.el (file-test--do-local-variables-test): |
| 49 | compilation warning message. | 119 | Avoid compilation warning message. |
| 50 | 120 | ||
| 51 | 2013-01-27 Dmitry Gutov <dgutov@yandex.ru> | 121 | 2013-01-27 Dmitry Gutov <dgutov@yandex.ru> |
| 52 | 122 | ||
| @@ -350,7 +420,7 @@ | |||
| 350 | 2011-07-26 Ulf Jasper <ulf.jasper@web.de> | 420 | 2011-07-26 Ulf Jasper <ulf.jasper@web.de> |
| 351 | 421 | ||
| 352 | * automated/icalendar-tests.el (icalendar-tests--compare-strings): | 422 | * automated/icalendar-tests.el (icalendar-tests--compare-strings): |
| 353 | Removed, simply use string=. | 423 | Remove, simply use string=. |
| 354 | (icalendar--diarytime-to-isotime) | 424 | (icalendar--diarytime-to-isotime) |
| 355 | (icalendar--datetime-to-diary-date) | 425 | (icalendar--datetime-to-diary-date) |
| 356 | (icalendar--datestring-to-isodate) | 426 | (icalendar--datestring-to-isodate) |
diff --git a/test/automated/add-log-tests.el b/test/automated/add-log-tests.el new file mode 100644 index 00000000000..f6e803cd317 --- /dev/null +++ b/test/automated/add-log-tests.el | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | ;;; add-log-tests.el --- Test suite for add-log. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Masatake YAMATO <yamato@redhat.com> | ||
| 6 | ;; Keywords: vc tools | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'add-log) | ||
| 26 | |||
| 27 | (defmacro add-log-current-defun-deftest (name doc major-mode | ||
| 28 | content marker expected-defun) | ||
| 29 | "Generate an ert test for mode-own `add-log-current-defun-function'. | ||
| 30 | Run `add-log-current-defun' at the point where MARKER specifies in a | ||
| 31 | buffer which content is CONTENT under MAJOR-MODE. Then it compares the | ||
| 32 | result with EXPECTED-DEFUN." | ||
| 33 | (let ((xname (intern (concat "add-log-current-defun-test-" | ||
| 34 | (symbol-name name) | ||
| 35 | )))) | ||
| 36 | `(ert-deftest ,xname () | ||
| 37 | ,doc | ||
| 38 | (with-temp-buffer | ||
| 39 | (insert ,content) | ||
| 40 | (goto-char (point-min)) | ||
| 41 | (funcall ',major-mode) | ||
| 42 | (should (equal (when (search-forward ,marker nil t) | ||
| 43 | (replace-match "" nil t) | ||
| 44 | (add-log-current-defun)) | ||
| 45 | ,expected-defun)))))) | ||
| 46 | |||
| 47 | (add-log-current-defun-deftest | ||
| 48 | sh-func1 | ||
| 49 | "Test sh-current-defun-name can find function." | ||
| 50 | sh-mode " | ||
| 51 | function foo | ||
| 52 | { | ||
| 53 | >< | ||
| 54 | }" "><" "foo") | ||
| 55 | |||
| 56 | (add-log-current-defun-deftest | ||
| 57 | sh-func2 | ||
| 58 | "Test sh-current-defun-name can find function." | ||
| 59 | sh-mode " | ||
| 60 | foo() | ||
| 61 | { | ||
| 62 | >< | ||
| 63 | }" "><" "foo") | ||
| 64 | |||
| 65 | (add-log-current-defun-deftest | ||
| 66 | sh-func3 | ||
| 67 | "Test sh-current-defun-name can find function." | ||
| 68 | sh-mode " | ||
| 69 | function foo() | ||
| 70 | { | ||
| 71 | >< | ||
| 72 | }" "><" "foo") | ||
| 73 | |||
| 74 | (add-log-current-defun-deftest | ||
| 75 | sh-var | ||
| 76 | "Test sh-current-defun-name can find variable definition." | ||
| 77 | sh-mode " | ||
| 78 | PATH=a:/ab:/usr/abc | ||
| 79 | DIR=/pr><oc" | ||
| 80 | "><" "DIR") | ||
| 81 | |||
| 82 | (provide 'add-log-tests) | ||
| 83 | |||
| 84 | ;;; add-log-tests.el ends here | ||
diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el new file mode 100644 index 00000000000..055626491c0 --- /dev/null +++ b/test/automated/decoder-tests.el | |||
| @@ -0,0 +1,279 @@ | |||
| 1 | ;;; decoder-tests.el --- test for text decoder | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Kenichi Handa <handa@gnu.org> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | |||
| 26 | ;;; Check ASCII optimizing decoder | ||
| 27 | |||
| 28 | ;; Directory to hold test data files. | ||
| 29 | (defvar decoder-tests-workdir | ||
| 30 | (expand-file-name "decoder-tests" temporary-file-directory)) | ||
| 31 | |||
| 32 | ;; Return the contents (specified by CONTENT-TYPE; ascii, latin, or | ||
| 33 | ;; binary) of a test file. | ||
| 34 | (defun decoder-tests-file-contents (content-type) | ||
| 35 | (let* ((ascii "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n") | ||
| 36 | (latin (concat ascii "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ\n")) | ||
| 37 | (binary (string-to-multibyte | ||
| 38 | (concat (string-as-unibyte latin) | ||
| 39 | (unibyte-string #xC0 #xC1 ?\n))))) | ||
| 40 | (cond ((eq content-type 'ascii) ascii) | ||
| 41 | ((eq content-type 'latin) latin) | ||
| 42 | ((eq content-type 'binary) binary) | ||
| 43 | (t | ||
| 44 | (error "Invalid file content type: %s" content-type))))) | ||
| 45 | |||
| 46 | ;; Return the name of test file whose contents specified by | ||
| 47 | ;; CONTENT-TYPE and whose encoding specified by CODING-SYSTEM. | ||
| 48 | (defun decoder-tests-filename (content-type coding-system) | ||
| 49 | (expand-file-name (format "%s-%s" content-type coding-system) | ||
| 50 | decoder-tests-workdir)) | ||
| 51 | |||
| 52 | ;; Generate a test file whose contents specified by CONTENT-TYPE and | ||
| 53 | ;; whose encoding specified by CODING-SYSTEM. | ||
| 54 | (defun decoder-tests-gen-file (content-type coding-system) | ||
| 55 | (or (file-directory-p decoder-tests-workdir) | ||
| 56 | (mkdir decoder-tests-workdir t)) | ||
| 57 | (let ((file (decoder-tests-filename content-type coding-system))) | ||
| 58 | (with-temp-file file | ||
| 59 | (set-buffer-file-coding-system coding-system) | ||
| 60 | (insert (decoder-tests-file-contents content-type))))) | ||
| 61 | |||
| 62 | ;; Remove all generated test files. | ||
| 63 | (defun decoder-tests-remove-files () | ||
| 64 | (delete-directory decoder-tests-workdir t)) | ||
| 65 | |||
| 66 | ;;; The following three functions are filters for contents of a test | ||
| 67 | ;;; file. | ||
| 68 | |||
| 69 | ;; Convert all LFs to CR LF sequences in the string STR. | ||
| 70 | (defun decoder-tests-lf-to-crlf (str) | ||
| 71 | (with-temp-buffer | ||
| 72 | (insert str) | ||
| 73 | (goto-char (point-min)) | ||
| 74 | (while (search-forward "\n" nil t) | ||
| 75 | (delete-char -1) | ||
| 76 | (insert "\r\n")) | ||
| 77 | (buffer-string))) | ||
| 78 | |||
| 79 | ;; Convert all LFs to CRs in the string STR. | ||
| 80 | (defun decoder-tests-lf-to-cr (str) | ||
| 81 | (with-temp-buffer | ||
| 82 | (insert str) | ||
| 83 | (subst-char-in-region (point-min) (point-max) ?\n ?\r) | ||
| 84 | (buffer-string))) | ||
| 85 | |||
| 86 | ;; Convert all LFs to LF LF sequences in the string STR. | ||
| 87 | (defun decoder-tests-lf-to-lflf (str) | ||
| 88 | (with-temp-buffer | ||
| 89 | (insert str) | ||
| 90 | (goto-char (point-min)) | ||
| 91 | (while (search-forward "\n" nil t) | ||
| 92 | (insert "\n")) | ||
| 93 | (buffer-string))) | ||
| 94 | |||
| 95 | ;; Prepend the UTF-8 BOM to STR. | ||
| 96 | (defun decoder-tests-add-bom (str) | ||
| 97 | (concat "\xfeff" str)) | ||
| 98 | |||
| 99 | ;; Test the decoding of a file whose contents and encoding are | ||
| 100 | ;; specified by CONTENT-TYPE and WRITE-CODING. The test passes if the | ||
| 101 | ;; file is read by READ-CODING and detected as DETECTED-CODING and the | ||
| 102 | ;; contents is correctly decoded. | ||
| 103 | ;; Optional 5th arg TRANSLATOR is a function to translate the original | ||
| 104 | ;; file contents to match with the expected result of decoding. For | ||
| 105 | ;; instance, when a file of dos eol-type is read by unix eol-type, | ||
| 106 | ;; `decode-test-lf-to-crlf' must be specified. | ||
| 107 | |||
| 108 | (defun decoder-tests (content-type write-coding read-coding detected-coding | ||
| 109 | &optional translator) | ||
| 110 | (prefer-coding-system 'utf-8-auto) | ||
| 111 | (let ((filename (decoder-tests-filename content-type write-coding))) | ||
| 112 | (with-temp-buffer | ||
| 113 | (let ((coding-system-for-read read-coding) | ||
| 114 | (contents (decoder-tests-file-contents content-type)) | ||
| 115 | (disable-ascii-optimization nil)) | ||
| 116 | (if translator | ||
| 117 | (setq contents (funcall translator contents))) | ||
| 118 | (insert-file-contents filename) | ||
| 119 | (if (and (coding-system-equal buffer-file-coding-system detected-coding) | ||
| 120 | (string= (buffer-string) contents)) | ||
| 121 | nil | ||
| 122 | (list buffer-file-coding-system | ||
| 123 | (string-to-list (buffer-string)) | ||
| 124 | (string-to-list contents))))))) | ||
| 125 | |||
| 126 | (ert-deftest ert-test-decoder-ascii () | ||
| 127 | (unwind-protect | ||
| 128 | (progn | ||
| 129 | (dolist (eol-type '(unix dos mac)) | ||
| 130 | (decoder-tests-gen-file 'ascii eol-type)) | ||
| 131 | (should-not (decoder-tests 'ascii 'unix 'undecided 'unix)) | ||
| 132 | (should-not (decoder-tests 'ascii 'dos 'undecided 'dos)) | ||
| 133 | (should-not (decoder-tests 'ascii 'dos 'dos 'dos)) | ||
| 134 | (should-not (decoder-tests 'ascii 'mac 'undecided 'mac)) | ||
| 135 | (should-not (decoder-tests 'ascii 'mac 'mac 'mac)) | ||
| 136 | (should-not (decoder-tests 'ascii 'dos 'utf-8 'utf-8-dos)) | ||
| 137 | (should-not (decoder-tests 'ascii 'dos 'unix 'unix | ||
| 138 | 'decoder-tests-lf-to-crlf)) | ||
| 139 | (should-not (decoder-tests 'ascii 'mac 'dos 'dos | ||
| 140 | 'decoder-tests-lf-to-cr)) | ||
| 141 | (should-not (decoder-tests 'ascii 'dos 'mac 'mac | ||
| 142 | 'decoder-tests-lf-to-lflf))) | ||
| 143 | (decoder-tests-remove-files))) | ||
| 144 | |||
| 145 | (ert-deftest ert-test-decoder-latin () | ||
| 146 | (unwind-protect | ||
| 147 | (progn | ||
| 148 | (dolist (coding '("utf-8" "utf-8-with-signature")) | ||
| 149 | (dolist (eol-type '("unix" "dos" "mac")) | ||
| 150 | (decoder-tests-gen-file 'latin | ||
| 151 | (intern (concat coding "-" eol-type))))) | ||
| 152 | (should-not (decoder-tests 'latin 'utf-8-unix 'undecided 'utf-8-unix)) | ||
| 153 | (should-not (decoder-tests 'latin 'utf-8-unix 'utf-8-unix 'utf-8-unix)) | ||
| 154 | (should-not (decoder-tests 'latin 'utf-8-dos 'undecided 'utf-8-dos)) | ||
| 155 | (should-not (decoder-tests 'latin 'utf-8-dos 'utf-8-dos 'utf-8-dos)) | ||
| 156 | (should-not (decoder-tests 'latin 'utf-8-mac 'undecided 'utf-8-mac)) | ||
| 157 | (should-not (decoder-tests 'latin 'utf-8-mac 'utf-8-mac 'utf-8-mac)) | ||
| 158 | (should-not (decoder-tests 'latin 'utf-8-dos 'unix 'utf-8-unix | ||
| 159 | 'decoder-tests-lf-to-crlf)) | ||
| 160 | (should-not (decoder-tests 'latin 'utf-8-mac 'dos 'utf-8-dos | ||
| 161 | 'decoder-tests-lf-to-cr)) | ||
| 162 | (should-not (decoder-tests 'latin 'utf-8-dos 'mac 'utf-8-mac | ||
| 163 | 'decoder-tests-lf-to-lflf)) | ||
| 164 | (should-not (decoder-tests 'latin 'utf-8-with-signature-unix 'undecided | ||
| 165 | 'utf-8-with-signature-unix)) | ||
| 166 | (should-not (decoder-tests 'latin 'utf-8-with-signature-unix 'utf-8-auto | ||
| 167 | 'utf-8-with-signature-unix)) | ||
| 168 | (should-not (decoder-tests 'latin 'utf-8-with-signature-dos 'undecided | ||
| 169 | 'utf-8-with-signature-dos)) | ||
| 170 | (should-not (decoder-tests 'latin 'utf-8-with-signature-unix 'utf-8 | ||
| 171 | 'utf-8-unix 'decoder-tests-add-bom)) | ||
| 172 | (should-not (decoder-tests 'latin 'utf-8-with-signature-unix 'utf-8 | ||
| 173 | 'utf-8-unix 'decoder-tests-add-bom))) | ||
| 174 | (decoder-tests-remove-files))) | ||
| 175 | |||
| 176 | (ert-deftest ert-test-decoder-binary () | ||
| 177 | (unwind-protect | ||
| 178 | (progn | ||
| 179 | (dolist (eol-type '("unix" "dos" "mac")) | ||
| 180 | (decoder-tests-gen-file 'binary | ||
| 181 | (intern (concat "raw-text" "-" eol-type)))) | ||
| 182 | (should-not (decoder-tests 'binary 'raw-text-unix 'undecided | ||
| 183 | 'raw-text-unix)) | ||
| 184 | (should-not (decoder-tests 'binary 'raw-text-dos 'undecided | ||
| 185 | 'raw-text-dos)) | ||
| 186 | (should-not (decoder-tests 'binary 'raw-text-mac 'undecided | ||
| 187 | 'raw-text-mac)) | ||
| 188 | (should-not (decoder-tests 'binary 'raw-text-dos 'unix | ||
| 189 | 'raw-text-unix 'decoder-tests-lf-to-crlf)) | ||
| 190 | (should-not (decoder-tests 'binary 'raw-text-mac 'dos | ||
| 191 | 'raw-text-dos 'decoder-tests-lf-to-cr)) | ||
| 192 | (should-not (decoder-tests 'binary 'raw-text-dos 'mac | ||
| 193 | 'raw-text-mac 'decoder-tests-lf-to-lflf))) | ||
| 194 | (decoder-tests-remove-files))) | ||
| 195 | |||
| 196 | |||
| 197 | |||
| 198 | ;;; The following is for benchmark testing of the new optimized | ||
| 199 | ;;; decoder, not for regression testing. | ||
| 200 | |||
| 201 | (defun generate-ascii-file () | ||
| 202 | (dotimes (i 100000) | ||
| 203 | (insert-char ?a 80) | ||
| 204 | (insert "\n"))) | ||
| 205 | |||
| 206 | (defun generate-rarely-nonascii-file () | ||
| 207 | (dotimes (i 100000) | ||
| 208 | (if (/= i 50000) | ||
| 209 | (insert-char ?a 80) | ||
| 210 | (insert ?À) | ||
| 211 | (insert-char ?a 79)) | ||
| 212 | (insert "\n"))) | ||
| 213 | |||
| 214 | (defun generate-mostly-nonascii-file () | ||
| 215 | (dotimes (i 30000) | ||
| 216 | (insert-char ?a 80) | ||
| 217 | (insert "\n")) | ||
| 218 | (dotimes (i 20000) | ||
| 219 | (insert-char ?À 80) | ||
| 220 | (insert "\n")) | ||
| 221 | (dotimes (i 10000) | ||
| 222 | (insert-char ?あ 80) | ||
| 223 | (insert "\n"))) | ||
| 224 | |||
| 225 | |||
| 226 | (defvar test-file-list | ||
| 227 | '((generate-ascii-file | ||
| 228 | ("~/ascii-tag-utf-8-unix.unix" ";; -*- coding: utf-8-unix; -*-" unix) | ||
| 229 | ("~/ascii-tag-utf-8.unix" ";; -*- coding: utf-8; -*-" unix) | ||
| 230 | ("~/ascii-tag-none.unix" "" unix) | ||
| 231 | ("~/ascii-tag-utf-8-dos.dos" ";; -*- coding: utf-8-dos; -*-" dos) | ||
| 232 | ("~/ascii-tag-utf-8.dos" ";; -*- coding: utf-8; -*-" dos) | ||
| 233 | ("~/ascii-tag-none.dos" "" dos)) | ||
| 234 | (generate-rarely-nonascii-file | ||
| 235 | ("~/utf-8-r-tag-utf-8-unix.unix" ";; -*- coding: utf-8-unix; -*-" utf-8-unix) | ||
| 236 | ("~/utf-8-r-tag-utf-8.unix" ";; -*- coding: utf-8; -*-" utf-8-unix) | ||
| 237 | ("~/utf-8-r-tag-none.unix" "" utf-8-unix) | ||
| 238 | ("~/utf-8-r-tag-utf-8-dos.dos" ";; -*- coding: utf-8-dos; -*-" utf-8-dos) | ||
| 239 | ("~/utf-8-r-tag-utf-8.dos" ";; -*- coding: utf-8; -*-" utf-8-dos) | ||
| 240 | ("~/utf-8-r-tag-none.dos" "" utf-8-dos)) | ||
| 241 | (generate-mostly-nonascii-file | ||
| 242 | ("~/utf-8-m-tag-utf-8-unix.unix" ";; -*- coding: utf-8-unix; -*-" utf-8-unix) | ||
| 243 | ("~/utf-8-m-tag-utf-8.unix" ";; -*- coding: utf-8; -*-" utf-8-unix) | ||
| 244 | ("~/utf-8-m-tag-none.unix" "" utf-8-unix) | ||
| 245 | ("~/utf-8-m-tag-utf-8-dos.dos" ";; -*- coding: utf-8-dos; -*-" utf-8-dos) | ||
| 246 | ("~/utf-8-m-tag-utf-8.dos" ";; -*- coding: utf-8; -*-" utf-8-dos) | ||
| 247 | ("~/utf-8-m-tag-none.dos" "" utf-8-dos)))) | ||
| 248 | |||
| 249 | (defun generate-benchmark-test-file () | ||
| 250 | (interactive) | ||
| 251 | (with-temp-buffer | ||
| 252 | (message "Generating data...") | ||
| 253 | (dolist (files test-file-list) | ||
| 254 | (delete-region (point-min) (point-max)) | ||
| 255 | (funcall (car files)) | ||
| 256 | (dolist (file (cdr files)) | ||
| 257 | (message "Writing %s..." (car file)) | ||
| 258 | (goto-char (point-min)) | ||
| 259 | (insert (nth 1 file) "\n") | ||
| 260 | (let ((coding-system-for-write (nth 2 file))) | ||
| 261 | (write-region (point-min) (point-max) (car file))) | ||
| 262 | (delete-region (point-min) (point)))))) | ||
| 263 | |||
| 264 | (defun benchmark-decoder () | ||
| 265 | (let ((gc-cons-threshold 4000000)) | ||
| 266 | (insert "Without optimization:\n") | ||
| 267 | (dolist (files test-file-list) | ||
| 268 | (dolist (file (cdr files)) | ||
| 269 | (let* ((disable-ascii-optimization t) | ||
| 270 | (result (benchmark-run 10 | ||
| 271 | (with-temp-buffer (insert-file-contents (car file)))))) | ||
| 272 | (insert (format "%s: %s\n" (car file) result))))) | ||
| 273 | (insert "With optimization:\n") | ||
| 274 | (dolist (files test-file-list) | ||
| 275 | (dolist (file (cdr files)) | ||
| 276 | (let* ((disable-ascii-optimization nil) | ||
| 277 | (result (benchmark-run 10 | ||
| 278 | (with-temp-buffer (insert-file-contents (car file)))))) | ||
| 279 | (insert (format "%s: %s\n" (car file) result))))))) | ||
diff --git a/test/automated/imenu-test.el b/test/automated/imenu-test.el new file mode 100644 index 00000000000..83e19ebd914 --- /dev/null +++ b/test/automated/imenu-test.el | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | ;;; imenu-tests.el --- Test suite for imenu. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Masatake YAMATO <yamato@redhat.com> | ||
| 6 | ;; Keywords: tools convenience | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'imenu) | ||
| 26 | |||
| 27 | ;; (imenu-simple-scan-deftest-gather-strings-from-list | ||
| 28 | ;; '(nil t 'a (0 . "x") ("c" . "d") ("a" 0 "b") )) | ||
| 29 | ;; => ("b" "a" "d" "c" "x") | ||
| 30 | (defun imenu-simple-scan-deftest-gather-strings-from-list(input) | ||
| 31 | "Gather strings from INPUT, a list." | ||
| 32 | (let ((result ())) | ||
| 33 | (while input | ||
| 34 | (cond | ||
| 35 | ((stringp input) | ||
| 36 | (setq result (cons input result) | ||
| 37 | input nil)) | ||
| 38 | ((atom input) | ||
| 39 | (setq input nil)) | ||
| 40 | ((listp (car input)) | ||
| 41 | (setq result (append | ||
| 42 | (imenu-simple-scan-deftest-gather-strings-from-list (car input)) | ||
| 43 | result) | ||
| 44 | input (cdr input))) | ||
| 45 | ((stringp (car input)) | ||
| 46 | (setq result (cons (car input) result) | ||
| 47 | input (cdr input))) | ||
| 48 | (t | ||
| 49 | (setq input (cdr input))))) | ||
| 50 | result)) | ||
| 51 | |||
| 52 | (defmacro imenu-simple-scan-deftest (name doc major-mode content expected-items) | ||
| 53 | "Generate an ert test for mode-own imenu expression. | ||
| 54 | Run `imenu-create-index-function' at the buffer which content is | ||
| 55 | CONTENT with MAJOR-MODE. A generated test runs `imenu-create-index-function' | ||
| 56 | at the buffer which content is CONTENT with MAJOR-MODE. Then it compares a list | ||
| 57 | of strings which are picked up from the result with EXPECTED-ITEMS." | ||
| 58 | (let ((xname (intern (concat "imenu-simple-scan-deftest-" (symbol-name name))))) | ||
| 59 | `(ert-deftest ,xname () | ||
| 60 | ,doc | ||
| 61 | (with-temp-buffer | ||
| 62 | (insert ,content) | ||
| 63 | (funcall ',major-mode) | ||
| 64 | (let ((result-items (sort (imenu-simple-scan-deftest-gather-strings-from-list | ||
| 65 | (funcall imenu-create-index-function)) | ||
| 66 | #'string-lessp)) | ||
| 67 | (expected-items (sort (copy-sequence ,expected-items) #'string-lessp))) | ||
| 68 | (should (equal result-items expected-items)) | ||
| 69 | ))))) | ||
| 70 | |||
| 71 | (imenu-simple-scan-deftest sh "Test imenu expression for sh-mode." sh-mode "a() | ||
| 72 | { | ||
| 73 | } | ||
| 74 | function b | ||
| 75 | { | ||
| 76 | } | ||
| 77 | function c() | ||
| 78 | { | ||
| 79 | } | ||
| 80 | function ABC_D() | ||
| 81 | { | ||
| 82 | } | ||
| 83 | " '("a" "b" "c" "ABC_D")) | ||
| 84 | |||
| 85 | (provide 'imenu-tests) | ||
| 86 | |||
| 87 | ;;; imenu-tests.el ends here | ||
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index ab8eb4816d3..8462a863b84 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -444,6 +444,28 @@ objects = Thing.objects.all() \\\\ | |||
| 444 | (should (eq (car (python-indent-context)) 'after-line)) | 444 | (should (eq (car (python-indent-context)) 'after-line)) |
| 445 | (should (= (python-indent-calculate-indentation) 0)))) | 445 | (should (= (python-indent-calculate-indentation) 0)))) |
| 446 | 446 | ||
| 447 | (ert-deftest python-indent-block-enders () | ||
| 448 | "Test `python-indent-block-enders' value honoring." | ||
| 449 | (python-tests-with-temp-buffer | ||
| 450 | " | ||
| 451 | Class foo(object): | ||
| 452 | |||
| 453 | def bar(self): | ||
| 454 | if self.baz: | ||
| 455 | return (1, | ||
| 456 | 2, | ||
| 457 | 3) | ||
| 458 | |||
| 459 | else: | ||
| 460 | pass | ||
| 461 | " | ||
| 462 | (python-tests-look-at "3)") | ||
| 463 | (forward-line 1) | ||
| 464 | (= (python-indent-calculate-indentation) 12) | ||
| 465 | (python-tests-look-at "pass") | ||
| 466 | (forward-line 1) | ||
| 467 | (= (python-indent-calculate-indentation) 8))) | ||
| 468 | |||
| 447 | 469 | ||
| 448 | ;;; Navigation | 470 | ;;; Navigation |
| 449 | 471 | ||
| @@ -652,6 +674,201 @@ def decoratorFunctionWithArguments(arg1, arg2, arg3): | |||
| 652 | (python-tests-look-at "return wrapped_f") | 674 | (python-tests-look-at "return wrapped_f") |
| 653 | (line-beginning-position)))))) | 675 | (line-beginning-position)))))) |
| 654 | 676 | ||
| 677 | (ert-deftest python-nav-backward-defun-1 () | ||
| 678 | (python-tests-with-temp-buffer | ||
| 679 | " | ||
| 680 | class A(object): # A | ||
| 681 | |||
| 682 | def a(self): # a | ||
| 683 | pass | ||
| 684 | |||
| 685 | def b(self): # b | ||
| 686 | pass | ||
| 687 | |||
| 688 | class B(object): # B | ||
| 689 | |||
| 690 | class C(object): # C | ||
| 691 | |||
| 692 | def d(self): # d | ||
| 693 | pass | ||
| 694 | |||
| 695 | # def e(self): # e | ||
| 696 | # pass | ||
| 697 | |||
| 698 | def c(self): # c | ||
| 699 | pass | ||
| 700 | |||
| 701 | # def d(self): # d | ||
| 702 | # pass | ||
| 703 | " | ||
| 704 | (goto-char (point-max)) | ||
| 705 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 706 | (python-tests-look-at " def c(self): # c" -1))) | ||
| 707 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 708 | (python-tests-look-at " def d(self): # d" -1))) | ||
| 709 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 710 | (python-tests-look-at " class C(object): # C" -1))) | ||
| 711 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 712 | (python-tests-look-at " class B(object): # B" -1))) | ||
| 713 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 714 | (python-tests-look-at " def b(self): # b" -1))) | ||
| 715 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 716 | (python-tests-look-at " def a(self): # a" -1))) | ||
| 717 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 718 | (python-tests-look-at "class A(object): # A" -1))) | ||
| 719 | (should (not (python-nav-backward-defun))))) | ||
| 720 | |||
| 721 | (ert-deftest python-nav-backward-defun-2 () | ||
| 722 | (python-tests-with-temp-buffer | ||
| 723 | " | ||
| 724 | def decoratorFunctionWithArguments(arg1, arg2, arg3): | ||
| 725 | '''print decorated function call data to stdout. | ||
| 726 | |||
| 727 | Usage: | ||
| 728 | |||
| 729 | @decoratorFunctionWithArguments('arg1', 'arg2') | ||
| 730 | def func(a, b, c=True): | ||
| 731 | pass | ||
| 732 | ''' | ||
| 733 | |||
| 734 | def wwrap(f): | ||
| 735 | print 'Inside wwrap()' | ||
| 736 | def wrapped_f(*args): | ||
| 737 | print 'Inside wrapped_f()' | ||
| 738 | print 'Decorator arguments:', arg1, arg2, arg3 | ||
| 739 | f(*args) | ||
| 740 | print 'After f(*args)' | ||
| 741 | return wrapped_f | ||
| 742 | return wwrap | ||
| 743 | " | ||
| 744 | (goto-char (point-max)) | ||
| 745 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 746 | (python-tests-look-at " def wrapped_f(*args):" -1))) | ||
| 747 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 748 | (python-tests-look-at " def wwrap(f):" -1))) | ||
| 749 | (should (= (save-excursion (python-nav-backward-defun)) | ||
| 750 | (python-tests-look-at "def decoratorFunctionWithArguments(arg1, arg2, arg3):" -1))) | ||
| 751 | (should (not (python-nav-backward-defun))))) | ||
| 752 | |||
| 753 | (ert-deftest python-nav-backward-defun-3 () | ||
| 754 | (python-tests-with-temp-buffer | ||
| 755 | " | ||
| 756 | ''' | ||
| 757 | def u(self): | ||
| 758 | pass | ||
| 759 | |||
| 760 | def v(self): | ||
| 761 | pass | ||
| 762 | |||
| 763 | def w(self): | ||
| 764 | pass | ||
| 765 | ''' | ||
| 766 | |||
| 767 | class A(object): | ||
| 768 | pass | ||
| 769 | " | ||
| 770 | (goto-char (point-min)) | ||
| 771 | (let ((point (python-tests-look-at "class A(object):"))) | ||
| 772 | (should (not (python-nav-backward-defun))) | ||
| 773 | (should (= point (point)))))) | ||
| 774 | |||
| 775 | (ert-deftest python-nav-forward-defun-1 () | ||
| 776 | (python-tests-with-temp-buffer | ||
| 777 | " | ||
| 778 | class A(object): # A | ||
| 779 | |||
| 780 | def a(self): # a | ||
| 781 | pass | ||
| 782 | |||
| 783 | def b(self): # b | ||
| 784 | pass | ||
| 785 | |||
| 786 | class B(object): # B | ||
| 787 | |||
| 788 | class C(object): # C | ||
| 789 | |||
| 790 | def d(self): # d | ||
| 791 | pass | ||
| 792 | |||
| 793 | # def e(self): # e | ||
| 794 | # pass | ||
| 795 | |||
| 796 | def c(self): # c | ||
| 797 | pass | ||
| 798 | |||
| 799 | # def d(self): # d | ||
| 800 | # pass | ||
| 801 | " | ||
| 802 | (goto-char (point-min)) | ||
| 803 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 804 | (python-tests-look-at "(object): # A"))) | ||
| 805 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 806 | (python-tests-look-at "(self): # a"))) | ||
| 807 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 808 | (python-tests-look-at "(self): # b"))) | ||
| 809 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 810 | (python-tests-look-at "(object): # B"))) | ||
| 811 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 812 | (python-tests-look-at "(object): # C"))) | ||
| 813 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 814 | (python-tests-look-at "(self): # d"))) | ||
| 815 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 816 | (python-tests-look-at "(self): # c"))) | ||
| 817 | (should (not (python-nav-forward-defun))))) | ||
| 818 | |||
| 819 | (ert-deftest python-nav-forward-defun-2 () | ||
| 820 | (python-tests-with-temp-buffer | ||
| 821 | " | ||
| 822 | def decoratorFunctionWithArguments(arg1, arg2, arg3): | ||
| 823 | '''print decorated function call data to stdout. | ||
| 824 | |||
| 825 | Usage: | ||
| 826 | |||
| 827 | @decoratorFunctionWithArguments('arg1', 'arg2') | ||
| 828 | def func(a, b, c=True): | ||
| 829 | pass | ||
| 830 | ''' | ||
| 831 | |||
| 832 | def wwrap(f): | ||
| 833 | print 'Inside wwrap()' | ||
| 834 | def wrapped_f(*args): | ||
| 835 | print 'Inside wrapped_f()' | ||
| 836 | print 'Decorator arguments:', arg1, arg2, arg3 | ||
| 837 | f(*args) | ||
| 838 | print 'After f(*args)' | ||
| 839 | return wrapped_f | ||
| 840 | return wwrap | ||
| 841 | " | ||
| 842 | (goto-char (point-min)) | ||
| 843 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 844 | (python-tests-look-at "(arg1, arg2, arg3):"))) | ||
| 845 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 846 | (python-tests-look-at "(f):"))) | ||
| 847 | (should (= (save-excursion (python-nav-forward-defun)) | ||
| 848 | (python-tests-look-at "(*args):"))) | ||
| 849 | (should (not (python-nav-forward-defun))))) | ||
| 850 | |||
| 851 | (ert-deftest python-nav-forward-defun-3 () | ||
| 852 | (python-tests-with-temp-buffer | ||
| 853 | " | ||
| 854 | class A(object): | ||
| 855 | pass | ||
| 856 | |||
| 857 | ''' | ||
| 858 | def u(self): | ||
| 859 | pass | ||
| 860 | |||
| 861 | def v(self): | ||
| 862 | pass | ||
| 863 | |||
| 864 | def w(self): | ||
| 865 | pass | ||
| 866 | ''' | ||
| 867 | " | ||
| 868 | (goto-char (point-min)) | ||
| 869 | (let ((point (python-tests-look-at "(object):"))) | ||
| 870 | (should (not (python-nav-forward-defun))) | ||
| 871 | (should (= point (point)))))) | ||
| 655 | 872 | ||
| 656 | (ert-deftest python-nav-beginning-of-statement-1 () | 873 | (ert-deftest python-nav-beginning-of-statement-1 () |
| 657 | (python-tests-with-temp-buffer | 874 | (python-tests-with-temp-buffer |
| @@ -1456,66 +1673,133 @@ Using `python-shell-interpreter' and | |||
| 1456 | 1673 | ||
| 1457 | 1674 | ||
| 1458 | ;;; Imenu | 1675 | ;;; Imenu |
| 1459 | (ert-deftest python-imenu-prev-index-position-1 () | 1676 | |
| 1460 | (require 'imenu) | 1677 | (ert-deftest python-imenu-create-index-1 () |
| 1461 | (python-tests-with-temp-buffer | 1678 | (python-tests-with-temp-buffer |
| 1462 | " | 1679 | " |
| 1463 | def decoratorFunctionWithArguments(arg1, arg2, arg3): | 1680 | class Foo(models.Model): |
| 1681 | pass | ||
| 1682 | |||
| 1683 | |||
| 1684 | class Bar(models.Model): | ||
| 1685 | pass | ||
| 1686 | |||
| 1687 | |||
| 1688 | def decorator(arg1, arg2, arg3): | ||
| 1464 | '''print decorated function call data to stdout. | 1689 | '''print decorated function call data to stdout. |
| 1465 | 1690 | ||
| 1466 | Usage: | 1691 | Usage: |
| 1467 | 1692 | ||
| 1468 | @decoratorFunctionWithArguments('arg1', 'arg2') | 1693 | @decorator('arg1', 'arg2') |
| 1469 | def func(a, b, c=True): | 1694 | def func(a, b, c=True): |
| 1470 | pass | 1695 | pass |
| 1471 | ''' | 1696 | ''' |
| 1472 | 1697 | ||
| 1473 | def wwrap(f): | 1698 | def wrap(f): |
| 1474 | print 'Inside wwrap()' | 1699 | print ('wrap') |
| 1475 | def wrapped_f(*args): | 1700 | def wrapped_f(*args): |
| 1476 | print 'Inside wrapped_f()' | 1701 | print ('wrapped_f') |
| 1477 | print 'Decorator arguments:', arg1, arg2, arg3 | 1702 | print ('Decorator arguments:', arg1, arg2, arg3) |
| 1478 | f(*args) | 1703 | f(*args) |
| 1479 | print 'After f(*args)' | 1704 | print ('called f(*args)') |
| 1480 | return wrapped_f | 1705 | return wrapped_f |
| 1481 | return wwrap | 1706 | return wrap |
| 1482 | 1707 | ||
| 1483 | def test(): # Some comment | ||
| 1484 | 'This is a test function' | ||
| 1485 | print 'test' | ||
| 1486 | 1708 | ||
| 1487 | class C(object): | 1709 | class Baz(object): |
| 1488 | 1710 | ||
| 1489 | def m(self): | 1711 | def a(self): |
| 1490 | self.c() | 1712 | pass |
| 1491 | 1713 | ||
| 1492 | def b(): | 1714 | def b(self): |
| 1493 | pass | 1715 | pass |
| 1494 | 1716 | ||
| 1495 | def a(): | 1717 | class Frob(object): |
| 1718 | |||
| 1719 | def c(self): | ||
| 1496 | pass | 1720 | pass |
| 1721 | " | ||
| 1722 | (goto-char (point-max)) | ||
| 1723 | (should (equal | ||
| 1724 | (list | ||
| 1725 | (cons "Foo (class)" (copy-marker 2)) | ||
| 1726 | (cons "Bar (class)" (copy-marker 38)) | ||
| 1727 | (list | ||
| 1728 | "decorator (def)" | ||
| 1729 | (cons "*function definition*" (copy-marker 74)) | ||
| 1730 | (list | ||
| 1731 | "wrap (def)" | ||
| 1732 | (cons "*function definition*" (copy-marker 254)) | ||
| 1733 | (cons "wrapped_f (def)" (copy-marker 294)))) | ||
| 1734 | (list | ||
| 1735 | "Baz (class)" | ||
| 1736 | (cons "*class definition*" (copy-marker 519)) | ||
| 1737 | (cons "a (def)" (copy-marker 539)) | ||
| 1738 | (cons "b (def)" (copy-marker 570)) | ||
| 1739 | (list | ||
| 1740 | "Frob (class)" | ||
| 1741 | (cons "*class definition*" (copy-marker 601)) | ||
| 1742 | (cons "c (def)" (copy-marker 626))))) | ||
| 1743 | (python-imenu-create-index))))) | ||
| 1744 | |||
| 1745 | (ert-deftest python-imenu-create-flat-index-1 () | ||
| 1746 | (python-tests-with-temp-buffer | ||
| 1747 | " | ||
| 1748 | class Foo(models.Model): | ||
| 1749 | pass | ||
| 1497 | 1750 | ||
| 1498 | def c(self): | 1751 | |
| 1752 | class Bar(models.Model): | ||
| 1753 | pass | ||
| 1754 | |||
| 1755 | |||
| 1756 | def decorator(arg1, arg2, arg3): | ||
| 1757 | '''print decorated function call data to stdout. | ||
| 1758 | |||
| 1759 | Usage: | ||
| 1760 | |||
| 1761 | @decorator('arg1', 'arg2') | ||
| 1762 | def func(a, b, c=True): | ||
| 1499 | pass | 1763 | pass |
| 1764 | ''' | ||
| 1765 | |||
| 1766 | def wrap(f): | ||
| 1767 | print ('wrap') | ||
| 1768 | def wrapped_f(*args): | ||
| 1769 | print ('wrapped_f') | ||
| 1770 | print ('Decorator arguments:', arg1, arg2, arg3) | ||
| 1771 | f(*args) | ||
| 1772 | print ('called f(*args)') | ||
| 1773 | return wrapped_f | ||
| 1774 | return wrap | ||
| 1775 | |||
| 1776 | |||
| 1777 | class Baz(object): | ||
| 1778 | |||
| 1779 | def a(self): | ||
| 1780 | pass | ||
| 1781 | |||
| 1782 | def b(self): | ||
| 1783 | pass | ||
| 1784 | |||
| 1785 | class Frob(object): | ||
| 1786 | |||
| 1787 | def c(self): | ||
| 1788 | pass | ||
| 1500 | " | 1789 | " |
| 1501 | (let ((expected | 1790 | (goto-char (point-max)) |
| 1502 | '(("*Rescan*" . -99) | 1791 | (should (equal |
| 1503 | ("decoratorFunctionWithArguments" . 2) | 1792 | (list (cons "Foo" (copy-marker 2)) |
| 1504 | ("decoratorFunctionWithArguments.wwrap" . 224) | 1793 | (cons "Bar" (copy-marker 38)) |
| 1505 | ("decoratorFunctionWithArguments.wwrap.wrapped_f" . 273) | 1794 | (cons "decorator" (copy-marker 74)) |
| 1506 | ("test" . 500) | 1795 | (cons "decorator.wrap" (copy-marker 254)) |
| 1507 | ("C" . 575) | 1796 | (cons "decorator.wrap.wrapped_f" (copy-marker 294)) |
| 1508 | ("C.m" . 593) | 1797 | (cons "Baz" (copy-marker 519)) |
| 1509 | ("C.m.b" . 628) | 1798 | (cons "Baz.a" (copy-marker 539)) |
| 1510 | ("C.m.a" . 663) | 1799 | (cons "Baz.b" (copy-marker 570)) |
| 1511 | ("C.c" . 698)))) | 1800 | (cons "Baz.Frob" (copy-marker 601)) |
| 1512 | (mapc | 1801 | (cons "Baz.Frob.c" (copy-marker 626))) |
| 1513 | (lambda (elt) | 1802 | (python-imenu-create-flat-index))))) |
| 1514 | (should (= (cdr (assoc-string (car elt) expected)) | ||
| 1515 | (if (markerp (cdr elt)) | ||
| 1516 | (marker-position (cdr elt)) | ||
| 1517 | (cdr elt))))) | ||
| 1518 | (imenu--make-index-alist))))) | ||
| 1519 | 1803 | ||
| 1520 | 1804 | ||
| 1521 | ;;; Misc helpers | 1805 | ;;; Misc helpers |
| @@ -1546,13 +1830,13 @@ class C(object): | |||
| 1546 | return [] | 1830 | return [] |
| 1547 | 1831 | ||
| 1548 | def b(): | 1832 | def b(): |
| 1549 | pass | 1833 | do_b() |
| 1550 | 1834 | ||
| 1551 | def a(): | 1835 | def a(): |
| 1552 | pass | 1836 | do_a() |
| 1553 | 1837 | ||
| 1554 | def c(self): | 1838 | def c(self): |
| 1555 | pass | 1839 | do_c() |
| 1556 | " | 1840 | " |
| 1557 | (forward-line 1) | 1841 | (forward-line 1) |
| 1558 | (should (string= "C" (python-info-current-defun))) | 1842 | (should (string= "C" (python-info-current-defun))) |
| @@ -1582,7 +1866,7 @@ class C(object): | |||
| 1582 | (python-tests-look-at "def c(self):") | 1866 | (python-tests-look-at "def c(self):") |
| 1583 | (should (string= "C.c" (python-info-current-defun))) | 1867 | (should (string= "C.c" (python-info-current-defun))) |
| 1584 | (should (string= "def C.c" (python-info-current-defun t))) | 1868 | (should (string= "def C.c" (python-info-current-defun t))) |
| 1585 | (python-tests-look-at "pass") | 1869 | (python-tests-look-at "do_c()") |
| 1586 | (should (string= "C.c" (python-info-current-defun))) | 1870 | (should (string= "C.c" (python-info-current-defun))) |
| 1587 | (should (string= "def C.c" (python-info-current-defun t))))) | 1871 | (should (string= "def C.c" (python-info-current-defun t))))) |
| 1588 | 1872 | ||
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el index 0ebe6d44e34..77dd62821f7 100644 --- a/test/automated/ruby-mode-tests.el +++ b/test/automated/ruby-mode-tests.el | |||
| @@ -84,6 +84,9 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 84 | (ert-deftest ruby-singleton-class-no-heredoc-font-lock () | 84 | (ert-deftest ruby-singleton-class-no-heredoc-font-lock () |
| 85 | (ruby-assert-face "class<<a" 8 nil)) | 85 | (ruby-assert-face "class<<a" 8 nil)) |
| 86 | 86 | ||
| 87 | (ert-deftest ruby-heredoc-highlights-interpolations () | ||
| 88 | (ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 font-lock-variable-name-face)) | ||
| 89 | |||
| 87 | (ert-deftest ruby-deep-indent () | 90 | (ert-deftest ruby-deep-indent () |
| 88 | (let ((ruby-deep-arglist nil) | 91 | (let ((ruby-deep-arglist nil) |
| 89 | (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) | 92 | (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) |
| @@ -109,6 +112,18 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 109 | (ert-deftest ruby-regexp-starts-after-string () | 112 | (ert-deftest ruby-regexp-starts-after-string () |
| 110 | (ruby-assert-state "'(/', /\d+/" 3 ?/ 8)) | 113 | (ruby-assert-state "'(/', /\d+/" 3 ?/ 8)) |
| 111 | 114 | ||
| 115 | (ert-deftest ruby-regexp-interpolation-is-highlighted () | ||
| 116 | (ruby-assert-face "/#{foobs}/" 4 font-lock-variable-name-face)) | ||
| 117 | |||
| 118 | (ert-deftest ruby-regexp-skips-over-interpolation () | ||
| 119 | (ruby-assert-state "/#{foobs.join('/')}/" 3 nil)) | ||
| 120 | |||
| 121 | (ert-deftest ruby-regexp-continues-till-end-when-unclosed () | ||
| 122 | (ruby-assert-state "/bars" 3 ?/)) | ||
| 123 | |||
| 124 | (ert-deftest ruby-regexp-can-be-multiline () | ||
| 125 | (ruby-assert-state "/bars\ntees # toots \nfoos/" 3 nil)) | ||
| 126 | |||
| 112 | (ert-deftest ruby-indent-simple () | 127 | (ert-deftest ruby-indent-simple () |
| 113 | (ruby-should-indent-buffer | 128 | (ruby-should-indent-buffer |
| 114 | "if foo | 129 | "if foo |
| @@ -325,6 +340,13 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 325 | (search-forward "tee") | 340 | (search-forward "tee") |
| 326 | (should (string= (thing-at-point 'symbol) "tee"))))) | 341 | (should (string= (thing-at-point 'symbol) "tee"))))) |
| 327 | 342 | ||
| 343 | (ert-deftest ruby-interpolation-inside-percent-literal () | ||
| 344 | (let ((s "%( #{boo} )")) | ||
| 345 | (ruby-assert-face s 1 font-lock-string-face) | ||
| 346 | (ruby-assert-face s 4 font-lock-variable-name-face) | ||
| 347 | (ruby-assert-face s 10 font-lock-string-face) | ||
| 348 | (ruby-assert-state s 8 nil))) | ||
| 349 | |||
| 328 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () | 350 | (ert-deftest ruby-interpolation-inside-percent-literal-with-paren () |
| 329 | :expected-result :failed | 351 | :expected-result :failed |
| 330 | (let ((s "%(^#{\")\"}^)")) | 352 | (let ((s "%(^#{\")\"}^)")) |
| @@ -334,6 +356,23 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 334 | ;; It's confused by the closing paren in the middle. | 356 | ;; It's confused by the closing paren in the middle. |
| 335 | (ruby-assert-state s 8 nil))) | 357 | (ruby-assert-state s 8 nil))) |
| 336 | 358 | ||
| 359 | (ert-deftest ruby-interpolation-inside-double-quoted-percent-literals () | ||
| 360 | (ruby-assert-face "%Q{foo #@bar}" 8 font-lock-variable-name-face) | ||
| 361 | (ruby-assert-face "%W{foo #@bar}" 8 font-lock-variable-name-face) | ||
| 362 | (ruby-assert-face "%r{foo #@bar}" 8 font-lock-variable-name-face) | ||
| 363 | (ruby-assert-face "%x{foo #@bar}" 8 font-lock-variable-name-face)) | ||
| 364 | |||
| 365 | (ert-deftest ruby-no-interpolation-in-single-quoted-literals () | ||
| 366 | (ruby-assert-face "'foo #@bar'" 7 font-lock-string-face) | ||
| 367 | (ruby-assert-face "%q{foo #@bar}" 8 font-lock-string-face) | ||
| 368 | (ruby-assert-face "%w{foo #@bar}" 8 font-lock-string-face) | ||
| 369 | (ruby-assert-face "%s{foo #@bar}" 8 font-lock-string-face)) | ||
| 370 | |||
| 371 | (ert-deftest ruby-no-unknown-percent-literals () | ||
| 372 | ;; No folding of case. | ||
| 373 | (ruby-assert-face "%S{foo}" 4 nil) | ||
| 374 | (ruby-assert-face "%R{foo}" 4 nil)) | ||
| 375 | |||
| 337 | (ert-deftest ruby-add-log-current-method-examples () | 376 | (ert-deftest ruby-add-log-current-method-examples () |
| 338 | (let ((pairs '(("foo" . "#foo") | 377 | (let ((pairs '(("foo" . "#foo") |
| 339 | ("C.foo" . ".foo") | 378 | ("C.foo" . ".foo") |
| @@ -487,6 +526,42 @@ VALUES-PLIST is a list with alternating index and value elements." | |||
| 487 | (ruby-beginning-of-block) | 526 | (ruby-beginning-of-block) |
| 488 | (should (= 1 (line-number-at-pos))))) | 527 | (should (= 1 (line-number-at-pos))))) |
| 489 | 528 | ||
| 529 | (ert-deftest ruby-move-to-block-does-not-fold-case () | ||
| 530 | (ruby-with-temp-buffer | ||
| 531 | (ruby-test-string | ||
| 532 | "foo do | ||
| 533 | | Module.to_s | ||
| 534 | |end") | ||
| 535 | (end-of-buffer) | ||
| 536 | (let ((case-fold-search t)) | ||
| 537 | (ruby-beginning-of-block)) | ||
| 538 | (should (= 1 (line-number-at-pos))))) | ||
| 539 | |||
| 540 | (ert-deftest ruby-beginning-of-defun-does-not-fold-case () | ||
| 541 | (ruby-with-temp-buffer | ||
| 542 | (ruby-test-string | ||
| 543 | "class C | ||
| 544 | | def bar | ||
| 545 | | Class.to_s | ||
| 546 | | end | ||
| 547 | |end") | ||
| 548 | (goto-line 4) | ||
| 549 | (let ((case-fold-search t)) | ||
| 550 | (beginning-of-defun)) | ||
| 551 | (should (= 2 (line-number-at-pos))))) | ||
| 552 | |||
| 553 | (ert-deftest ruby-end-of-defun-skips-to-next-line-after-the-method () | ||
| 554 | (ruby-with-temp-buffer | ||
| 555 | (ruby-test-string | ||
| 556 | "class D | ||
| 557 | | def tee | ||
| 558 | | 'ho hum' | ||
| 559 | | end | ||
| 560 | |end") | ||
| 561 | (goto-line 2) | ||
| 562 | (end-of-defun) | ||
| 563 | (should (= 5 (line-number-at-pos))))) | ||
| 564 | |||
| 490 | (provide 'ruby-mode-tests) | 565 | (provide 'ruby-mode-tests) |
| 491 | 566 | ||
| 492 | ;;; ruby-mode-tests.el ends here | 567 | ;;; ruby-mode-tests.el ends here |
diff --git a/test/eshell.el b/test/eshell.el index 7baeb58a56a..126a47220c4 100644 --- a/test/eshell.el +++ b/test/eshell.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; esh-test.el --- Eshell test suite | 1 | ;;; tests/eshell.el --- Eshell test suite |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1999-2013 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1999-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -21,55 +21,20 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Commentary: | 22 | ;;; Commentary: |
| 23 | 23 | ||
| 24 | ;; The purpose of this module is to verify that Eshell works as | 24 | ;; Eshell test suite. |
| 25 | ;; expected. To run it on your system, use the command | ||
| 26 | ;; \\[eshell-test]. | ||
| 27 | 25 | ||
| 28 | ;;; Code: | 26 | ;;; Code: |
| 29 | 27 | ||
| 30 | (eval-when-compile | 28 | (require 'ert) |
| 31 | (require 'cl-lib) | 29 | (require 'eshell) |
| 32 | (require 'eshell) | ||
| 33 | (require 'esh-util)) | ||
| 34 | (require 'esh-mode) | ||
| 35 | |||
| 36 | (defgroup eshell-test nil | ||
| 37 | "This module is meant to ensure that Eshell is working correctly." | ||
| 38 | :tag "Eshell test suite" | ||
| 39 | :group 'eshell) | ||
| 40 | |||
| 41 | ;;; User Variables: | ||
| 42 | |||
| 43 | (defface eshell-test-ok | ||
| 44 | '((((class color) (background light)) (:foreground "Green" :bold t)) | ||
| 45 | (((class color) (background dark)) (:foreground "Green" :bold t))) | ||
| 46 | "The face used to highlight OK result strings." | ||
| 47 | :group 'eshell-test) | ||
| 48 | (define-obsolete-face-alias 'eshell-test-ok-face 'eshell-test-ok "22.1") | ||
| 49 | |||
| 50 | (defface eshell-test-failed | ||
| 51 | '((((class color) (background light)) (:foreground "OrangeRed" :bold t)) | ||
| 52 | (((class color) (background dark)) (:foreground "OrangeRed" :bold t)) | ||
| 53 | (t (:bold t))) | ||
| 54 | "The face used to highlight FAILED result strings." | ||
| 55 | :group 'eshell-test) | ||
| 56 | (define-obsolete-face-alias 'eshell-test-failed-face 'eshell-test-failed "22.1") | ||
| 57 | |||
| 58 | (defcustom eshell-show-usage-metrics nil | ||
| 59 | "If non-nil, display different usage metrics for each Eshell command." | ||
| 60 | :set (lambda (symbol value) | ||
| 61 | (if value | ||
| 62 | (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics) | ||
| 63 | (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics)) | ||
| 64 | (set symbol value)) | ||
| 65 | :type '(choice (const :tag "No metrics" nil) | ||
| 66 | (const :tag "Cons cells consumed" t) | ||
| 67 | (const :tag "Time elapsed" 0)) | ||
| 68 | :group 'eshell-test) | ||
| 69 | 30 | ||
| 70 | ;;; Code: | 31 | (defmacro with-temp-eshell (&rest body) |
| 71 | 32 | "Evaluate BODY in a temporary Eshell buffer." | |
| 72 | (defvar test-buffer) | 33 | `(let ((eshell-buffer (eshell t))) |
| 34 | (unwind-protect | ||
| 35 | (with-current-buffer eshell-buffer | ||
| 36 | ,@body) | ||
| 37 | (kill-buffer eshell-buffer)))) | ||
| 73 | 38 | ||
| 74 | (defun eshell-insert-command (text &optional func) | 39 | (defun eshell-insert-command (text &optional func) |
| 75 | "Insert a command at the end of the buffer." | 40 | "Insert a command at the end of the buffer." |
| @@ -87,335 +52,141 @@ | |||
| 87 | (eshell-insert-command text func) | 52 | (eshell-insert-command text func) |
| 88 | (eshell-match-result regexp)) | 53 | (eshell-match-result regexp)) |
| 89 | 54 | ||
| 90 | (defvar eshell-test-failures nil) | 55 | ;;; Tests: |
| 91 | 56 | ||
| 92 | (defun eshell-run-test (module funcsym label command) | 57 | (ert-deftest eshell-test/simple-command-result () |
| 93 | "Test whether FORM evaluates to a non-nil value." | 58 | "Test `eshell-command-result' with a simple command." |
| 94 | (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module))))) | 59 | (should (equal (eshell-command-result "+ 1 2") 3))) |
| 95 | (or (memq sym (eshell-subgroups 'eshell)) | ||
| 96 | (eshell-using-module sym))) | ||
| 97 | (with-current-buffer test-buffer | ||
| 98 | (insert-before-markers | ||
| 99 | (format "%-70s " (substring label 0 (min 70 (length label))))) | ||
| 100 | (insert-before-markers " ....") | ||
| 101 | (eshell-redisplay)) | ||
| 102 | (let ((truth (eval command))) | ||
| 103 | (with-current-buffer test-buffer | ||
| 104 | (delete-char -6) | ||
| 105 | (insert-before-markers | ||
| 106 | "[" (let (str) | ||
| 107 | (if truth | ||
| 108 | (progn | ||
| 109 | (setq str " OK ") | ||
| 110 | (put-text-property 0 6 'face 'eshell-test-ok str)) | ||
| 111 | (setq str "FAILED") | ||
| 112 | (setq eshell-test-failures (1+ eshell-test-failures)) | ||
| 113 | (put-text-property 0 6 'face 'eshell-test-failed str)) | ||
| 114 | str) "]") | ||
| 115 | (add-text-properties (line-beginning-position) (point) | ||
| 116 | (list 'test-func funcsym)) | ||
| 117 | (eshell-redisplay))))) | ||
| 118 | |||
| 119 | (defun eshell-test-goto-func () | ||
| 120 | "Jump to the function that defines a particular test." | ||
| 121 | (interactive) | ||
| 122 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 123 | (when fsym | ||
| 124 | (let* ((def (symbol-function fsym)) | ||
| 125 | (library (locate-library (symbol-file fsym 'defun))) | ||
| 126 | (name (substring (symbol-name fsym) | ||
| 127 | (length "eshell-test--"))) | ||
| 128 | (inhibit-redisplay t)) | ||
| 129 | (find-file library) | ||
| 130 | (goto-char (point-min)) | ||
| 131 | (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+" | ||
| 132 | name)) | ||
| 133 | (beginning-of-line))))) | ||
| 134 | |||
| 135 | (defun eshell-run-one-test (&optional arg) | ||
| 136 | "Jump to the function that defines a particular test." | ||
| 137 | (interactive "P") | ||
| 138 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 139 | (when fsym | ||
| 140 | (beginning-of-line) | ||
| 141 | (delete-region (point) (line-end-position)) | ||
| 142 | (let ((test-buffer (current-buffer))) | ||
| 143 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 144 | (save-window-excursion (eshell t)))) | ||
| 145 | (funcall fsym) | ||
| 146 | (unless arg | ||
| 147 | (kill-buffer (current-buffer))))))) | ||
| 148 | |||
| 149 | ;;;###autoload | ||
| 150 | (defun eshell-test (&optional arg) | ||
| 151 | "Test Eshell to verify that it works as expected." | ||
| 152 | (interactive "P") | ||
| 153 | (let* ((begin (float-time)) | ||
| 154 | (test-buffer (get-buffer-create "*eshell test*"))) | ||
| 155 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 156 | (save-window-excursion (eshell t)))) | ||
| 157 | (with-current-buffer test-buffer | ||
| 158 | (erase-buffer) | ||
| 159 | (setq major-mode 'eshell-test-mode) | ||
| 160 | (setq mode-name "EShell Test") | ||
| 161 | (set (make-local-variable 'eshell-test-failures) 0) | ||
| 162 | (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func) | ||
| 163 | (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test) | ||
| 164 | (local-set-key [(control ?m)] 'eshell-test-goto-func) | ||
| 165 | (local-set-key [return] 'eshell-test-goto-func) | ||
| 166 | |||
| 167 | (insert "Testing Eshell under " (emacs-version)) | ||
| 168 | (switch-to-buffer test-buffer) | ||
| 169 | (delete-other-windows)) | ||
| 170 | (dolist (funcname (sort (all-completions "eshell-test--" | ||
| 171 | obarray 'functionp) | ||
| 172 | 'string-lessp)) | ||
| 173 | (with-current-buffer test-buffer | ||
| 174 | (insert "\n")) | ||
| 175 | (funcall (intern-soft funcname))) | ||
| 176 | (with-current-buffer test-buffer | ||
| 177 | (insert (format "\n\n--- %s --- (completed in %d seconds)\n" | ||
| 178 | (current-time-string) | ||
| 179 | (- (float-time) begin))) | ||
| 180 | (message "Eshell test suite completed: %s failure%s" | ||
| 181 | (if (> eshell-test-failures 0) | ||
| 182 | (number-to-string eshell-test-failures) | ||
| 183 | "No") | ||
| 184 | (if (= eshell-test-failures 1) "" "s")))) | ||
| 185 | (goto-char eshell-last-output-end) | ||
| 186 | (unless arg | ||
| 187 | (kill-buffer (current-buffer)))) | ||
| 188 | |||
| 189 | |||
| 190 | (defvar eshell-metric-before-command 0) | ||
| 191 | (defvar eshell-metric-after-command 0) | ||
| 192 | |||
| 193 | (defun eshell-show-usage-metrics () | ||
| 194 | "If run at Eshell mode startup, metrics are shown after each command." | ||
| 195 | (set (make-local-variable 'eshell-metric-before-command) | ||
| 196 | (if (eq eshell-show-usage-metrics t) | ||
| 197 | 0 | ||
| 198 | (current-time))) | ||
| 199 | (set (make-local-variable 'eshell-metric-after-command) | ||
| 200 | (if (eq eshell-show-usage-metrics t) | ||
| 201 | 0 | ||
| 202 | (current-time))) | ||
| 203 | |||
| 204 | (add-hook 'eshell-pre-command-hook | ||
| 205 | (function | ||
| 206 | (lambda () | ||
| 207 | (setq eshell-metric-before-command | ||
| 208 | (if (eq eshell-show-usage-metrics t) | ||
| 209 | (car (memory-use-counts)) | ||
| 210 | (current-time))))) nil t) | ||
| 211 | |||
| 212 | (add-hook 'eshell-post-command-hook | ||
| 213 | (function | ||
| 214 | (lambda () | ||
| 215 | (setq eshell-metric-after-command | ||
| 216 | (if (eq eshell-show-usage-metrics t) | ||
| 217 | (car (memory-use-counts)) | ||
| 218 | (current-time))) | ||
| 219 | (eshell-interactive-print | ||
| 220 | (concat | ||
| 221 | (int-to-string | ||
| 222 | (if (eq eshell-show-usage-metrics t) | ||
| 223 | (- eshell-metric-after-command | ||
| 224 | eshell-metric-before-command 7) | ||
| 225 | (- (float-time | ||
| 226 | eshell-metric-after-command) | ||
| 227 | (float-time | ||
| 228 | eshell-metric-before-command)))) | ||
| 229 | "\n")))) | ||
| 230 | nil t)) | ||
| 231 | |||
| 232 | |||
| 233 | ;;; The tests. | ||
| 234 | |||
| 235 | (defmacro eshell-deftest (module name label &rest forms) | ||
| 236 | (declare (indent 2)) | ||
| 237 | (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) | ||
| 238 | nil | ||
| 239 | (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) | ||
| 240 | `(eval-when-compile | ||
| 241 | (ignore | ||
| 242 | (defun ,fsym () ,label | ||
| 243 | (eshell-run-test (quote ,module) (quote ,fsym) ,label | ||
| 244 | (quote (progn ,@forms))))))))) | ||
| 245 | |||
| 246 | |||
| 247 | (eshell-deftest mode same-window-buffer-names | ||
| 248 | "`eshell-buffer-name' is a member of `same-window-buffer-names'" | ||
| 249 | (member eshell-buffer-name same-window-buffer-names)) | ||
| 250 | |||
| 251 | (eshell-deftest mode eshell-directory-exists | ||
| 252 | "`eshell-directory-name' exists and is writable" | ||
| 253 | (file-writable-p eshell-directory-name)) | ||
| 254 | |||
| 255 | (eshell-deftest mode eshell-directory-modes | ||
| 256 | "`eshell-directory-name' has correct access protections" | ||
| 257 | (or (eshell-under-windows-p) | ||
| 258 | (= (file-modes eshell-directory-name) | ||
| 259 | eshell-private-directory-modes))) | ||
| 260 | |||
| 261 | (eshell-deftest mode simple-command-result | ||
| 262 | "`eshell-command-result' works with a simple command." | ||
| 263 | (= (eshell-command-result "+ 1 2") 3)) | ||
| 264 | |||
| 265 | |||
| 266 | (require 'em-banner) | ||
| 267 | |||
| 268 | (eshell-deftest banner banner-displayed | ||
| 269 | "Startup banner is displayed at point-min" | ||
| 270 | (cl-assert eshell-banner-message) | ||
| 271 | (let ((msg (eval eshell-banner-message))) | ||
| 272 | (cl-assert msg) | ||
| 273 | (goto-char (point-min)) | ||
| 274 | (looking-at msg))) | ||
| 275 | |||
| 276 | |||
| 277 | (require 'esh-cmd) | ||
| 278 | |||
| 279 | (eshell-deftest var last-result-var | ||
| 280 | "\"last result\" variable" | ||
| 281 | (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) | ||
| 282 | |||
| 283 | (eshell-deftest var last-result-var2 | ||
| 284 | "\"last result\" variable" | ||
| 285 | (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) | ||
| 286 | |||
| 287 | (eshell-deftest var last-arg-var | ||
| 288 | "\"last arg\" variable" | ||
| 289 | (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) | ||
| 290 | |||
| 291 | (eshell-deftest cmd lisp-command | ||
| 292 | "Evaluate Lisp command" | ||
| 293 | (eshell-command-result-p "(+ 1 2)" "3")) | ||
| 294 | |||
| 295 | (eshell-deftest cmd lisp-command-args | ||
| 296 | "Evaluate Lisp command (ignore args)" | ||
| 297 | (eshell-command-result-p "(+ 1 2) 3" "3")) | ||
| 298 | |||
| 299 | (eshell-deftest cmd subcommand | ||
| 300 | "Run subcommand" | ||
| 301 | (eshell-command-result-p "{+ 1 2}" "3\n")) | ||
| 302 | |||
| 303 | (eshell-deftest cmd subcommand-args | ||
| 304 | "Run subcommand (ignore args)" | ||
| 305 | (eshell-command-result-p "{+ 1 2} 3" "3\n")) | ||
| 306 | |||
| 307 | (eshell-deftest cmd subcommand-lisp | ||
| 308 | "Run subcommand + Lisp form" | ||
| 309 | (eshell-command-result-p "{(+ 1 2)}" "3\n")) | ||
| 310 | |||
| 311 | (eshell-deftest cmd named-command | ||
| 312 | "Execute named command" | ||
| 313 | (eshell-command-result-p "+ 1 2" "3\n")) | ||
| 314 | |||
| 315 | |||
| 316 | (require 'esh-mode) | ||
| 317 | |||
| 318 | (eshell-deftest mode major-mode | ||
| 319 | "Major mode is correct" | ||
| 320 | (eq major-mode 'eshell-mode)) | ||
| 321 | |||
| 322 | (eshell-deftest mode eshell-mode-variable | ||
| 323 | "`eshell-mode' is true" | ||
| 324 | (eq eshell-mode t)) | ||
| 325 | |||
| 326 | (eshell-deftest var window-height | ||
| 327 | "LINES equals window height" | ||
| 328 | (let ((eshell-stringify-t t)) | ||
| 329 | (eshell-command-result-p "= $LINES (window-height)" "t\n"))) | ||
| 330 | |||
| 331 | (eshell-deftest mode command-running-p | ||
| 332 | "Modeline shows no command running" | ||
| 333 | (or (featurep 'xemacs) | ||
| 334 | (not eshell-status-in-modeline) | ||
| 335 | (and (memq 'eshell-command-running-string mode-line-format) | ||
| 336 | (equal eshell-command-running-string "--")))) | ||
| 337 | |||
| 338 | (eshell-deftest arg forward-arg | ||
| 339 | "Move across command arguments" | ||
| 340 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) | ||
| 341 | (let ((here (point)) begin valid) | ||
| 342 | (eshell-bol) | ||
| 343 | (setq begin (point)) | ||
| 344 | (eshell-forward-argument 4) | ||
| 345 | (setq valid (= here (point))) | ||
| 346 | (eshell-backward-argument 4) | ||
| 347 | (prog1 | ||
| 348 | (and valid (= begin (point))) | ||
| 349 | (eshell-bol) | ||
| 350 | (delete-region (point) (point-max))))) | ||
| 351 | |||
| 352 | (eshell-deftest mode queue-input | ||
| 353 | "Queue command input" | ||
| 354 | (eshell-insert-command "sleep 2") | ||
| 355 | (eshell-insert-command "echo alpha" 'eshell-queue-input) | ||
| 356 | (let ((count 10)) | ||
| 357 | (while (and eshell-current-command | ||
| 358 | (> count 0)) | ||
| 359 | (sit-for 1 0) | ||
| 360 | (setq count (1- count)))) | ||
| 361 | (eshell-match-result "alpha\n")) | ||
| 362 | |||
| 363 | ; (eshell-deftest proc send-to-subprocess | ||
| 364 | ; "Send input to a subprocess" | ||
| 365 | ; ;; jww (1999-12-06): what about when bc is unavailable? | ||
| 366 | ; (if (not (eshell-search-path "bc")) | ||
| 367 | ; t | ||
| 368 | ; (eshell-insert-command "bc") | ||
| 369 | ; (eshell-insert-command "1 + 2") | ||
| 370 | ; (sit-for 1 0) | ||
| 371 | ; (forward-line -1) | ||
| 372 | ; (prog1 | ||
| 373 | ; (looking-at "3\n") | ||
| 374 | ; (eshell-insert-command "quit") | ||
| 375 | ; (sit-for 1 0)))) | ||
| 376 | |||
| 377 | (eshell-deftest io flush-output | ||
| 378 | "Flush previous output" | ||
| 379 | (eshell-insert-command "echo alpha") | ||
| 380 | (eshell-kill-output) | ||
| 381 | (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) | ||
| 382 | (forward-line) | ||
| 383 | (= (point) eshell-last-output-start))) | ||
| 384 | |||
| 385 | (eshell-deftest mode run-old-command | ||
| 386 | "Re-run an old command" | ||
| 387 | (eshell-insert-command "echo alpha") | ||
| 388 | (goto-char eshell-last-input-start) | ||
| 389 | (string= (eshell-get-old-input) "echo alpha")) | ||
| 390 | 60 | ||
| 61 | (ert-deftest eshell-test/lisp-command () | ||
| 62 | "Test `eshell-command-result' with an elisp command." | ||
| 63 | (should (equal (eshell-command-result "(+ 1 2)") 3))) | ||
| 391 | 64 | ||
| 392 | (require 'esh-var) | 65 | (ert-deftest eshell-test/lisp-command-args () |
| 66 | "Test `eshell-command-result' with elisp and trailing args. | ||
| 67 | Test that trailing arguments outside the S-expression are | ||
| 68 | ignored. e.g. \"(+ 1 2) 3\" => 3" | ||
| 69 | (should (equal (eshell-command-result "(+ 1 2) 3") 3))) | ||
| 393 | 70 | ||
| 394 | (eshell-deftest var interp-cmd | 71 | (ert-deftest eshell-test/subcommand () |
| 72 | "Test `eshell-command-result' with a simple subcommand." | ||
| 73 | (should (equal (eshell-command-result "{+ 1 2}") 3))) | ||
| 74 | |||
| 75 | (ert-deftest eshell-test/subcommand-args () | ||
| 76 | "Test `eshell-command-result' with a subcommand and trailing args. | ||
| 77 | Test that trailing arguments outside the subcommand are ignored. | ||
| 78 | e.g. \"{+ 1 2} 3\" => 3" | ||
| 79 | (should (equal (eshell-command-result "{+ 1 2} 3") 3))) | ||
| 80 | |||
| 81 | (ert-deftest eshell-test/subcommand-lisp () | ||
| 82 | "Test `eshell-command-result' with an elisp subcommand and trailing args. | ||
| 83 | Test that trailing arguments outside the subcommand are ignored. | ||
| 84 | e.g. \"{(+ 1 2)} 3\" => 3" | ||
| 85 | (should (equal (eshell-command-result "{(+ 1 2)} 3") 3))) | ||
| 86 | |||
| 87 | (ert-deftest eshell-test/interp-cmd () | ||
| 395 | "Interpolate command result" | 88 | "Interpolate command result" |
| 396 | (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) | 89 | (should (equal (eshell-command-result "+ ${+ 1 2} 3") 6))) |
| 397 | 90 | ||
| 398 | (eshell-deftest var interp-lisp | 91 | (ert-deftest eshell-test/interp-lisp () |
| 399 | "Interpolate Lisp form evaluation" | 92 | "Interpolate Lisp form evaluation" |
| 400 | (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) | 93 | (should (equal (eshell-command-result "+ $(+ 1 2) 3") 6))) |
| 401 | 94 | ||
| 402 | (eshell-deftest var interp-concat | 95 | (ert-deftest eshell-test/interp-concat () |
| 403 | "Interpolate and concat command" | 96 | "Interpolate and concat command" |
| 404 | (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) | 97 | (should (equal (eshell-command-result "+ ${+ 1 2}3 3") 36))) |
| 405 | 98 | ||
| 406 | (eshell-deftest var interp-concat-lisp | 99 | (ert-deftest eshell-test/interp-concat-lisp () |
| 407 | "Interpolate and concat Lisp form" | 100 | "Interpolate and concat Lisp form" |
| 408 | (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) | 101 | (should (equal (eshell-command-result "+ $(+ 1 2)3 3") 36))) |
| 409 | 102 | ||
| 410 | (eshell-deftest var interp-concat2 | 103 | (ert-deftest eshell-test/interp-concat2 () |
| 411 | "Interpolate and concat two commands" | 104 | "Interpolate and concat two commands" |
| 412 | (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) | 105 | (should (equal (eshell-command-result "+ ${+ 1 2}${+ 1 2} 3") 36))) |
| 413 | 106 | ||
| 414 | (eshell-deftest var interp-concat-lisp2 | 107 | (ert-deftest eshell-test/interp-concat-lisp2 () |
| 415 | "Interpolate and concat two Lisp forms" | 108 | "Interpolate and concat two Lisp forms" |
| 416 | (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) | 109 | (should (equal (eshell-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36))) |
| 417 | 110 | ||
| 111 | (ert-deftest eshell-test/window-height () | ||
| 112 | "$LINES should equal (window-height)" | ||
| 113 | (should (eshell-command-result "= $LINES (window-height)"))) | ||
| 114 | |||
| 115 | (ert-deftest eshell-test/window-width () | ||
| 116 | "$COLUMNS should equal (window-width)" | ||
| 117 | (should (eshell-command-result "= $COLUMNS (window-width)"))) | ||
| 118 | |||
| 119 | (ert-deftest eshell-test/last-result-var () | ||
| 120 | "Test using the \"last result\" ($$) variable" | ||
| 121 | (with-temp-eshell | ||
| 122 | (should | ||
| 123 | (eshell-command-result-p "+ 1 2; + $$ 2" | ||
| 124 | "3\n5\n")))) | ||
| 125 | |||
| 126 | (ert-deftest eshell-test/last-result-var2 () | ||
| 127 | "Test using the \"last result\" ($$) variable twice" | ||
| 128 | (with-temp-eshell | ||
| 129 | (should | ||
| 130 | (eshell-command-result-p "+ 1 2; + $$ $$" | ||
| 131 | "3\n6\n")))) | ||
| 132 | |||
| 133 | (ert-deftest eshell-test/last-arg-var () | ||
| 134 | "Test using the \"last arg\" ($_) variable" | ||
| 135 | (with-temp-eshell | ||
| 136 | (should | ||
| 137 | (eshell-command-result-p "+ 1 2; + $_ 4" | ||
| 138 | "3\n6\n")))) | ||
| 139 | |||
| 140 | (ert-deftest eshell-test/command-running-p () | ||
| 141 | "Modeline should show no command running" | ||
| 142 | (with-temp-eshell | ||
| 143 | (let ((eshell-status-in-mode-line t)) | ||
| 144 | (should (memq 'eshell-command-running-string mode-line-format)) | ||
| 145 | (should (equal eshell-command-running-string "--"))))) | ||
| 146 | |||
| 147 | (ert-deftest eshell-test/forward-arg () | ||
| 148 | "Test moving across command arguments" | ||
| 149 | (with-temp-eshell | ||
| 150 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) | ||
| 151 | (let ((here (point)) begin valid) | ||
| 152 | (eshell-bol) | ||
| 153 | (setq begin (point)) | ||
| 154 | (eshell-forward-argument 4) | ||
| 155 | (setq valid (= here (point))) | ||
| 156 | (eshell-backward-argument 4) | ||
| 157 | (prog1 | ||
| 158 | (and valid (= begin (point))) | ||
| 159 | (eshell-bol) | ||
| 160 | (delete-region (point) (point-max)))))) | ||
| 161 | |||
| 162 | (ert-deftest eshell-test/queue-input () | ||
| 163 | "Test queuing command input" | ||
| 164 | (with-temp-eshell | ||
| 165 | (eshell-insert-command "sleep 2") | ||
| 166 | (eshell-insert-command "echo alpha" 'eshell-queue-input) | ||
| 167 | (let ((count 10)) | ||
| 168 | (while (and eshell-current-command | ||
| 169 | (> count 0)) | ||
| 170 | (sit-for 1) | ||
| 171 | (setq count (1- count)))) | ||
| 172 | (should (eshell-match-result "alpha\n")))) | ||
| 173 | |||
| 174 | (ert-deftest eshell-test/flush-output () | ||
| 175 | "Test flushing of previous output" | ||
| 176 | (with-temp-eshell | ||
| 177 | (eshell-insert-command "echo alpha") | ||
| 178 | (eshell-kill-output) | ||
| 179 | (should (eshell-match-result (regexp-quote "*** output flushed ***\n"))) | ||
| 180 | (should (forward-line)) | ||
| 181 | (should (= (point) eshell-last-output-start)))) | ||
| 182 | |||
| 183 | (ert-deftest eshell-test/run-old-command () | ||
| 184 | "Re-run an old command" | ||
| 185 | (with-temp-eshell | ||
| 186 | (eshell-insert-command "echo alpha") | ||
| 187 | (goto-char eshell-last-input-start) | ||
| 188 | (string= (eshell-get-old-input) "echo alpha"))) | ||
| 418 | 189 | ||
| 419 | (provide 'esh-test) | 190 | (provide 'esh-test) |
| 420 | 191 | ||
| 421 | ;;; esh-test.el ends here | 192 | ;;; tests/eshell.el ends here |
diff --git a/test/indent/octave.m b/test/indent/octave.m index bc7784f1ba2..e5bae850589 100644 --- a/test/indent/octave.m +++ b/test/indent/octave.m | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ## -*- mode: octave; coding: utf-8 -*- | 1 | ## -*- mode: octave; coding: utf-8 -*- |
| 2 | 2 | 0; # Don't make this a function file | |
| 3 | function res = tcomp (fn) | 3 | function res = tcomp (fn) |
| 4 | %% res = tcomp (fn) | 4 | %% res = tcomp (fn) |
| 5 | %% imports components and rearranges them. | 5 | %% imports components and rearranges them. |
| @@ -1089,13 +1089,13 @@ function [pkg_idx_struct] = parse_pkg_idx (packdir) | |||
| 1089 | 1089 | ||
| 1090 | while (! feof (fid) || line != -1) | 1090 | while (! feof (fid) || line != -1) |
| 1091 | if (! any (! isspace (line)) || line(1) == "#" || any (line == "=")) | 1091 | if (! any (! isspace (line)) || line(1) == "#" || any (line == "=")) |
| 1092 | ## Comments, blank lines or comments about unimplemented | 1092 | ## Comments, blank lines or comments about unimplemented |
| 1093 | ## functions: do nothing | 1093 | ## functions: do nothing |
| 1094 | ## FIXME: probably comments and pointers to external functions | 1094 | ## FIXME: probably comments and pointers to external functions |
| 1095 | ## could be treated better when printing to screen? | 1095 | ## could be treated better when printing to screen? |
| 1096 | elseif (! isempty (strfind (line, ">>"))) | 1096 | elseif (! isempty (strfind (line, ">>"))) |
| 1097 | ## Skip package name and description as they are in DESCRIPTION | 1097 | ## Skip package name and description as they are in DESCRIPTION |
| 1098 | ## already. | 1098 | ## already. |
| 1099 | elseif (! isspace (line(1))) | 1099 | elseif (! isspace (line(1))) |
| 1100 | ## Category. | 1100 | ## Category. |
| 1101 | if (! isempty (pkg_idx_struct{cat_num}.functions)) | 1101 | if (! isempty (pkg_idx_struct{cat_num}.functions)) |
| @@ -1658,7 +1658,7 @@ function desc = get_description (filename) | |||
| 1658 | line = fgetl (fid); | 1658 | line = fgetl (fid); |
| 1659 | while (line != -1) | 1659 | while (line != -1) |
| 1660 | if (line(1) == "#") | 1660 | if (line(1) == "#") |
| 1661 | ## Comments, do nothing. | 1661 | ## Comments, do nothing. |
| 1662 | elseif (isspace(line(1))) | 1662 | elseif (isspace(line(1))) |
| 1663 | ## Continuation lines | 1663 | ## Continuation lines |
| 1664 | if (exist ("keyword", "var") && isfield (desc, keyword)) | 1664 | if (exist ("keyword", "var") && isfield (desc, keyword)) |
| @@ -1752,9 +1752,9 @@ function deps_cell = fix_depends (depends) | |||
| 1752 | endif | 1752 | endif |
| 1753 | version = fix_version (parts{2}); | 1753 | version = fix_version (parts{2}); |
| 1754 | 1754 | ||
| 1755 | ## If no version is specified for the dependency | 1755 | ## If no version is specified for the dependency |
| 1756 | ## we say that the version should be greater than | 1756 | ## we say that the version should be greater than |
| 1757 | ## or equal to "0.0.0". | 1757 | ## or equal to "0.0.0". |
| 1758 | else | 1758 | else |
| 1759 | package = tolower (strip (dep)); | 1759 | package = tolower (strip (dep)); |
| 1760 | operator = ">="; | 1760 | operator = ">="; |
| @@ -1859,7 +1859,7 @@ function bad_deps = get_unsatisfied_deps (desc, installed_pkgs_lst) | |||
| 1859 | if (! compare_versions (OCTAVE_VERSION, dep.version, dep.operator)) | 1859 | if (! compare_versions (OCTAVE_VERSION, dep.version, dep.operator)) |
| 1860 | bad_deps{end+1} = dep; | 1860 | bad_deps{end+1} = dep; |
| 1861 | endif | 1861 | endif |
| 1862 | ## Is the current dependency not Octave? | 1862 | ## Is the current dependency not Octave? |
| 1863 | else | 1863 | else |
| 1864 | ok = false; | 1864 | ok = false; |
| 1865 | for i = 1:length (installed_pkgs_lst) | 1865 | for i = 1:length (installed_pkgs_lst) |
| @@ -2025,7 +2025,7 @@ function load_packages (files, handle_deps, local_list, global_list) | |||
| 2025 | ## Load all. | 2025 | ## Load all. |
| 2026 | if (length (files) == 1 && strcmp (files{1}, "all")) | 2026 | if (length (files) == 1 && strcmp (files{1}, "all")) |
| 2027 | idx = [1:length(installed_pkgs_lst)]; | 2027 | idx = [1:length(installed_pkgs_lst)]; |
| 2028 | ## Load auto. | 2028 | ## Load auto. |
| 2029 | elseif (length (files) == 1 && strcmp (files{1}, "auto")) | 2029 | elseif (length (files) == 1 && strcmp (files{1}, "auto")) |
| 2030 | idx = []; | 2030 | idx = []; |
| 2031 | for i = 1:length (installed_pkgs_lst) | 2031 | for i = 1:length (installed_pkgs_lst) |
| @@ -2033,7 +2033,7 @@ function load_packages (files, handle_deps, local_list, global_list) | |||
| 2033 | idx (end + 1) = i; | 2033 | idx (end + 1) = i; |
| 2034 | endif | 2034 | endif |
| 2035 | endfor | 2035 | endfor |
| 2036 | ## Load package_name1 ... | 2036 | ## Load package_name1 ... |
| 2037 | else | 2037 | else |
| 2038 | idx = []; | 2038 | idx = []; |
| 2039 | for i = 1:length (files) | 2039 | for i = 1:length (files) |
| @@ -2100,8 +2100,8 @@ function unload_packages (files, handle_deps, local_list, global_list) | |||
| 2100 | idx = strcmp (p, d); | 2100 | idx = strcmp (p, d); |
| 2101 | if (any (idx)) | 2101 | if (any (idx)) |
| 2102 | rmpath (d); | 2102 | rmpath (d); |
| 2103 | ## FIXME: We should also check if we need to remove items from | 2103 | ## FIXME: We should also check if we need to remove items from |
| 2104 | ## EXEC_PATH. | 2104 | ## EXEC_PATH. |
| 2105 | endif | 2105 | endif |
| 2106 | endfor | 2106 | endfor |
| 2107 | endfunction | 2107 | endfunction |
| @@ -2310,7 +2310,9 @@ function dep = is_architecture_dependent (nm) | |||
| 2310 | isglob = true; | 2310 | isglob = true; |
| 2311 | ext(end) = []; | 2311 | ext(end) = []; |
| 2312 | else | 2312 | else |
| 2313 | isglob = false; | 2313 | isglob = false; # I am a test |
| 2314 | #%% me too | ||
| 2315 | ### I shall align to column 0 | ||
| 2314 | endif | 2316 | endif |
| 2315 | pos = findstr (nm, ext); | 2317 | pos = findstr (nm, ext); |
| 2316 | if (pos) | 2318 | if (pos) |
| @@ -2322,3 +2324,17 @@ function dep = is_architecture_dependent (nm) | |||
| 2322 | endif | 2324 | endif |
| 2323 | endfor | 2325 | endfor |
| 2324 | endfunction | 2326 | endfunction |
| 2327 | |||
| 2328 | %!assert(norm(logm([1 -1;0 1]) - [0 -1; 0 0]) < 1e-5); | ||
| 2329 | %!assert(norm(expm(logm([-1 2 ; 4 -1])) - [-1 2 ; 4 -1]) < 1e-5); | ||
| 2330 | %!assert(logm([1 -1 -1;0 1 -1; 0 0 1]), [0 -1 -1.5; 0 0 -1; 0 0 0], 1e-5); | ||
| 2331 | %!assert (logm (expm ([0 1i; -1i 0])), [0 1i; -1i 0], 10 * eps) | ||
| 2332 | |||
| 2333 | %% Test input validation | ||
| 2334 | %!error logm (); | ||
| 2335 | %!error logm (1, 2, 3); | ||
| 2336 | %!error <logm: A must be a square matrix> logm([1 0;0 1; 2 2]); | ||
| 2337 | |||
| 2338 | %!assert (logm (10), log (10)) | ||
| 2339 | %!assert (full (logm (eye (3))), logm (full (eye (3)))) | ||
| 2340 | %!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps) | ||
diff --git a/test/indent/pascal.pas b/test/indent/pascal.pas index 0dda0c47fef..e7203fece68 100644 --- a/test/indent/pascal.pas +++ b/test/indent/pascal.pas | |||
| @@ -6,7 +6,7 @@ Author: Frank Heckenbach <frank@pascal.gnu.de> | |||
| 6 | 6 | ||
| 7 | This program is free software; you can redistribute it and/or | 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as | 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation, version 2. | 9 | published by the Free Software Foundation, version 3. |
| 10 | 10 | ||
| 11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| @@ -25,7 +25,10 @@ by the GNU General Public License. } | |||
| 25 | 25 | ||
| 26 | {$gnu-pascal,I+} | 26 | {$gnu-pascal,I+} |
| 27 | 27 | ||
| 28 | (* second style of comment *) | ||
| 28 | // Free-pascal style comment. | 29 | // Free-pascal style comment. |
| 30 | var x:Char = 12 /* 45; // This /* does not start a comment. | ||
| 31 | var x:Char = (/ 4); // This (/ does not start a comment. | ||
| 29 | 32 | ||
| 30 | program CRTDemo; | 33 | program CRTDemo; |
| 31 | 34 | ||
diff --git a/test/indent/perl.perl b/test/indent/perl.perl index 2411c96a5e4..69c1f90c807 100755 --- a/test/indent/perl.perl +++ b/test/indent/perl.perl | |||
| @@ -1,5 +1,20 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
| 2 | # -*- eval: (bug-reference-mode 1) -*- | 2 | # -*- eval: (bug-reference-mode 1) -*- |
| 3 | 3 | ||
| 4 | print <<"EOF1" . s/he"llo/th'ere/; | ||
| 5 | foo | ||
| 6 | EOF2 | ||
| 7 | bar | ||
| 8 | EOF1 | ||
| 9 | |||
| 10 | |||
| 11 | print <<"EOF1" . <<\EOF2 . s/he"llo/th'ere/; | ||
| 12 | foo | ||
| 13 | EOF2 | ||
| 14 | bar | ||
| 15 | EOF1 | ||
| 16 | bar | ||
| 17 | EOF2 | ||
| 18 | |||
| 4 | $fileType_filesButNot # bug#12373? | 19 | $fileType_filesButNot # bug#12373? |
| 5 | = join( '|', map { quotemeta($_).'$' } @{$fileType->{filesButNot}} ); | 20 | = join( '|', map { quotemeta($_).'$' } @{$fileType->{filesButNot}} ); |
diff --git a/test/indent/ruby.rb b/test/indent/ruby.rb index 4f2e9e63377..853f4dbf992 100644 --- a/test/indent/ruby.rb +++ b/test/indent/ruby.rb | |||
| @@ -10,7 +10,7 @@ d = %(hello (nested) world) | |||
| 10 | 10 | ||
| 11 | # Or inside comments. | 11 | # Or inside comments. |
| 12 | x = # "tot %q/to"; = | 12 | x = # "tot %q/to"; = |
| 13 | y = 2 / 3 | 13 | y = 2 / 3 |
| 14 | 14 | ||
| 15 | # Regexp after whitelisted method. | 15 | # Regexp after whitelisted method. |
| 16 | "abc".sub /b/, 'd' | 16 | "abc".sub /b/, 'd' |
| @@ -21,6 +21,47 @@ a = asub / aslb + bsub / bslb; | |||
| 21 | # Highlight the regexp after "if". | 21 | # Highlight the regexp after "if". |
| 22 | x = toto / foo if /do bar/ =~ "dobar" | 22 | x = toto / foo if /do bar/ =~ "dobar" |
| 23 | 23 | ||
| 24 | # Multiline regexp. | ||
| 25 | /bars | ||
| 26 | tees # toots | ||
| 27 | nfoos/ | ||
| 28 | |||
| 29 | def test1(arg) | ||
| 30 | puts "hello" | ||
| 31 | end | ||
| 32 | |||
| 33 | def test2 (arg) | ||
| 34 | a = "apple" | ||
| 35 | |||
| 36 | if a == 2 | ||
| 37 | puts "hello" | ||
| 38 | else | ||
| 39 | puts "there" | ||
| 40 | end | ||
| 41 | |||
| 42 | if a == 2 then | ||
| 43 | puts "hello" | ||
| 44 | elsif a == 3 | ||
| 45 | puts "hello3" | ||
| 46 | elsif a == 3 then | ||
| 47 | puts "hello3" | ||
| 48 | else | ||
| 49 | puts "there" | ||
| 50 | end | ||
| 51 | |||
| 52 | case a | ||
| 53 | when "a" | ||
| 54 | 6 | ||
| 55 | # Support for this syntax was removed in Ruby 1.9, so we | ||
| 56 | # probably don't need to handle it either. | ||
| 57 | # when "b" : | ||
| 58 | # 7 | ||
| 59 | # when "c" : 2 | ||
| 60 | when "d" then 4 | ||
| 61 | else 5 | ||
| 62 | end | ||
| 63 | end | ||
| 64 | |||
| 24 | # Some Cucumber code: | 65 | # Some Cucumber code: |
| 25 | Given /toto/ do | 66 | Given /toto/ do |
| 26 | print "hello" | 67 | print "hello" |