aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorK. Handa2014-12-28 22:18:39 +0900
committerK. Handa2014-12-28 22:18:39 +0900
commitc2f9c07aa02d1c8cba4efdd503463642a910cd6b (patch)
tree8e25338f25fe6d71a72cddff77f4c368192379ef /test
parent5979af512bf5d6a28acea24299b67c7939d9e703 (diff)
parente092accb6bb8aea08dab1796d707b3adce55a38c (diff)
downloademacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.tar.gz
emacs-c2f9c07aa02d1c8cba4efdd503463642a910cd6b.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog71
-rw-r--r--test/automated/data/flymake/test.pl2
-rw-r--r--test/automated/electric-tests.el11
-rw-r--r--test/automated/let-alist.el3
-rw-r--r--test/automated/python-tests.el509
-rw-r--r--test/automated/tramp-tests.el7
-rw-r--r--test/indent/js.js5
7 files changed, 470 insertions, 138 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 7d23b3efe1c..2ea325432d0 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,72 @@
12014-12-27 Glenn Morris <rgm@gnu.org>
2
3 * automated/let-alist.el: Load dependency.
4
52014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
6
7 * automated/python-tests.el
8 (python-shell-completion-native-interpreter-disabled-p-1): New
9 test.
10
112014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
12
13 * automated/python-tests.el (python-shell-get-or-create-process-1)
14 (python-shell-get-or-create-process-2)
15 (python-shell-get-or-create-process-3): Remove tests.
16
172014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
18
19 (python-shell-buffer-substring-9): New test.
20
212014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
22
23 * automated/python-tests.el (python-shell-buffer-substring-1)
24 (python-shell-buffer-substring-2, python-shell-buffer-substring-3)
25 (python-shell-buffer-substring-4, python-shell-buffer-substring-5)
26 (python-shell-buffer-substring-6, python-shell-buffer-substring-7)
27 (python-shell-buffer-substring-8)
28 (python-info-encoding-from-cookie-1)
29 (python-info-encoding-from-cookie-2)
30 (python-info-encoding-from-cookie-3)
31 (python-info-encoding-from-cookie-4)
32 (python-info-encoding-from-cookie-5)
33 (python-info-encoding-from-cookie-6)
34 (python-info-encoding-from-cookie-7, python-info-encoding-1)
35 (python-info-encoding-2): New tests.
36
372014-12-27 Michael Albinus <michael.albinus@gmx.de>
38
39 * automated/tramp-tests.el (tramp-test17-insert-directory): Do not
40 expect a given order of "." and "..".
41
422014-12-27 Fabián Ezequiel Gallina <fgallina@gnu.org>
43
44 * automated/python-tests.el (python-indent-electric-colon-2)
45 (python-indent-electric-colon-3): New tests.
46
472014-12-27 João Távora <joaotavora@gmail.com>
48
49 * automated/electric-tests.el (autowrapping-7): Tests for
50 tex-mode.
51
522014-12-27 Glenn Morris <rgm@gnu.org>
53
54 * automated/flymake/warnpred/test.pl: Tweak format, since the
55 previous one seems to have stopped giving a warning with perl 5.20.1.
56
572014-12-26 Fabián Ezequiel Gallina <fgallina@gnu.org>
58
59 * automated/python-tests.el (python-shell-get-process-name-1)
60 (python-shell-internal-get-process-name-1): Cleanup.
61 (python-shell-get-process-name-2)
62 (python-shell-internal-get-process-name-2): New tests.
63 (python-shell-calculate-command-1)
64 (python-shell-calculate-process-environment-3)
65 (python-shell-calculate-exec-path-2, python-shell-make-comint-1)
66 (python-shell-make-comint-2, python-shell-make-comint-4)
67 (python-shell-get-process-1, python-util-clone-local-variables-1):
68 Replace obsolete function and variable references with current.
69
12014-12-19 Artur Malabarba <bruce.connor.am@gmail.com> 702014-12-19 Artur Malabarba <bruce.connor.am@gmail.com>
2 71
3 * automated/let-alist.el: require `cl-lib' 72 * automated/let-alist.el: require `cl-lib'
@@ -143,7 +212,7 @@
143 212
1442014-10-22 Noam Postavsky <npostavs@users.sourceforget.net> 2132014-10-22 Noam Postavsky <npostavs@users.sourceforget.net>
145 214
146 * test/automated/process-tests.el (process-test-quoted-batfile): 215 * automated/process-tests.el (process-test-quoted-batfile):
147 New test. 216 New test.
148 217
1492014-10-20 Glenn Morris <rgm@gnu.org> 2182014-10-20 Glenn Morris <rgm@gnu.org>
diff --git a/test/automated/data/flymake/test.pl b/test/automated/data/flymake/test.pl
index 2013b2e4434..d5abcb47e7f 100644
--- a/test/automated/data/flymake/test.pl
+++ b/test/automated/data/flymake/test.pl
@@ -1,2 +1,2 @@
1@arr = [1,2,3,4]; 1@arr = [1,2,3,4];
2@arr[1] = -1; 2my $b = @arr[1];
diff --git a/test/automated/electric-tests.el b/test/automated/electric-tests.el
index b1908e6bb32..cd07213bf20 100644
--- a/test/automated/electric-tests.el
+++ b/test/automated/electric-tests.el
@@ -60,7 +60,7 @@
60 (cl-progv 60 (cl-progv
61 (mapcar #'car bindings) 61 (mapcar #'car bindings)
62 (mapcar #'cdr bindings) 62 (mapcar #'cdr bindings)
63 (self-insert-command 1)))) 63 (call-interactively (key-binding `[,last-command-event])))))
64 (should (equal (buffer-substring-no-properties (point-min) (point-max)) 64 (should (equal (buffer-substring-no-properties (point-min) (point-max))
65 expected-string)) 65 expected-string))
66 (should (equal (point) 66 (should (equal (point)
@@ -575,5 +575,14 @@ baz\"\""
575 (skip-chars-backward "\"") 575 (skip-chars-backward "\"")
576 (mark-sexp -1))) 576 (mark-sexp -1)))
577 577
578(define-electric-pair-test autowrapping-7
579 "foo" "\"" :expected-string "``foo''" :expected-point 8
580 :modes '(tex-mode)
581 :fixture-fn #'(lambda ()
582 (electric-pair-mode 1)
583 (goto-char (point-max))
584 (skip-chars-backward "\"")
585 (mark-sexp -1)))
586
578(provide 'electric-tests) 587(provide 'electric-tests)
579;;; electric-tests.el ends here 588;;; electric-tests.el ends here
diff --git a/test/automated/let-alist.el b/test/automated/let-alist.el
index c43e6a07ddc..a45864e220c 100644
--- a/test/automated/let-alist.el
+++ b/test/automated/let-alist.el
@@ -21,6 +21,7 @@
21 21
22(require 'ert) 22(require 'ert)
23(require 'cl-lib) 23(require 'cl-lib)
24(require 'let-alist)
24 25
25(ert-deftest let-alist-surface-test () 26(ert-deftest let-alist-surface-test ()
26 "Tests basic macro expansion for `let-alist'." 27 "Tests basic macro expansion for `let-alist'."
@@ -62,7 +63,7 @@
62 '(nil 1 1 2 nil))))) 63 '(nil 1 1 2 nil)))))
63 64
64(ert-deftest let-alist-remove-dot () 65(ert-deftest let-alist-remove-dot ()
65 "Remove firt dot from symbol." 66 "Remove first dot from symbol."
66 (should (equal (let-alist--remove-dot 'hi) 'hi)) 67 (should (equal (let-alist--remove-dot 'hi) 'hi))
67 (should (equal (let-alist--remove-dot '.hi) 'hi)) 68 (should (equal (let-alist--remove-dot '.hi) 'hi))
68 (should (equal (let-alist--remove-dot '..hi) '.hi))) 69 (should (equal (let-alist--remove-dot '..hi) '.hi)))
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index de20a80ea52..ca43c45ac5e 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -740,6 +740,39 @@ def b()
740 (python-tests-self-insert ":") 740 (python-tests-self-insert ":")
741 (should (= (current-indentation) 0)))) 741 (should (= (current-indentation) 0))))
742 742
743(ert-deftest python-indent-electric-colon-2 ()
744 "Test indentation case for dedenter."
745 (python-tests-with-temp-buffer
746 "
747if do:
748 something()
749 else
750"
751 (python-tests-look-at "else")
752 (goto-char (line-end-position))
753 (python-tests-self-insert ":")
754 (should (= (current-indentation) 0))))
755
756(ert-deftest python-indent-electric-colon-3 ()
757 "Test indentation case for multi-line dedenter."
758 (python-tests-with-temp-buffer
759 "
760if do:
761 something()
762 elif (this
763 and
764 that)
765"
766 (python-tests-look-at "that)")
767 (goto-char (line-end-position))
768 (python-tests-self-insert ":")
769 (python-tests-look-at "elif" -1)
770 (should (= (current-indentation) 0))
771 (python-tests-look-at "and")
772 (should (= (current-indentation) 6))
773 (python-tests-look-at "that)")
774 (should (= (current-indentation) 6))))
775
743(ert-deftest python-indent-region-1 () 776(ert-deftest python-indent-region-1 ()
744 "Test indentation case from Bug#18843." 777 "Test indentation case from Bug#18843."
745 (let ((contents " 778 (let ((contents "
@@ -1775,52 +1808,41 @@ def f():
1775(defvar python-tests-shell-interpreter "python") 1808(defvar python-tests-shell-interpreter "python")
1776 1809
1777(ert-deftest python-shell-get-process-name-1 () 1810(ert-deftest python-shell-get-process-name-1 ()
1778 "Check process name calculation on different scenarios." 1811 "Check process name calculation sans `buffer-file-name'."
1779 (python-tests-with-temp-buffer 1812 (python-tests-with-temp-buffer
1780 "" 1813 ""
1781 (should (string= (python-shell-get-process-name nil) 1814 (should (string= (python-shell-get-process-name nil)
1782 python-shell-buffer-name)) 1815 python-shell-buffer-name))
1783 ;; When the `current-buffer' doesn't have `buffer-file-name', even 1816 (should (string= (python-shell-get-process-name t)
1784 ;; if dedicated flag is non-nil should not include its name. 1817 (format "%s[%s]" python-shell-buffer-name (buffer-name))))))
1785 (should (string= (python-shell-get-process-name t) 1818
1786 python-shell-buffer-name))) 1819(ert-deftest python-shell-get-process-name-2 ()
1820 "Check process name calculation with `buffer-file-name'."
1787 (python-tests-with-temp-file 1821 (python-tests-with-temp-file
1788 "" 1822 ""
1789 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and 1823 ;; `buffer-file-name' is non-nil but the dedicated flag is nil and
1790 ;; should be respected. 1824 ;; should be respected.
1791 (should (string= (python-shell-get-process-name nil) 1825 (should (string= (python-shell-get-process-name nil)
1792 python-shell-buffer-name)) 1826 python-shell-buffer-name))
1793 (should (string= 1827 (should (string=
1794 (python-shell-get-process-name t) 1828 (python-shell-get-process-name t)
1795 (format "%s[%s]" python-shell-buffer-name buffer-file-name))))) 1829 (format "%s[%s]" python-shell-buffer-name (buffer-name))))))
1796 1830
1797(ert-deftest python-shell-internal-get-process-name-1 () 1831(ert-deftest python-shell-internal-get-process-name-1 ()
1798 "Check the internal process name is config-unique." 1832 "Check the internal process name is buffer-unique sans `buffer-file-name'."
1799 (let* ((python-shell-interpreter python-tests-shell-interpreter) 1833 (python-tests-with-temp-buffer
1800 (python-shell-interpreter-args "") 1834 ""
1801 (python-shell-prompt-regexp ">>> ") 1835 (should (string= (python-shell-internal-get-process-name)
1802 (python-shell-prompt-block-regexp "[.][.][.] ") 1836 (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))))))
1803 (python-shell-setup-codes "") 1837
1804 (python-shell-process-environment "") 1838(ert-deftest python-shell-internal-get-process-name-2 ()
1805 (python-shell-extra-pythonpaths "") 1839 "Check the internal process name is buffer-unique with `buffer-file-name'."
1806 (python-shell-exec-path "") 1840 (python-tests-with-temp-file
1807 (python-shell-virtualenv-path "") 1841 ""
1808 (expected (python-tests-with-temp-buffer 1842 (should (string= (python-shell-internal-get-process-name)
1809 "" (python-shell-internal-get-process-name)))) 1843 (format "%s[%s]" python-shell-internal-buffer-name (buffer-name))))))
1810 ;; Same configurations should match. 1844
1811 (should 1845(ert-deftest python-shell-calculate-command-1 ()
1812 (string= expected
1813 (python-tests-with-temp-buffer
1814 "" (python-shell-internal-get-process-name))))
1815 (let ((python-shell-interpreter-args "-B"))
1816 ;; A minimal change should generate different names.
1817 (should
1818 (not (string=
1819 expected
1820 (python-tests-with-temp-buffer
1821 "" (python-shell-internal-get-process-name))))))))
1822
1823(ert-deftest python-shell-parse-command-1 ()
1824 "Check the command to execute is calculated correctly. 1846 "Check the command to execute is calculated correctly.
1825Using `python-shell-interpreter' and 1847Using `python-shell-interpreter' and
1826`python-shell-interpreter-args'." 1848`python-shell-interpreter-args'."
@@ -1832,7 +1854,7 @@ Using `python-shell-interpreter' and
1832 (format "%s %s" 1854 (format "%s %s"
1833 python-shell-interpreter 1855 python-shell-interpreter
1834 python-shell-interpreter-args) 1856 python-shell-interpreter-args)
1835 (python-shell-parse-command))))) 1857 (python-shell-calculate-command)))))
1836 1858
1837(ert-deftest python-shell-calculate-process-environment-1 () 1859(ert-deftest python-shell-calculate-process-environment-1 ()
1838 "Test `python-shell-process-environment' modification." 1860 "Test `python-shell-process-environment' modification."
@@ -1857,17 +1879,17 @@ Using `python-shell-interpreter' and
1857 path-separator original-pythonpath))))) 1879 path-separator original-pythonpath)))))
1858 1880
1859(ert-deftest python-shell-calculate-process-environment-3 () 1881(ert-deftest python-shell-calculate-process-environment-3 ()
1860 "Test `python-shell-virtualenv-path' modification." 1882 "Test `python-shell-virtualenv-root' modification."
1861 (let* ((original-path (or (getenv "PATH") "")) 1883 (let* ((original-path (or (getenv "PATH") ""))
1862 (python-shell-virtualenv-path 1884 (python-shell-virtualenv-root
1863 (directory-file-name user-emacs-directory)) 1885 (directory-file-name user-emacs-directory))
1864 (process-environment 1886 (process-environment
1865 (python-shell-calculate-process-environment))) 1887 (python-shell-calculate-process-environment)))
1866 (should (not (getenv "PYTHONHOME"))) 1888 (should (not (getenv "PYTHONHOME")))
1867 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-path)) 1889 (should (string= (getenv "VIRTUAL_ENV") python-shell-virtualenv-root))
1868 (should (equal (getenv "PATH") 1890 (should (equal (getenv "PATH")
1869 (format "%s/bin%s%s" 1891 (format "%s/bin%s%s"
1870 python-shell-virtualenv-path 1892 python-shell-virtualenv-root
1871 path-separator original-path))))) 1893 path-separator original-path)))))
1872 1894
1873(ert-deftest python-shell-calculate-process-environment-4 () 1895(ert-deftest python-shell-calculate-process-environment-4 ()
@@ -1900,13 +1922,13 @@ Using `python-shell-interpreter' and
1900(ert-deftest python-shell-calculate-exec-path-2 () 1922(ert-deftest python-shell-calculate-exec-path-2 ()
1901 "Test `python-shell-exec-path' modification." 1923 "Test `python-shell-exec-path' modification."
1902 (let* ((original-exec-path exec-path) 1924 (let* ((original-exec-path exec-path)
1903 (python-shell-virtualenv-path 1925 (python-shell-virtualenv-root
1904 (directory-file-name (expand-file-name user-emacs-directory))) 1926 (directory-file-name (expand-file-name user-emacs-directory)))
1905 (exec-path (python-shell-calculate-exec-path))) 1927 (exec-path (python-shell-calculate-exec-path)))
1906 (should (equal 1928 (should (equal
1907 exec-path 1929 exec-path
1908 (append (cons 1930 (append (cons
1909 (format "%s/bin" python-shell-virtualenv-path) 1931 (format "%s/bin" python-shell-virtualenv-root)
1910 original-exec-path)))))) 1932 original-exec-path))))))
1911 1933
1912(ert-deftest python-shell-make-comint-1 () 1934(ert-deftest python-shell-make-comint-1 ()
@@ -1922,7 +1944,7 @@ Using `python-shell-interpreter' and
1922 (shell-buffer 1944 (shell-buffer
1923 (python-tests-with-temp-buffer 1945 (python-tests-with-temp-buffer
1924 "" (python-shell-make-comint 1946 "" (python-shell-make-comint
1925 (python-shell-parse-command) proc-name))) 1947 (python-shell-calculate-command) proc-name)))
1926 (process (get-buffer-process shell-buffer))) 1948 (process (get-buffer-process shell-buffer)))
1927 (unwind-protect 1949 (unwind-protect
1928 (progn 1950 (progn
@@ -1943,7 +1965,7 @@ Using `python-shell-interpreter' and
1943 (shell-buffer 1965 (shell-buffer
1944 (python-tests-with-temp-buffer 1966 (python-tests-with-temp-buffer
1945 "" (python-shell-make-comint 1967 "" (python-shell-make-comint
1946 (python-shell-parse-command) proc-name nil t))) 1968 (python-shell-calculate-command) proc-name nil t)))
1947 (process (get-buffer-process shell-buffer))) 1969 (process (get-buffer-process shell-buffer)))
1948 (unwind-protect 1970 (unwind-protect
1949 (progn 1971 (progn
@@ -2010,7 +2032,7 @@ and `python-shell-interpreter-args' in the new shell buffer."
2010 (setenv "PYTHONSTARTUP" startup-file) 2032 (setenv "PYTHONSTARTUP" startup-file)
2011 (python-tests-with-temp-buffer 2033 (python-tests-with-temp-buffer
2012 "" (python-shell-make-comint 2034 "" (python-shell-make-comint
2013 (python-shell-parse-command) proc-name nil)))) 2035 (python-shell-calculate-command) proc-name nil))))
2014 (process (get-buffer-process shell-buffer))) 2036 (process (get-buffer-process shell-buffer)))
2015 (unwind-protect 2037 (unwind-protect
2016 (progn 2038 (progn
@@ -2040,10 +2062,10 @@ and `python-shell-interpreter-args' in the new shell buffer."
2040 (dedicated-proc-name (python-shell-get-process-name t)) 2062 (dedicated-proc-name (python-shell-get-process-name t))
2041 (global-shell-buffer 2063 (global-shell-buffer
2042 (python-shell-make-comint 2064 (python-shell-make-comint
2043 (python-shell-parse-command) global-proc-name)) 2065 (python-shell-calculate-command) global-proc-name))
2044 (dedicated-shell-buffer 2066 (dedicated-shell-buffer
2045 (python-shell-make-comint 2067 (python-shell-make-comint
2046 (python-shell-parse-command) dedicated-proc-name)) 2068 (python-shell-calculate-command) dedicated-proc-name))
2047 (global-process (get-buffer-process global-shell-buffer)) 2069 (global-process (get-buffer-process global-shell-buffer))
2048 (dedicated-process (get-buffer-process dedicated-shell-buffer))) 2070 (dedicated-process (get-buffer-process dedicated-shell-buffer)))
2049 (unwind-protect 2071 (unwind-protect
@@ -2061,84 +2083,6 @@ and `python-shell-interpreter-args' in the new shell buffer."
2061 (ignore-errors (kill-buffer global-shell-buffer)) 2083 (ignore-errors (kill-buffer global-shell-buffer))
2062 (ignore-errors (kill-buffer dedicated-shell-buffer)))))) 2084 (ignore-errors (kill-buffer dedicated-shell-buffer))))))
2063 2085
2064(ert-deftest python-shell-get-or-create-process-1 ()
2065 "Check shell dedicated process creation."
2066 (skip-unless (executable-find python-tests-shell-interpreter))
2067 (python-tests-with-temp-file
2068 ""
2069 (let* ((cmd
2070 (concat (executable-find python-tests-shell-interpreter) " -i"))
2071 (use-dialog-box)
2072 (dedicated-process-name (python-shell-get-process-name t))
2073 (dedicated-process (python-shell-get-or-create-process cmd t))
2074 (dedicated-shell-buffer (process-buffer dedicated-process)))
2075 (unwind-protect
2076 (progn
2077 (set-process-query-on-exit-flag dedicated-process nil)
2078 ;; should be dedicated.
2079 (should (equal (process-name dedicated-process)
2080 dedicated-process-name))
2081 (kill-buffer dedicated-shell-buffer)
2082 ;; Check there are no processes for current buffer.
2083 (should (not (python-shell-get-process))))
2084 (ignore-errors (kill-buffer dedicated-shell-buffer))))))
2085
2086(ert-deftest python-shell-get-or-create-process-2 ()
2087 "Check shell global process creation."
2088 (skip-unless (executable-find python-tests-shell-interpreter))
2089 (python-tests-with-temp-file
2090 ""
2091 (let* ((cmd
2092 (concat (executable-find python-tests-shell-interpreter) " -i"))
2093 (use-dialog-box)
2094 (process-name (python-shell-get-process-name nil))
2095 (process (python-shell-get-or-create-process cmd))
2096 (shell-buffer (process-buffer process)))
2097 (unwind-protect
2098 (progn
2099 (set-process-query-on-exit-flag process nil)
2100 ;; should be global.
2101 (should (equal (process-name process) process-name))
2102 (kill-buffer shell-buffer)
2103 ;; Check there are no processes for current buffer.
2104 (should (not (python-shell-get-process))))
2105 (ignore-errors (kill-buffer shell-buffer))))))
2106
2107(ert-deftest python-shell-get-or-create-process-3 ()
2108 "Check shell dedicated/global process preference."
2109 (skip-unless (executable-find python-tests-shell-interpreter))
2110 (python-tests-with-temp-file
2111 ""
2112 (let* ((cmd
2113 (concat (executable-find python-tests-shell-interpreter) " -i"))
2114 (python-shell-interpreter python-tests-shell-interpreter)
2115 (use-dialog-box)
2116 (dedicated-process-name (python-shell-get-process-name t))
2117 (global-process)
2118 (dedicated-process))
2119 (progn
2120 ;; Create global process
2121 (run-python cmd nil)
2122 (setq global-process (get-buffer-process "*Python*"))
2123 (should global-process)
2124 (set-process-query-on-exit-flag global-process nil)
2125 ;; Create dedicated process
2126 (run-python cmd t)
2127 (setq dedicated-process (get-process dedicated-process-name))
2128 (should dedicated-process)
2129 (set-process-query-on-exit-flag dedicated-process nil)
2130 ;; Prefer dedicated.
2131 (should (equal (python-shell-get-or-create-process)
2132 dedicated-process))
2133 ;; Kill the dedicated so the global takes over.
2134 (kill-buffer (process-buffer dedicated-process))
2135 ;; Detect global.
2136 (should (equal (python-shell-get-or-create-process) global-process))
2137 ;; Kill the global.
2138 (kill-buffer (process-buffer global-process))
2139 ;; Check there are no processes for current buffer.
2140 (should (not (python-shell-get-process)))))))
2141
2142(ert-deftest python-shell-internal-get-or-create-process-1 () 2086(ert-deftest python-shell-internal-get-or-create-process-1 ()
2143 "Check internal shell process creation fallback." 2087 "Check internal shell process creation fallback."
2144 (skip-unless (executable-find python-tests-shell-interpreter)) 2088 (skip-unless (executable-find python-tests-shell-interpreter))
@@ -2424,9 +2368,229 @@ and `python-shell-interpreter-args' in the new shell buffer."
2424 "^\\(o\\.t \\|\\)"))) 2368 "^\\(o\\.t \\|\\)")))
2425 (ignore-errors (delete-file startup-file))))) 2369 (ignore-errors (delete-file startup-file)))))
2426 2370
2371(ert-deftest python-shell-buffer-substring-1 ()
2372 "Selecting a substring of the whole buffer must match its contents."
2373 (python-tests-with-temp-buffer
2374 "
2375class Foo(models.Model):
2376 pass
2377
2378
2379class Bar(models.Model):
2380 pass
2381"
2382 (should (string= (buffer-string)
2383 (python-shell-buffer-substring (point-min) (point-max))))))
2384
2385(ert-deftest python-shell-buffer-substring-2 ()
2386 "Main block should be removed if NOMAIN is non-nil."
2387 (python-tests-with-temp-buffer
2388 "
2389class Foo(models.Model):
2390 pass
2391
2392class Bar(models.Model):
2393 pass
2394
2395if __name__ == \"__main__\":
2396 foo = Foo()
2397 print (foo)
2398"
2399 (should (string= (python-shell-buffer-substring (point-min) (point-max) t)
2400 "
2401class Foo(models.Model):
2402 pass
2403
2404class Bar(models.Model):
2405 pass
2406
2407
2408
2409
2410"))))
2411
2412(ert-deftest python-shell-buffer-substring-3 ()
2413 "Main block should be removed if NOMAIN is non-nil."
2414 (python-tests-with-temp-buffer
2415 "
2416class Foo(models.Model):
2417 pass
2418
2419if __name__ == \"__main__\":
2420 foo = Foo()
2421 print (foo)
2422
2423class Bar(models.Model):
2424 pass
2425"
2426 (should (string= (python-shell-buffer-substring (point-min) (point-max) t)
2427 "
2428class Foo(models.Model):
2429 pass
2430
2431
2432
2433
2434
2435class Bar(models.Model):
2436 pass
2437"))))
2438
2439(ert-deftest python-shell-buffer-substring-4 ()
2440 "Coding cookie should be added for substrings."
2441 (python-tests-with-temp-buffer
2442 "# coding: latin-1
2443
2444class Foo(models.Model):
2445 pass
2446
2447if __name__ == \"__main__\":
2448 foo = Foo()
2449 print (foo)
2450
2451class Bar(models.Model):
2452 pass
2453"
2454 (should (string= (python-shell-buffer-substring
2455 (python-tests-look-at "class Foo(models.Model):")
2456 (progn (python-nav-forward-sexp) (point)))
2457 "# -*- coding: latin-1 -*-
2458
2459class Foo(models.Model):
2460 pass"))))
2461
2462(ert-deftest python-shell-buffer-substring-5 ()
2463 "The proper amount of blank lines is added for a substring."
2464 (python-tests-with-temp-buffer
2465 "# coding: latin-1
2466
2467class Foo(models.Model):
2468 pass
2469
2470if __name__ == \"__main__\":
2471 foo = Foo()
2472 print (foo)
2473
2474class Bar(models.Model):
2475 pass
2476"
2477 (should (string= (python-shell-buffer-substring
2478 (python-tests-look-at "class Bar(models.Model):")
2479 (progn (python-nav-forward-sexp) (point)))
2480 "# -*- coding: latin-1 -*-
2481
2482
2483
2484
2485
2486
2487
2488
2489class Bar(models.Model):
2490 pass"))))
2491
2492(ert-deftest python-shell-buffer-substring-6 ()
2493 "Handle substring with coding cookie in the second line."
2494 (python-tests-with-temp-buffer
2495 "
2496# coding: latin-1
2497
2498class Foo(models.Model):
2499 pass
2500
2501if __name__ == \"__main__\":
2502 foo = Foo()
2503 print (foo)
2504
2505class Bar(models.Model):
2506 pass
2507"
2508 (should (string= (python-shell-buffer-substring
2509 (python-tests-look-at "# coding: latin-1")
2510 (python-tests-look-at "if __name__ == \"__main__\":"))
2511 "# -*- coding: latin-1 -*-
2512
2513
2514class Foo(models.Model):
2515 pass
2516
2517"))))
2518
2519(ert-deftest python-shell-buffer-substring-7 ()
2520 "Ensure first coding cookie gets precedence."
2521 (python-tests-with-temp-buffer
2522 "# coding: utf-8
2523# coding: latin-1
2524
2525class Foo(models.Model):
2526 pass
2527
2528if __name__ == \"__main__\":
2529 foo = Foo()
2530 print (foo)
2531
2532class Bar(models.Model):
2533 pass
2534"
2535 (should (string= (python-shell-buffer-substring
2536 (python-tests-look-at "# coding: latin-1")
2537 (python-tests-look-at "if __name__ == \"__main__\":"))
2538 "# -*- coding: utf-8 -*-
2539
2540
2541class Foo(models.Model):
2542 pass
2543
2544"))))
2545
2546(ert-deftest python-shell-buffer-substring-8 ()
2547 "Ensure first coding cookie gets precedence when sending whole buffer."
2548 (python-tests-with-temp-buffer
2549 "# coding: utf-8
2550# coding: latin-1
2551
2552class Foo(models.Model):
2553 pass
2554"
2555 (should (string= (python-shell-buffer-substring (point-min) (point-max))
2556 "# coding: utf-8
2557
2558
2559class Foo(models.Model):
2560 pass
2561"))))
2562
2563(ert-deftest python-shell-buffer-substring-9 ()
2564 "Check substring starting from `point-min'."
2565 (python-tests-with-temp-buffer
2566 "# coding: utf-8
2567
2568class Foo(models.Model):
2569 pass
2570
2571class Bar(models.Model):
2572 pass
2573"
2574 (should (string= (python-shell-buffer-substring
2575 (point-min)
2576 (python-tests-look-at "class Bar(models.Model):"))
2577 "# coding: utf-8
2578
2579class Foo(models.Model):
2580 pass
2581
2582"))))
2583
2427 2584
2428;;; Shell completion 2585;;; Shell completion
2429 2586
2587(ert-deftest python-shell-completion-native-interpreter-disabled-p-1 ()
2588 (let* ((python-shell-completion-native-disabled-interpreters (list "pypy"))
2589 (python-shell-interpreter "/some/path/to/bin/pypy"))
2590 (should (python-shell-completion-native-interpreter-disabled-p))))
2591
2592
2593
2430 2594
2431;;; PDB Track integration 2595;;; PDB Track integration
2432 2596
@@ -3738,6 +3902,85 @@ foo = True # another comment
3738 (forward-line 1) 3902 (forward-line 1)
3739 (should (python-info-current-line-empty-p)))) 3903 (should (python-info-current-line-empty-p))))
3740 3904
3905(ert-deftest python-info-encoding-from-cookie-1 ()
3906 "Should detect it on first line."
3907 (python-tests-with-temp-buffer
3908 "# coding=latin-1
3909
3910foo = True # another comment
3911"
3912 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3913
3914(ert-deftest python-info-encoding-from-cookie-2 ()
3915 "Should detect it on second line."
3916 (python-tests-with-temp-buffer
3917 "
3918# coding=latin-1
3919
3920foo = True # another comment
3921"
3922 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3923
3924(ert-deftest python-info-encoding-from-cookie-3 ()
3925 "Should not be detected on third line (and following ones)."
3926 (python-tests-with-temp-buffer
3927 "
3928
3929# coding=latin-1
3930foo = True # another comment
3931"
3932 (should (not (python-info-encoding-from-cookie)))))
3933
3934(ert-deftest python-info-encoding-from-cookie-4 ()
3935 "Should detect Emacs style."
3936 (python-tests-with-temp-buffer
3937 "# -*- coding: latin-1 -*-
3938
3939foo = True # another comment"
3940 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3941
3942(ert-deftest python-info-encoding-from-cookie-5 ()
3943 "Should detect Vim style."
3944 (python-tests-with-temp-buffer
3945 "# vim: set fileencoding=latin-1 :
3946
3947foo = True # another comment"
3948 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3949
3950(ert-deftest python-info-encoding-from-cookie-6 ()
3951 "First cookie wins."
3952 (python-tests-with-temp-buffer
3953 "# -*- coding: iso-8859-1 -*-
3954# vim: set fileencoding=latin-1 :
3955
3956foo = True # another comment"
3957 (should (eq (python-info-encoding-from-cookie) 'iso-8859-1))))
3958
3959(ert-deftest python-info-encoding-from-cookie-7 ()
3960 "First cookie wins."
3961 (python-tests-with-temp-buffer
3962 "# vim: set fileencoding=latin-1 :
3963# -*- coding: iso-8859-1 -*-
3964
3965foo = True # another comment"
3966 (should (eq (python-info-encoding-from-cookie) 'latin-1))))
3967
3968(ert-deftest python-info-encoding-1 ()
3969 "Should return the detected encoding from cookie."
3970 (python-tests-with-temp-buffer
3971 "# vim: set fileencoding=latin-1 :
3972
3973foo = True # another comment"
3974 (should (eq (python-info-encoding) 'latin-1))))
3975
3976(ert-deftest python-info-encoding-2 ()
3977 "Should default to utf-8."
3978 (python-tests-with-temp-buffer
3979 "# No encoding for you
3980
3981foo = True # another comment"
3982 (should (eq (python-info-encoding) 'utf-8))))
3983
3741 3984
3742;;; Utility functions 3985;;; Utility functions
3743 3986
@@ -3767,7 +4010,7 @@ def foo(a, b, c):
3767 . "from IPython.core.completerlib import module_completion") 4010 . "from IPython.core.completerlib import module_completion")
3768 (python-shell-completion-string-code 4011 (python-shell-completion-string-code
3769 . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n") 4012 . "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")
3770 (python-shell-virtualenv-path 4013 (python-shell-virtualenv-root
3771 . "/home/user/.virtualenvs/project")))) 4014 . "/home/user/.virtualenvs/project"))))
3772 (with-current-buffer buffer 4015 (with-current-buffer buffer
3773 (kill-all-local-variables) 4016 (kill-all-local-variables)
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el
index c03b7464b4f..c59445c3b02 100644
--- a/test/automated/tramp-tests.el
+++ b/test/automated/tramp-tests.el
@@ -953,7 +953,12 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
953 (goto-char (point-min)) 953 (goto-char (point-min))
954 (should 954 (should
955 (looking-at-p 955 (looking-at-p
956 "\\(total.+[[:digit:]]+\n\\)?.+ \\.\n.+ \\.\\.\n.+ foo$")))) 956 (concat
957 ;; There might be a summary line.
958 "\\(total.+[[:digit:]]+\n\\)?"
959 ;; We don't know in which order "." and ".." appear.
960 "\\(.+ \\.?\\.\n\\)\\{2\\}"
961 ".+ foo$")))))
957 (ignore-errors (delete-directory tmp-name1 'recursive))))) 962 (ignore-errors (delete-directory tmp-name1 'recursive)))))
958 963
959(ert-deftest tramp-test18-file-attributes () 964(ert-deftest tramp-test18-file-attributes ()
diff --git a/test/indent/js.js b/test/indent/js.js
index 1924094e9d8..2d458e1b769 100644
--- a/test/indent/js.js
+++ b/test/indent/js.js
@@ -7,6 +7,11 @@ let c = 1,
7var e = 100500, 7var e = 100500,
8 + 1; 8 + 1;
9 9
10function test ()
11{
12 return /[/]/.test ('/') // (bug#19397)
13}
14
10var f = bar('/protocols/') 15var f = bar('/protocols/')
11baz(); 16baz();
12 17