diff options
| author | Stephen Leake | 2019-04-11 14:00:02 -0700 |
|---|---|---|
| committer | Stephen Leake | 2019-04-11 14:00:02 -0700 |
| commit | 7ba7def5caf7ec9d9bebffff489f0a658229fbda (patch) | |
| tree | e0cfcb59937ca0528fb81769d7d48a904a91f5dc /test | |
| parent | 7768581172e11be52b1fcd8224f4594e126bbdb7 (diff) | |
| parent | de238b39e335c6814283faa171b35145f124edf2 (diff) | |
| download | emacs-7ba7def5caf7ec9d9bebffff489f0a658229fbda.tar.gz emacs-7ba7def5caf7ec9d9bebffff489f0a658229fbda.zip | |
Merge commit 'de238b39e335c6814283faa171b35145f124edf2'
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/button-tests.el | 40 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 142 | ||||
| -rw-r--r-- | test/lisp/progmodes/flymake-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/progmodes/python-tests.el | 10 | ||||
| -rw-r--r-- | test/lisp/wid-edit-tests.el | 39 | ||||
| -rw-r--r-- | test/manual/indent/js-jsx.js | 85 | ||||
| -rw-r--r-- | test/manual/indent/js.js | 5 | ||||
| -rw-r--r-- | test/manual/indent/jsx-align-gt-with-lt.jsx | 12 | ||||
| -rw-r--r-- | test/manual/indent/jsx-indent-level.jsx | 13 | ||||
| -rw-r--r-- | test/manual/indent/jsx-quote.jsx | 16 | ||||
| -rw-r--r-- | test/manual/indent/jsx-self-closing.jsx | 13 | ||||
| -rw-r--r-- | test/manual/indent/jsx-unclosed-1.jsx | 13 | ||||
| -rw-r--r-- | test/manual/indent/jsx-unclosed-2.jsx | 65 | ||||
| -rw-r--r-- | test/manual/indent/jsx.jsx | 314 | ||||
| -rw-r--r-- | test/src/editfns-tests.el | 3 |
15 files changed, 626 insertions, 146 deletions
diff --git a/test/lisp/button-tests.el b/test/lisp/button-tests.el new file mode 100644 index 00000000000..d54a992ab89 --- /dev/null +++ b/test/lisp/button-tests.el | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | ;;; button-tests.el --- tests for button.el -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest button-at () | ||
| 25 | "Test `button-at' behavior." | ||
| 26 | (with-temp-buffer | ||
| 27 | (should-not (button-at (point))) | ||
| 28 | (let ((button (insert-text-button "text button")) | ||
| 29 | (marker (button-at (1- (point))))) | ||
| 30 | (should (markerp marker)) | ||
| 31 | (should (= (button-end button) (button-end marker) (point)))) | ||
| 32 | (let ((button (insert-button "overlay button")) | ||
| 33 | (overlay (button-at (1- (point))))) | ||
| 34 | (should (overlayp overlay)) | ||
| 35 | (should (eq button overlay))) | ||
| 36 | ;; Buttons and widgets are incompatible (bug#34506). | ||
| 37 | (widget-create 'link "link widget") | ||
| 38 | (should-not (button-at (1- (point)))))) | ||
| 39 | |||
| 40 | ;;; button-tests.el ends here | ||
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 1c7198ce560..5a9541db8fb 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -3849,12 +3849,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3849 | "Check `start-file-process'." | 3849 | "Check `start-file-process'." |
| 3850 | :tags '(:expensive-test) | 3850 | :tags '(:expensive-test) |
| 3851 | (skip-unless (tramp--test-enabled)) | 3851 | (skip-unless (tramp--test-enabled)) |
| 3852 | (skip-unless (tramp--test-sh-p)) | 3852 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) |
| 3853 | 3853 | ||
| 3854 | (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) | 3854 | (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) |
| 3855 | (let ((default-directory tramp-test-temporary-file-directory) | 3855 | (let ((default-directory tramp-test-temporary-file-directory) |
| 3856 | (tmp-name (tramp--test-make-temp-name nil quoted)) | 3856 | (tmp-name (tramp--test-make-temp-name nil quoted)) |
| 3857 | kill-buffer-query-functions proc) | 3857 | kill-buffer-query-functions proc) |
| 3858 | |||
| 3859 | ;; Simple process. | ||
| 3858 | (unwind-protect | 3860 | (unwind-protect |
| 3859 | (with-temp-buffer | 3861 | (with-temp-buffer |
| 3860 | (setq proc (start-file-process "test1" (current-buffer) "cat")) | 3862 | (setq proc (start-file-process "test1" (current-buffer) "cat")) |
| @@ -3866,11 +3868,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3866 | (with-timeout (10 (tramp--test-timeout-handler)) | 3868 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 3867 | (while (< (- (point-max) (point-min)) (length "foo")) | 3869 | (while (< (- (point-max) (point-min)) (length "foo")) |
| 3868 | (while (accept-process-output proc 0 nil t)))) | 3870 | (while (accept-process-output proc 0 nil t)))) |
| 3869 | (should (string-equal (buffer-string) "foo"))) | 3871 | ;; We cannot use `string-equal', because tramp-adb.el |
| 3872 | ;; echoes also the sent string. | ||
| 3873 | (should (string-match "\\`foo" (buffer-string)))) | ||
| 3870 | 3874 | ||
| 3871 | ;; Cleanup. | 3875 | ;; Cleanup. |
| 3872 | (ignore-errors (delete-process proc))) | 3876 | (ignore-errors (delete-process proc))) |
| 3873 | 3877 | ||
| 3878 | ;; Simple process using a file. | ||
| 3874 | (unwind-protect | 3879 | (unwind-protect |
| 3875 | (with-temp-buffer | 3880 | (with-temp-buffer |
| 3876 | (write-region "foo" nil tmp-name) | 3881 | (write-region "foo" nil tmp-name) |
| @@ -3891,6 +3896,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3891 | (delete-process proc) | 3896 | (delete-process proc) |
| 3892 | (delete-file tmp-name))) | 3897 | (delete-file tmp-name))) |
| 3893 | 3898 | ||
| 3899 | ;; Process filter. | ||
| 3894 | (unwind-protect | 3900 | (unwind-protect |
| 3895 | (with-temp-buffer | 3901 | (with-temp-buffer |
| 3896 | (setq proc (start-file-process "test3" (current-buffer) "cat")) | 3902 | (setq proc (start-file-process "test3" (current-buffer) "cat")) |
| @@ -3905,7 +3911,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3905 | (with-timeout (10 (tramp--test-timeout-handler)) | 3911 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 3906 | (while (< (- (point-max) (point-min)) (length "foo")) | 3912 | (while (< (- (point-max) (point-min)) (length "foo")) |
| 3907 | (while (accept-process-output proc 0 nil t)))) | 3913 | (while (accept-process-output proc 0 nil t)))) |
| 3908 | (should (string-equal (buffer-string) "foo"))) | 3914 | ;; We cannot use `string-equal', because tramp-adb.el |
| 3915 | ;; echoes also the sent string. | ||
| 3916 | (should (string-match "\\`foo" (buffer-string)))) | ||
| 3909 | 3917 | ||
| 3910 | ;; Cleanup. | 3918 | ;; Cleanup. |
| 3911 | (ignore-errors (delete-process proc)))))) | 3919 | (ignore-errors (delete-process proc)))))) |
| @@ -3914,9 +3922,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3914 | "Check `make-process'." | 3922 | "Check `make-process'." |
| 3915 | :tags '(:expensive-test) | 3923 | :tags '(:expensive-test) |
| 3916 | (skip-unless (tramp--test-enabled)) | 3924 | (skip-unless (tramp--test-enabled)) |
| 3917 | (skip-unless (tramp--test-sh-p)) | 3925 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) |
| 3926 | ;; `make-process' supports file name handlers since Emacs 27. | ||
| 3918 | (skip-unless (tramp--test-emacs27-p)) | 3927 | (skip-unless (tramp--test-emacs27-p)) |
| 3919 | 3928 | ||
| 3929 | (tramp--test-instrument-test-case 0 | ||
| 3920 | (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) | 3930 | (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) |
| 3921 | (let ((default-directory tramp-test-temporary-file-directory) | 3931 | (let ((default-directory tramp-test-temporary-file-directory) |
| 3922 | (tmp-name (tramp--test-make-temp-name nil quoted)) | 3932 | (tmp-name (tramp--test-make-temp-name nil quoted)) |
| @@ -3938,7 +3948,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3938 | (with-timeout (10 (tramp--test-timeout-handler)) | 3948 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 3939 | (while (< (- (point-max) (point-min)) (length "foo")) | 3949 | (while (< (- (point-max) (point-min)) (length "foo")) |
| 3940 | (while (accept-process-output proc 0 nil t)))) | 3950 | (while (accept-process-output proc 0 nil t)))) |
| 3941 | (should (string-equal (buffer-string) "foo"))) | 3951 | ;; We cannot use `string-equal', because tramp-adb.el |
| 3952 | ;; echoes also the sent string. | ||
| 3953 | (should (string-match "\\`foo" (buffer-string)))) | ||
| 3942 | 3954 | ||
| 3943 | ;; Cleanup. | 3955 | ;; Cleanup. |
| 3944 | (ignore-errors (delete-process proc))) | 3956 | (ignore-errors (delete-process proc))) |
| @@ -3981,9 +3993,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3981 | (process-send-eof proc) | 3993 | (process-send-eof proc) |
| 3982 | ;; Read output. | 3994 | ;; Read output. |
| 3983 | (with-timeout (10 (tramp--test-timeout-handler)) | 3995 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 3984 | (while (< (- (point-max) (point-min)) (length "foo")) | 3996 | (while (not (string-match "foo" (buffer-string))) |
| 3985 | (while (accept-process-output proc 0 nil t)))) | 3997 | (while (accept-process-output proc 0 nil t)))) |
| 3986 | (should (string-equal (buffer-string) "foo"))) | 3998 | ;; We cannot use `string-equal', because tramp-adb.el |
| 3999 | ;; echoes also the sent string. | ||
| 4000 | (should (string-match "\\`foo" (buffer-string)))) | ||
| 3987 | 4001 | ||
| 3988 | ;; Cleanup. | 4002 | ;; Cleanup. |
| 3989 | (ignore-errors (delete-process proc))) | 4003 | (ignore-errors (delete-process proc))) |
| @@ -4006,33 +4020,37 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4006 | ;; Read output. | 4020 | ;; Read output. |
| 4007 | (with-timeout (10 (tramp--test-timeout-handler)) | 4021 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 4008 | (while (accept-process-output proc 0 nil t))) | 4022 | (while (accept-process-output proc 0 nil t))) |
| 4009 | (should (string-equal (buffer-string) "killed\n"))) | 4023 | ;; We cannot use `string-equal', because tramp-adb.el |
| 4024 | ;; echoes also the sent string. | ||
| 4025 | (should (string-match "killed\n\\'" (buffer-string)))) | ||
| 4010 | 4026 | ||
| 4011 | ;; Cleanup. | 4027 | ;; Cleanup. |
| 4012 | (ignore-errors (delete-process proc))) | 4028 | (ignore-errors (delete-process proc))) |
| 4013 | 4029 | ||
| 4014 | ;; Process with stderr. | 4030 | ;; Process with stderr. tramp-adb.el doesn't support it (yet). |
| 4015 | (let ((stderr (generate-new-buffer (generate-new-buffer-name "stderr")))) | 4031 | (unless (tramp--test-adb-p) |
| 4016 | (unwind-protect | 4032 | (let ((stderr |
| 4017 | (with-temp-buffer | 4033 | (generate-new-buffer (generate-new-buffer-name "stderr")))) |
| 4018 | (setq proc | 4034 | (unwind-protect |
| 4019 | (make-process | 4035 | (with-temp-buffer |
| 4020 | :name "test5" :buffer (current-buffer) | 4036 | (setq proc |
| 4021 | :command '("cat" "/") | 4037 | (make-process |
| 4022 | :stderr stderr | 4038 | :name "test5" :buffer (current-buffer) |
| 4023 | :file-handler t)) | 4039 | :command '("cat" "/") |
| 4024 | (should (processp proc)) | 4040 | :stderr stderr |
| 4025 | ;; Read stderr. | 4041 | :file-handler t)) |
| 4026 | (with-current-buffer stderr | 4042 | (should (processp proc)) |
| 4027 | (with-timeout (10 (tramp--test-timeout-handler)) | 4043 | ;; Read stderr. |
| 4028 | (while (= (point-min) (point-max)) | 4044 | (with-current-buffer stderr |
| 4029 | (while (accept-process-output proc 0 nil t)))) | 4045 | (with-timeout (10 (tramp--test-timeout-handler)) |
| 4030 | (should | 4046 | (while (= (point-min) (point-max)) |
| 4031 | (string-equal (buffer-string) "cat: /: Is a directory\n")))) | 4047 | (while (accept-process-output proc 0 nil t)))) |
| 4048 | (should | ||
| 4049 | (string-match "^cat:.* Is a directory" (buffer-string))))) | ||
| 4032 | 4050 | ||
| 4033 | ;; Cleanup. | 4051 | ;; Cleanup. |
| 4034 | (ignore-errors (delete-process proc)) | 4052 | (ignore-errors (delete-process proc)) |
| 4035 | (ignore-errors (kill-buffer stderr))))))) | 4053 | (ignore-errors (kill-buffer stderr))))))))) |
| 4036 | 4054 | ||
| 4037 | (ert-deftest tramp-test31-interrupt-process () | 4055 | (ert-deftest tramp-test31-interrupt-process () |
| 4038 | "Check `interrupt-process'." | 4056 | "Check `interrupt-process'." |
| @@ -4096,8 +4114,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4096 | ;; Cleanup. | 4114 | ;; Cleanup. |
| 4097 | (ignore-errors (delete-file tmp-name))) | 4115 | (ignore-errors (delete-file tmp-name))) |
| 4098 | 4116 | ||
| 4099 | ;; tramp-adb.el is not fit yet for asynchronous processes. | ||
| 4100 | (unless (tramp--test-adb-p) | ||
| 4101 | (unwind-protect | 4117 | (unwind-protect |
| 4102 | (with-temp-buffer | 4118 | (with-temp-buffer |
| 4103 | (write-region "foo" nil tmp-name) | 4119 | (write-region "foo" nil tmp-name) |
| @@ -4124,10 +4140,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4124 | (buffer-string)))) | 4140 | (buffer-string)))) |
| 4125 | 4141 | ||
| 4126 | ;; Cleanup. | 4142 | ;; Cleanup. |
| 4127 | (ignore-errors (delete-file tmp-name)))) | 4143 | (ignore-errors (delete-file tmp-name))) |
| 4128 | 4144 | ||
| 4129 | ;; tramp-adb.el is not fit yet for asynchronous processes. | ||
| 4130 | (unless (tramp--test-adb-p) | ||
| 4131 | (unwind-protect | 4145 | (unwind-protect |
| 4132 | (with-temp-buffer | 4146 | (with-temp-buffer |
| 4133 | (write-region "foo" nil tmp-name) | 4147 | (write-region "foo" nil tmp-name) |
| @@ -4155,7 +4169,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4155 | (buffer-string)))) | 4169 | (buffer-string)))) |
| 4156 | 4170 | ||
| 4157 | ;; Cleanup. | 4171 | ;; Cleanup. |
| 4158 | (ignore-errors (delete-file tmp-name))))))) | 4172 | (ignore-errors (delete-file tmp-name)))))) |
| 4159 | 4173 | ||
| 4160 | (defun tramp--test-shell-command-to-string-asynchronously (command) | 4174 | (defun tramp--test-shell-command-to-string-asynchronously (command) |
| 4161 | "Like `shell-command-to-string', but for asynchronous processes." | 4175 | "Like `shell-command-to-string', but for asynchronous processes." |
| @@ -4350,11 +4364,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4350 | ;; The functions were introduced in Emacs 26.1. | 4364 | ;; The functions were introduced in Emacs 26.1. |
| 4351 | (ert-deftest tramp-test34-explicit-shell-file-name () | 4365 | (ert-deftest tramp-test34-explicit-shell-file-name () |
| 4352 | "Check that connection-local `explicit-shell-file-name' is set." | 4366 | "Check that connection-local `explicit-shell-file-name' is set." |
| 4353 | ;; The handling of connection-local variables has changed. Test | 4367 | :tags '(:expensive-test) |
| 4354 | ;; must be reworked. | ||
| 4355 | :tags '(:expensive-test :unstable) | ||
| 4356 | (skip-unless (tramp--test-enabled)) | 4368 | (skip-unless (tramp--test-enabled)) |
| 4357 | (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) | 4369 | ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for |
| 4370 | ;; remote processes in Emacs. That doesn't work for tramp-adb.el. | ||
| 4371 | (skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p)) | ||
| 4372 | (tramp--test-sh-p))) | ||
| 4358 | ;; Since Emacs 26.1. | 4373 | ;; Since Emacs 26.1. |
| 4359 | (skip-unless (and (fboundp 'connection-local-set-profile-variables) | 4374 | (skip-unless (and (fboundp 'connection-local-set-profile-variables) |
| 4360 | (fboundp 'connection-local-set-profiles))) | 4375 | (fboundp 'connection-local-set-profiles))) |
| @@ -4368,15 +4383,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4368 | (unwind-protect | 4383 | (unwind-protect |
| 4369 | (progn | 4384 | (progn |
| 4370 | ;; `shell-mode' would ruin our test, because it deletes all | 4385 | ;; `shell-mode' would ruin our test, because it deletes all |
| 4371 | ;; buffer local variables. | 4386 | ;; buffer local variables. Not needed in Emacs 27.1. |
| 4372 | (put 'explicit-shell-file-name 'permanent-local t) | 4387 | (put 'explicit-shell-file-name 'permanent-local t) |
| 4373 | ;; Declare connection-local variable `explicit-shell-file-name'. | 4388 | ;; Declare connection-local variables `explicit-shell-file-name' |
| 4389 | ;; and `explicit-sh-args'. | ||
| 4374 | (with-no-warnings | 4390 | (with-no-warnings |
| 4375 | (connection-local-set-profile-variables | 4391 | (connection-local-set-profile-variables |
| 4376 | 'remote-sh | 4392 | 'remote-sh |
| 4377 | `((explicit-shell-file-name | 4393 | `((explicit-shell-file-name |
| 4378 | . ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")) | 4394 | . ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")) |
| 4379 | (explicit-sh-args . ("-i")))) | 4395 | (explicit-sh-args . ("-c" "echo foo")))) |
| 4380 | (connection-local-set-profiles | 4396 | (connection-local-set-profiles |
| 4381 | `(:application tramp | 4397 | `(:application tramp |
| 4382 | :protocol ,(file-remote-p default-directory 'method) | 4398 | :protocol ,(file-remote-p default-directory 'method) |
| @@ -4386,14 +4402,18 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4386 | (put 'explicit-shell-file-name 'safe-local-variable #'identity) | 4402 | (put 'explicit-shell-file-name 'safe-local-variable #'identity) |
| 4387 | (put 'explicit-sh-args 'safe-local-variable #'identity) | 4403 | (put 'explicit-sh-args 'safe-local-variable #'identity) |
| 4388 | 4404 | ||
| 4389 | ;; Run interactive shell. Since the default directory is | 4405 | ;; Run `shell' interactively. Since the default directory |
| 4390 | ;; remote, `explicit-shell-file-name' shall be set in order | 4406 | ;; is remote, `explicit-shell-file-name' shall be set in |
| 4391 | ;; to avoid a question. | 4407 | ;; order to avoid a question. `explicit-sh-args' echoes the |
| 4408 | ;; test data. | ||
| 4392 | (with-current-buffer (get-buffer-create "*shell*") | 4409 | (with-current-buffer (get-buffer-create "*shell*") |
| 4393 | (ignore-errors (kill-process (current-buffer))) | 4410 | (ignore-errors (kill-process (current-buffer))) |
| 4394 | (should-not explicit-shell-file-name) | 4411 | (should-not explicit-shell-file-name) |
| 4395 | (call-interactively #'shell) | 4412 | (call-interactively #'shell) |
| 4396 | (should explicit-shell-file-name))) | 4413 | (with-timeout (10) |
| 4414 | (while (accept-process-output | ||
| 4415 | (get-buffer-process (current-buffer)) nil nil t))) | ||
| 4416 | (should (string-match "^foo$" (buffer-string))))) | ||
| 4397 | 4417 | ||
| 4398 | ;; Cleanup. | 4418 | ;; Cleanup. |
| 4399 | (put 'explicit-shell-file-name 'permanent-local nil) | 4419 | (put 'explicit-shell-file-name 'permanent-local nil) |
| @@ -5347,20 +5367,17 @@ process sentinels. They shall not disturb each other." | |||
| 5347 | ;; we mark it as unstable. | 5367 | ;; we mark it as unstable. |
| 5348 | :tags '(:expensive-test :unstable) | 5368 | :tags '(:expensive-test :unstable) |
| 5349 | (skip-unless (tramp--test-enabled)) | 5369 | (skip-unless (tramp--test-enabled)) |
| 5350 | (skip-unless (tramp--test-sh-p)) | 5370 | ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for |
| 5351 | ;; This test is sensible wrt to other running tests. Let it work | 5371 | ;; remote processes in Emacs. That doesn't work for tramp-adb.el. |
| 5352 | ;; only if it is the only selected test. | 5372 | (skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p)) |
| 5353 | ;; FIXME: There must be a better solution. | 5373 | (tramp--test-sh-p))) |
| 5354 | (skip-unless | ||
| 5355 | (= 1 (length | ||
| 5356 | (ert-select-tests (ert--stats-selector ert--current-run-stats) t)))) | ||
| 5357 | 5374 | ||
| 5358 | (with-timeout | 5375 | (with-timeout |
| 5359 | (tramp--test-asynchronous-requests-timeout (tramp--test-timeout-handler)) | 5376 | (tramp--test-asynchronous-requests-timeout (tramp--test-timeout-handler)) |
| 5360 | (define-key special-event-map [sigusr1] #'tramp--test-timeout-handler) | 5377 | (define-key special-event-map [sigusr1] #'tramp--test-timeout-handler) |
| 5361 | (let* (;; For the watchdog. | 5378 | (let* (;; For the watchdog. |
| 5362 | (default-directory (expand-file-name temporary-file-directory)) | 5379 | (default-directory (expand-file-name temporary-file-directory)) |
| 5363 | (shell-file-name "/bin/sh") | 5380 | (shell-file-name (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")) |
| 5364 | (watchdog | 5381 | (watchdog |
| 5365 | (start-process-shell-command | 5382 | (start-process-shell-command |
| 5366 | "*watchdog*" nil | 5383 | "*watchdog*" nil |
| @@ -5460,7 +5477,7 @@ process sentinels. They shall not disturb each other." | |||
| 5460 | "Process filter %s %s %s" proc string (current-time-string)) | 5477 | "Process filter %s %s %s" proc string (current-time-string)) |
| 5461 | (with-current-buffer (process-buffer proc) | 5478 | (with-current-buffer (process-buffer proc) |
| 5462 | (insert string)) | 5479 | (insert string)) |
| 5463 | (unless (zerop (length string)) | 5480 | (when (< (process-get proc 'bar) 2) |
| 5464 | (dired-uncache (process-get proc 'foo)) | 5481 | (dired-uncache (process-get proc 'foo)) |
| 5465 | (should (file-attributes (process-get proc 'foo)))))) | 5482 | (should (file-attributes (process-get proc 'foo)))))) |
| 5466 | ;; Add process sentinel. It shall not perform remote | 5483 | ;; Add process sentinel. It shall not perform remote |
| @@ -5513,7 +5530,12 @@ process sentinels. They shall not disturb each other." | |||
| 5513 | (dolist (buf buffers) | 5530 | (dolist (buf buffers) |
| 5514 | (with-current-buffer buf | 5531 | (with-current-buffer buf |
| 5515 | (should | 5532 | (should |
| 5516 | (string-equal (format "%s\n%s\n" buf buf) (buffer-string))))) | 5533 | (string-equal |
| 5534 | ;; tramp-adb.el echoes, so we must add the three strings. | ||
| 5535 | (if (tramp--test-adb-p) | ||
| 5536 | (format "%s\n%s\n%s\n%s\n%s\n" buf buf buf buf buf) | ||
| 5537 | (format "%s\n%s\n" buf buf)) | ||
| 5538 | (buffer-string))))) | ||
| 5517 | (should-not | 5539 | (should-not |
| 5518 | (directory-files | 5540 | (directory-files |
| 5519 | tmp-name nil directory-files-no-dot-files-regexp))) | 5541 | tmp-name nil directory-files-no-dot-files-regexp))) |
| @@ -5714,11 +5736,9 @@ Since it unloads Tramp, it shall be the last test to run." | |||
| 5714 | ;; do not work properly for `nextcloud'. | 5736 | ;; do not work properly for `nextcloud'. |
| 5715 | ;; * Fix `tramp-test29-start-file-process' and | 5737 | ;; * Fix `tramp-test29-start-file-process' and |
| 5716 | ;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). | 5738 | ;; `tramp-test30-make-process' on MS Windows (`process-send-eof'?). |
| 5717 | ;; * Fix `tramp-test29-start-file-process', | 5739 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. Looks |
| 5718 | ;; `tramp-test30-make-process' and `tramp-test32-shell-command' for | 5740 | ;; like it is resolved now. Remove `:unstable' tag? |
| 5719 | ;; `adb' (see comment in `tramp-adb-send-command'). | 5741 | ;; * Implement `tramp-test31-interrupt-process' for `adb'. |
| 5720 | ;; * Rework `tramp-test34-explicit-shell-file-name'. | ||
| 5721 | ;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'. | ||
| 5722 | 5742 | ||
| 5723 | (provide 'tramp-tests) | 5743 | (provide 'tramp-tests) |
| 5724 | ;;; tramp-tests.el ends here | 5744 | ;;; tramp-tests.el ends here |
diff --git a/test/lisp/progmodes/flymake-tests.el b/test/lisp/progmodes/flymake-tests.el index 629cdf9a137..732193476dd 100644 --- a/test/lisp/progmodes/flymake-tests.el +++ b/test/lisp/progmodes/flymake-tests.el | |||
| @@ -142,6 +142,8 @@ SEVERITY-PREDICATE is used to setup | |||
| 142 | 142 | ||
| 143 | (ert-deftest different-diagnostic-types () | 143 | (ert-deftest different-diagnostic-types () |
| 144 | "Test GCC warning via function predicate." | 144 | "Test GCC warning via function predicate." |
| 145 | ;; http://lists.gnu.org/archive/html/emacs-devel/2019-03/msg01043.html | ||
| 146 | :expected-result (if (getenv "EMACS_HYDRA_CI") :failed :passed) | ||
| 145 | (skip-unless (and (executable-find "gcc") | 147 | (skip-unless (and (executable-find "gcc") |
| 146 | (version<= | 148 | (version<= |
| 147 | "5" (string-trim | 149 | "5" (string-trim |
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 94c846ecb16..999cf8dc7a3 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el | |||
| @@ -5345,13 +5345,23 @@ class SomeClass: | |||
| 5345 | (ert-deftest python-tests--python-nav-end-of-statement--infloop () | 5345 | (ert-deftest python-tests--python-nav-end-of-statement--infloop () |
| 5346 | "Checks that `python-nav-end-of-statement' doesn't infloop in a | 5346 | "Checks that `python-nav-end-of-statement' doesn't infloop in a |
| 5347 | buffer with overlapping strings." | 5347 | buffer with overlapping strings." |
| 5348 | ;; FIXME: The treatment of strings has changed in the mean time, and the | ||
| 5349 | ;; test below now neither signals an error nor inf-loops. | ||
| 5350 | ;; The description of the problem it's trying to catch is not clear enough | ||
| 5351 | ;; to be able to see if the underlying problem is really fixed, sadly. | ||
| 5352 | ;; E.g. I don't know what is meant by "overlap", really. | ||
| 5353 | (skip-unless nil) | ||
| 5348 | (python-tests-with-temp-buffer "''' '\n''' ' '\n" | 5354 | (python-tests-with-temp-buffer "''' '\n''' ' '\n" |
| 5349 | (syntax-propertize (point-max)) | 5355 | (syntax-propertize (point-max)) |
| 5350 | ;; Create a situation where strings nominally overlap. This | 5356 | ;; Create a situation where strings nominally overlap. This |
| 5351 | ;; shouldn't happen in practice, but apparently it can happen when | 5357 | ;; shouldn't happen in practice, but apparently it can happen when |
| 5352 | ;; a package calls `syntax-ppss' in a narrowed buffer during JIT | 5358 | ;; a package calls `syntax-ppss' in a narrowed buffer during JIT |
| 5353 | ;; lock. | 5359 | ;; lock. |
| 5360 | ;; FIXME: 4-5 is the SPC right after the opening triple quotes: why | ||
| 5361 | ;; put a string-fence syntax on it? | ||
| 5354 | (put-text-property 4 5 'syntax-table (string-to-syntax "|")) | 5362 | (put-text-property 4 5 'syntax-table (string-to-syntax "|")) |
| 5363 | ;; FIXME: 8-9 is the middle quote in the closing triple quotes: | ||
| 5364 | ;; it shouldn't have any syntax-table property to remove anyway! | ||
| 5355 | (remove-text-properties 8 9 '(syntax-table nil)) | 5365 | (remove-text-properties 8 9 '(syntax-table nil)) |
| 5356 | (goto-char 4) | 5366 | (goto-char 4) |
| 5357 | (setq-local syntax-propertize-function nil) | 5367 | (setq-local syntax-propertize-function nil) |
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el new file mode 100644 index 00000000000..a4350e715ed --- /dev/null +++ b/test/lisp/wid-edit-tests.el | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | ;;; wid-edit-tests.el --- tests for wid-edit.el -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | (require 'wid-edit) | ||
| 24 | |||
| 25 | (ert-deftest widget-at () | ||
| 26 | "Test `widget-at' behavior." | ||
| 27 | (with-temp-buffer | ||
| 28 | (should-not (widget-at)) | ||
| 29 | (let ((marco (widget-create 'link "link widget")) | ||
| 30 | (polo (widget-at (1- (point))))) | ||
| 31 | (should (widgetp polo)) | ||
| 32 | (should (eq marco polo))) | ||
| 33 | ;; Buttons and widgets are incompatible (bug#34506). | ||
| 34 | (insert-text-button "text button") | ||
| 35 | (should-not (widget-at (1- (point)))) | ||
| 36 | (insert-button "overlay button") | ||
| 37 | (should-not (widget-at (1- (point)))))) | ||
| 38 | |||
| 39 | ;;; wid-edit-tests.el ends here | ||
diff --git a/test/manual/indent/js-jsx.js b/test/manual/indent/js-jsx.js deleted file mode 100644 index 7401939d282..00000000000 --- a/test/manual/indent/js-jsx.js +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 1 | // -*- mode: js-jsx; -*- | ||
| 2 | |||
| 3 | var foo = <div></div>; | ||
| 4 | |||
| 5 | return ( | ||
| 6 | <div> | ||
| 7 | </div> | ||
| 8 | <div> | ||
| 9 | <div></div> | ||
| 10 | <div> | ||
| 11 | <div></div> | ||
| 12 | </div> | ||
| 13 | </div> | ||
| 14 | ); | ||
| 15 | |||
| 16 | React.render( | ||
| 17 | <div> | ||
| 18 | <div></div> | ||
| 19 | </div>, | ||
| 20 | { | ||
| 21 | a: 1 | ||
| 22 | }, | ||
| 23 | <div> | ||
| 24 | <div></div> | ||
| 25 | </div> | ||
| 26 | ); | ||
| 27 | |||
| 28 | return ( | ||
| 29 | // Sneaky! | ||
| 30 | <div></div> | ||
| 31 | ); | ||
| 32 | |||
| 33 | return ( | ||
| 34 | <div></div> | ||
| 35 | // Sneaky! | ||
| 36 | ); | ||
| 37 | |||
| 38 | React.render( | ||
| 39 | <input | ||
| 40 | />, | ||
| 41 | { | ||
| 42 | a: 1 | ||
| 43 | } | ||
| 44 | ); | ||
| 45 | |||
| 46 | return ( | ||
| 47 | <div> | ||
| 48 | {array.map(function () { | ||
| 49 | return { | ||
| 50 | a: 1 | ||
| 51 | }; | ||
| 52 | })} | ||
| 53 | </div> | ||
| 54 | ); | ||
| 55 | |||
| 56 | return ( | ||
| 57 | <div attribute={array.map(function () { | ||
| 58 | return { | ||
| 59 | a: 1 | ||
| 60 | }; | ||
| 61 | |||
| 62 | return { | ||
| 63 | a: 1 | ||
| 64 | }; | ||
| 65 | |||
| 66 | return { | ||
| 67 | a: 1 | ||
| 68 | }; | ||
| 69 | })}> | ||
| 70 | </div> | ||
| 71 | ); | ||
| 72 | |||
| 73 | // Local Variables: | ||
| 74 | // indent-tabs-mode: nil | ||
| 75 | // js-indent-level: 2 | ||
| 76 | // End: | ||
| 77 | |||
| 78 | // The following test has intentionally unclosed elements and should | ||
| 79 | // be placed below all other tests to prevent awkward indentation. | ||
| 80 | |||
| 81 | return ( | ||
| 82 | <div> | ||
| 83 | {array.map(function () { | ||
| 84 | return { | ||
| 85 | a: 1 | ||
diff --git a/test/manual/indent/js.js b/test/manual/indent/js.js index 647d7438f45..9658c95701c 100644 --- a/test/manual/indent/js.js +++ b/test/manual/indent/js.js | |||
| @@ -160,6 +160,11 @@ foo.bar.baz(very => // A comment | |||
| 160 | snorf | 160 | snorf |
| 161 | ); | 161 | ); |
| 162 | 162 | ||
| 163 | // Continuation of bug#25904; support broken arrow as N+1th arg | ||
| 164 | map(arr, (val) => | ||
| 165 | val | ||
| 166 | ) | ||
| 167 | |||
| 163 | // Local Variables: | 168 | // Local Variables: |
| 164 | // indent-tabs-mode: nil | 169 | // indent-tabs-mode: nil |
| 165 | // js-indent-level: 2 | 170 | // js-indent-level: 2 |
diff --git a/test/manual/indent/jsx-align-gt-with-lt.jsx b/test/manual/indent/jsx-align-gt-with-lt.jsx new file mode 100644 index 00000000000..8eb1d6d718c --- /dev/null +++ b/test/manual/indent/jsx-align-gt-with-lt.jsx | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | <element | ||
| 2 | attr="" | ||
| 3 | > | ||
| 4 | </element> | ||
| 5 | <input | ||
| 6 | /> | ||
| 7 | |||
| 8 | // Local Variables: | ||
| 9 | // indent-tabs-mode: nil | ||
| 10 | // js-indent-level: 2 | ||
| 11 | // js-jsx-align->-with-<: nil | ||
| 12 | // End: | ||
diff --git a/test/manual/indent/jsx-indent-level.jsx b/test/manual/indent/jsx-indent-level.jsx new file mode 100644 index 00000000000..0a84b9eb77a --- /dev/null +++ b/test/manual/indent/jsx-indent-level.jsx | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | return ( | ||
| 2 | <element> | ||
| 3 | <element> | ||
| 4 | Hello World! | ||
| 5 | </element> | ||
| 6 | </element> | ||
| 7 | ) | ||
| 8 | |||
| 9 | // Local Variables: | ||
| 10 | // indent-tabs-mode: nil | ||
| 11 | // js-indent-level: 4 | ||
| 12 | // js-jsx-indent-level: 2 | ||
| 13 | // End: | ||
diff --git a/test/manual/indent/jsx-quote.jsx b/test/manual/indent/jsx-quote.jsx new file mode 100644 index 00000000000..1b2c6528734 --- /dev/null +++ b/test/manual/indent/jsx-quote.jsx | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | // JSX text node values should be strings, but only JS string syntax | ||
| 2 | // is considered, so quote marks delimit strings like normal, with | ||
| 3 | // disastrous results (https://github.com/mooz/js2-mode/issues/409). | ||
| 4 | function Bug() { | ||
| 5 | return <div>C'est Montréal</div>; | ||
| 6 | } | ||
| 7 | function Test(foo = /'/, | ||
| 8 | bar = 123) {} | ||
| 9 | |||
| 10 | // This test is in a separate file because it can break other tests | ||
| 11 | // when indenting the whole buffer (not sure why). | ||
| 12 | |||
| 13 | // Local Variables: | ||
| 14 | // indent-tabs-mode: nil | ||
| 15 | // js-indent-level: 2 | ||
| 16 | // End: | ||
diff --git a/test/manual/indent/jsx-self-closing.jsx b/test/manual/indent/jsx-self-closing.jsx new file mode 100644 index 00000000000..f8ea7a138ad --- /dev/null +++ b/test/manual/indent/jsx-self-closing.jsx | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // Local Variables: | ||
| 2 | // indent-tabs-mode: nil | ||
| 3 | // js-indent-level: 2 | ||
| 4 | // End: | ||
| 5 | |||
| 6 | // The following test goes below any comments to avoid including | ||
| 7 | // misindented comments among the erroring lines. | ||
| 8 | |||
| 9 | // Properly parse/indent code with a self-closing tag inside the | ||
| 10 | // attribute of another self-closing tag. | ||
| 11 | <div> | ||
| 12 | <div attr={() => <div attr="" />} /> | ||
| 13 | </div> | ||
diff --git a/test/manual/indent/jsx-unclosed-1.jsx b/test/manual/indent/jsx-unclosed-1.jsx new file mode 100644 index 00000000000..1f5c3fba8da --- /dev/null +++ b/test/manual/indent/jsx-unclosed-1.jsx | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // Local Variables: | ||
| 2 | // indent-tabs-mode: nil | ||
| 3 | // js-indent-level: 2 | ||
| 4 | // End: | ||
| 5 | |||
| 6 | // The following test goes below any comments to avoid including | ||
| 7 | // misindented comments among the erroring lines. | ||
| 8 | |||
| 9 | return ( | ||
| 10 | <div> | ||
| 11 | {array.map(function () { | ||
| 12 | return { | ||
| 13 | a: 1 | ||
diff --git a/test/manual/indent/jsx-unclosed-2.jsx b/test/manual/indent/jsx-unclosed-2.jsx new file mode 100644 index 00000000000..fb665b96a43 --- /dev/null +++ b/test/manual/indent/jsx-unclosed-2.jsx | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | // Local Variables: | ||
| 2 | // indent-tabs-mode: nil | ||
| 3 | // js-indent-level: 2 | ||
| 4 | // End: | ||
| 5 | |||
| 6 | // The following tests go below any comments to avoid including | ||
| 7 | // misindented comments among the erroring lines. | ||
| 8 | |||
| 9 | // Don’t misinterpret inequality operators as JSX. | ||
| 10 | for (; i < length;) void 0 | ||
| 11 | if (foo > bar) void 0 | ||
| 12 | |||
| 13 | // Don’t misintrepet inequalities within JSX, either. | ||
| 14 | <div> | ||
| 15 | {foo < bar} | ||
| 16 | </div> | ||
| 17 | |||
| 18 | // Don’t even misinterpret unary operators as JSX. | ||
| 19 | if (foo < await bar) void 0 | ||
| 20 | while (await foo > bar) void 0 | ||
| 21 | |||
| 22 | <div> | ||
| 23 | {foo < await bar} | ||
| 24 | </div> | ||
| 25 | |||
| 26 | // Allow unary keyword names as null-valued JSX attributes. | ||
| 27 | // (As if this will EVER happen…) | ||
| 28 | <Foo yield> | ||
| 29 | <Bar void> | ||
| 30 | <Baz | ||
| 31 | zorp | ||
| 32 | typeof> | ||
| 33 | <Please do_n0t delete this_stupidTest > | ||
| 34 | How would we ever live without unary support | ||
| 35 | </Please> | ||
| 36 | </Baz> | ||
| 37 | </Bar> | ||
| 38 | </Foo> | ||
| 39 | |||
| 40 | // “-” is not allowed in a JSXBoundaryElement’s name. | ||
| 41 | <ABC /> | ||
| 42 | <A-B-C /> // Weirdly-indented “continued expression.” | ||
| 43 | |||
| 44 | // “-” may be used in a JSXAttribute’s name. | ||
| 45 | <Foo a-b-c="" | ||
| 46 | x-y-z="" /> | ||
| 47 | |||
| 48 | // Weird spaces should be tolerated. | ||
| 49 | < div > | ||
| 50 | < div > | ||
| 51 | < div | ||
| 52 | attr="" | ||
| 53 | / > | ||
| 54 | < div | ||
| 55 | attr="" | ||
| 56 | / > | ||
| 57 | < / div> | ||
| 58 | < / div > | ||
| 59 | |||
| 60 | // Non-ASCII identifiers are acceptable. | ||
| 61 | <Über> | ||
| 62 | <Québec διακριτικός sueño=""> | ||
| 63 | Guten Tag! | ||
| 64 | </Québec> | ||
| 65 | </Über> | ||
diff --git a/test/manual/indent/jsx.jsx b/test/manual/indent/jsx.jsx new file mode 100644 index 00000000000..c200979df8c --- /dev/null +++ b/test/manual/indent/jsx.jsx | |||
| @@ -0,0 +1,314 @@ | |||
| 1 | var foo = <div></div>; | ||
| 2 | |||
| 3 | return ( | ||
| 4 | <div> | ||
| 5 | </div> | ||
| 6 | <div> | ||
| 7 | <div></div> | ||
| 8 | <div> | ||
| 9 | <div></div> | ||
| 10 | </div> | ||
| 11 | </div> | ||
| 12 | ); | ||
| 13 | |||
| 14 | React.render( | ||
| 15 | <div> | ||
| 16 | <div></div> | ||
| 17 | </div>, | ||
| 18 | { | ||
| 19 | a: 1 | ||
| 20 | }, | ||
| 21 | <div> | ||
| 22 | <div></div> | ||
| 23 | </div> | ||
| 24 | ); | ||
| 25 | |||
| 26 | return ( | ||
| 27 | // Sneaky! | ||
| 28 | <div></div> | ||
| 29 | ); | ||
| 30 | |||
| 31 | return ( | ||
| 32 | <div></div> | ||
| 33 | // Sneaky! | ||
| 34 | ); | ||
| 35 | |||
| 36 | React.render( | ||
| 37 | <input | ||
| 38 | />, | ||
| 39 | { | ||
| 40 | a: 1 | ||
| 41 | } | ||
| 42 | ); | ||
| 43 | |||
| 44 | return ( | ||
| 45 | <div> | ||
| 46 | {array.map(function () { | ||
| 47 | return { | ||
| 48 | a: 1 | ||
| 49 | }; | ||
| 50 | })} | ||
| 51 | </div> | ||
| 52 | ); | ||
| 53 | |||
| 54 | return ( | ||
| 55 | <div attribute={array.map(function () { | ||
| 56 | return { | ||
| 57 | a: 1 | ||
| 58 | }; | ||
| 59 | |||
| 60 | return { | ||
| 61 | a: 1 | ||
| 62 | }; | ||
| 63 | |||
| 64 | return { | ||
| 65 | a: 1 | ||
| 66 | }; | ||
| 67 | })}> | ||
| 68 | </div> | ||
| 69 | ); | ||
| 70 | |||
| 71 | return ( | ||
| 72 | <div attribute={{ | ||
| 73 | a: 1, // Indent relative to “attribute” column. | ||
| 74 | b: 2 | ||
| 75 | } && { // Dedent to “attribute” column. | ||
| 76 | a: 1, | ||
| 77 | b: 2 | ||
| 78 | }} /> // Also dedent. | ||
| 79 | ); | ||
| 80 | |||
| 81 | return ( | ||
| 82 | <div attribute= | ||
| 83 | { // Indent properly on another line, too. | ||
| 84 | { | ||
| 85 | a: 1, | ||
| 86 | b: 2, | ||
| 87 | } && ( | ||
| 88 | // Indent other forms, too. | ||
| 89 | a ? b : | ||
| 90 | c ? d : | ||
| 91 | e | ||
| 92 | ) | ||
| 93 | } /> | ||
| 94 | ) | ||
| 95 | |||
| 96 | // JSXMemberExpression names are parsed/indented: | ||
| 97 | <Foo.Bar> | ||
| 98 | <div> | ||
| 99 | <Foo.Bar> | ||
| 100 | Hello World! | ||
| 101 | </Foo.Bar> | ||
| 102 | <Foo.Bar> | ||
| 103 | <div> | ||
| 104 | </div> | ||
| 105 | </Foo.Bar> | ||
| 106 | </div> | ||
| 107 | </Foo.Bar> | ||
| 108 | |||
| 109 | // JSXOpeningFragment and JSXClosingFragment are parsed/indented: | ||
| 110 | <> | ||
| 111 | <div> | ||
| 112 | <> | ||
| 113 | Hello World! | ||
| 114 | </> | ||
| 115 | <> | ||
| 116 | <div> | ||
| 117 | </div> | ||
| 118 | </> | ||
| 119 | </div> | ||
| 120 | </> | ||
| 121 | |||
| 122 | // Indent void expressions (no need for contextual parens / commas) | ||
| 123 | // (https://github.com/mooz/js2-mode/issues/140#issuecomment-166250016). | ||
| 124 | <div className="class-name"> | ||
| 125 | <h2>Title</h2> | ||
| 126 | {array.map(() => { | ||
| 127 | return <Element />; | ||
| 128 | })} | ||
| 129 | {message} | ||
| 130 | </div> | ||
| 131 | // Another example of above issue | ||
| 132 | // (https://github.com/mooz/js2-mode/issues/490). | ||
| 133 | <App> | ||
| 134 | <div> | ||
| 135 | {variable1} | ||
| 136 | <Component/> | ||
| 137 | </div> | ||
| 138 | </App> | ||
| 139 | |||
| 140 | // Comments and arrows can break indentation (Bug#24896 / | ||
| 141 | // https://github.com/mooz/js2-mode/issues/389). | ||
| 142 | const Component = props => ( | ||
| 143 | <FatArrow a={e => c} | ||
| 144 | b={123}> | ||
| 145 | </FatArrow> | ||
| 146 | ); | ||
| 147 | const Component = props => ( | ||
| 148 | <NoFatArrow a={123} | ||
| 149 | b={123}> | ||
| 150 | </NoFatArrow> | ||
| 151 | ); | ||
| 152 | const Component = props => ( // Parse this comment, please. | ||
| 153 | <FatArrow a={e => c} | ||
| 154 | b={123}> | ||
| 155 | </FatArrow> | ||
| 156 | ); | ||
| 157 | const Component = props => ( // Parse this comment, please. | ||
| 158 | <NoFatArrow a={123} | ||
| 159 | b={123}> | ||
| 160 | </NoFatArrow> | ||
| 161 | ); | ||
| 162 | // Another example of above issue (Bug#30225). | ||
| 163 | class { | ||
| 164 | render() { | ||
| 165 | return ( | ||
| 166 | <select style={{paddingRight: "10px"}} | ||
| 167 | onChange={e => this.setState({value: e.target.value})} | ||
| 168 | value={this.state.value}> | ||
| 169 | <option>Hi</option> | ||
| 170 | </select> | ||
| 171 | ); | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 175 | // JSX attributes of an arrow function’s expression body’s JSX | ||
| 176 | // expression should be indented with respect to the JSX opening | ||
| 177 | // element (Bug#26001 / | ||
| 178 | // https://github.com/mooz/js2-mode/issues/389#issuecomment-271869380). | ||
| 179 | class { | ||
| 180 | render() { | ||
| 181 | const messages = this.state.messages.map( | ||
| 182 | message => <Message key={message.id} | ||
| 183 | text={message.text} | ||
| 184 | mine={message.mine} /> | ||
| 185 | ); return messages; | ||
| 186 | } | ||
| 187 | render() { | ||
| 188 | const messages = this.state.messages.map(message => | ||
| 189 | <Message key={message.timestamp} | ||
| 190 | text={message.text} | ||
| 191 | mine={message.mine} /> | ||
| 192 | ); return messages; | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | // Users expect tag closers to align with the tag’s start; this is the | ||
| 197 | // style used in the React docs, so it should be the default. | ||
| 198 | // - https://github.com/mooz/js2-mode/issues/389#issuecomment-390766873 | ||
| 199 | // - https://github.com/mooz/js2-mode/issues/482 | ||
| 200 | // - Bug#32158 | ||
| 201 | const foo = (props) => ( | ||
| 202 | <div> | ||
| 203 | <input | ||
| 204 | cat={i => i} | ||
| 205 | /> | ||
| 206 | <button | ||
| 207 | className="square" | ||
| 208 | > | ||
| 209 | {this.state.value} | ||
| 210 | </button> | ||
| 211 | </div> | ||
| 212 | ); | ||
| 213 | |||
| 214 | // Embedded JSX in parens breaks indentation | ||
| 215 | // (https://github.com/mooz/js2-mode/issues/411). | ||
| 216 | let a = ( | ||
| 217 | <div> | ||
| 218 | {condition && <Component/>} | ||
| 219 | {condition && <Component/>} | ||
| 220 | <div/> | ||
| 221 | </div> | ||
| 222 | ) | ||
| 223 | let b = ( | ||
| 224 | <div> | ||
| 225 | {condition && (<Component/>)} | ||
| 226 | <div/> | ||
| 227 | </div> | ||
| 228 | ) | ||
| 229 | let c = ( | ||
| 230 | <div> | ||
| 231 | {condition && (<Component/>)} | ||
| 232 | {condition && "something"} | ||
| 233 | </div> | ||
| 234 | ) | ||
| 235 | let d = ( | ||
| 236 | <div> | ||
| 237 | {(<Component/>)} | ||
| 238 | {condition && "something"} | ||
| 239 | </div> | ||
| 240 | ) | ||
| 241 | // Another example of the above issue (Bug#27000). | ||
| 242 | function testA() { | ||
| 243 | return ( | ||
| 244 | <div> | ||
| 245 | <div> { ( <div/> ) } </div> | ||
| 246 | </div> | ||
| 247 | ); | ||
| 248 | } | ||
| 249 | function testB() { | ||
| 250 | return ( | ||
| 251 | <div> | ||
| 252 | <div> { <div/> } </div> | ||
| 253 | </div> | ||
| 254 | ); | ||
| 255 | } | ||
| 256 | // Another example of the above issue | ||
| 257 | // (https://github.com/mooz/js2-mode/issues/451). | ||
| 258 | class Classy extends React.Component { | ||
| 259 | render () { | ||
| 260 | return ( | ||
| 261 | <div> | ||
| 262 | <ul className="tocListRoot"> | ||
| 263 | { this.state.list.map((item) => { | ||
| 264 | return (<div />) | ||
| 265 | })} | ||
| 266 | </ul> | ||
| 267 | </div> | ||
| 268 | ) | ||
| 269 | } | ||
| 270 | } | ||
| 271 | |||
| 272 | // Self-closing tags should be indented properly | ||
| 273 | // (https://github.com/mooz/js2-mode/issues/459). | ||
| 274 | export default ({ stars }) => ( | ||
| 275 | <div className='overlay__container'> | ||
| 276 | <div className='overlay__header overlay--text'> | ||
| 277 | Congratulations! | ||
| 278 | </div> | ||
| 279 | <div className='overlay__reward'> | ||
| 280 | <Icon {...createIconProps(stars > 0)} size='large' /> | ||
| 281 | <div className='overlay__reward__bottom'> | ||
| 282 | <Icon {...createIconProps(stars > 1)} size='small' /> | ||
| 283 | <Icon {...createIconProps(stars > 2)} size='small' /> | ||
| 284 | </div> | ||
| 285 | </div> | ||
| 286 | <div className='overlay__description overlay--text'> | ||
| 287 | You have created <large>1</large> reminder | ||
| 288 | </div> | ||
| 289 | </div> | ||
| 290 | ) | ||
| 291 | |||
| 292 | // JS expressions should not break indentation | ||
| 293 | // (https://github.com/mooz/js2-mode/issues/462). | ||
| 294 | // | ||
| 295 | // In the referenced issue, the user actually wanted indentation which | ||
| 296 | // was simply different than Emacs’ SGML attribute indentation. | ||
| 297 | // Nevertheless, his issue highlighted our inability to properly | ||
| 298 | // indent code with JSX inside JSXExpressionContainers inside JSX. | ||
| 299 | return ( | ||
| 300 | <Router> | ||
| 301 | <Bar> | ||
| 302 | <Route exact path="/foo" | ||
| 303 | render={() => ( | ||
| 304 | <div>nothing</div> | ||
| 305 | )} /> | ||
| 306 | <Route exact path="/bar" /> | ||
| 307 | </Bar> | ||
| 308 | </Router> | ||
| 309 | ) | ||
| 310 | |||
| 311 | // Local Variables: | ||
| 312 | // indent-tabs-mode: nil | ||
| 313 | // js-indent-level: 2 | ||
| 314 | // End: | ||
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 449f00f3780..1e8b7066d15 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -351,6 +351,9 @@ | |||
| 351 | "-0x000000003ffffffffffffffe000000000000000 ")))) | 351 | "-0x000000003ffffffffffffffe000000000000000 ")))) |
| 352 | 352 | ||
| 353 | (ert-deftest test-group-name () | 353 | (ert-deftest test-group-name () |
| 354 | ;; FIXME: Actually my GID in one of my systems has no associated entry | ||
| 355 | ;; in /etc/group so there's no name for it and `group-name' correctly | ||
| 356 | ;; returns nil! | ||
| 354 | (should (stringp (group-name (group-gid)))) | 357 | (should (stringp (group-name (group-gid)))) |
| 355 | (should-error (group-name 'foo)) | 358 | (should-error (group-name 'foo)) |
| 356 | (cond | 359 | (cond |