aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorK. Handa2015-10-05 22:56:26 +0900
committerK. Handa2015-10-05 22:56:26 +0900
commit47e9556c70a7009d7c750fd7bf10a0e6cf41cdce (patch)
tree4e944bd68080adee76291dd7d4f34103e2b55d50 /test
parent52beda922d2cb523a03661bf74b8678c8b45e440 (diff)
parentef171d1d0b42758b5f705847d558436e867372f4 (diff)
downloademacs-47e9556c70a7009d7c750fd7bf10a0e6cf41cdce.tar.gz
emacs-47e9556c70a7009d7c750fd7bf10a0e6cf41cdce.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
-rw-r--r--test/automated/auth-source-tests.el178
-rw-r--r--test/automated/coding-tests.el50
-rw-r--r--test/automated/json-tests.el13
-rw-r--r--test/automated/mule-util.el2
-rw-r--r--test/automated/python-tests.el1
-rw-r--r--test/indent/octave.m22
-rw-r--r--test/indent/prolog.prolog52
7 files changed, 300 insertions, 18 deletions
diff --git a/test/automated/auth-source-tests.el b/test/automated/auth-source-tests.el
new file mode 100644
index 00000000000..0b49b9013f7
--- /dev/null
+++ b/test/automated/auth-source-tests.el
@@ -0,0 +1,178 @@
1;;; auth-source-tests.el --- Tests for auth-source.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5;; Author: Damien Cassou <damien@cassou.me>,
6;; Nicolas Petton <nicolas@petton.fr>
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;;; Commentary:
24
25;;
26
27;;; Code:
28
29(require 'ert)
30(require 'auth-source)
31
32(defvar secrets-enabled t
33 "Enable the secrets backend to test its features.")
34
35(defun auth-source-validate-backend (source validation-alist)
36 (let ((backend (auth-source-backend-parse source)))
37 (should (auth-source-backend-p backend))
38 (dolist (pair validation-alist)
39 (should (equal (eieio-oref backend (car pair)) (cdr pair))))))
40
41(ert-deftest auth-source-backend-parse-macos-keychain ()
42 (auth-source-validate-backend '(:source (:macos-keychain-generic foobar))
43 '((:source . "foobar")
44 (:type . macos-keychain-generic)
45 (:search-function . auth-source-macos-keychain-search)
46 (:create-function . auth-source-macos-keychain-create))))
47
48(ert-deftest auth-source-backend-parse-macos-keychain-generic-string ()
49 (auth-source-validate-backend "macos-keychain-generic:foobar"
50 '((:source . "foobar")
51 (:type . macos-keychain-generic)
52 (:search-function . auth-source-macos-keychain-search)
53 (:create-function . auth-source-macos-keychain-create))))
54
55(ert-deftest auth-source-backend-parse-macos-keychain-internet-string ()
56 (auth-source-validate-backend "macos-keychain-internet:foobar"
57 '((:source . "foobar")
58 (:type . macos-keychain-internet)
59 (:search-function . auth-source-macos-keychain-search)
60 (:create-function . auth-source-macos-keychain-create))))
61
62(ert-deftest auth-source-backend-parse-macos-keychain-internet-symbol ()
63 (auth-source-validate-backend 'macos-keychain-internet
64 '((:source . "default")
65 (:type . macos-keychain-internet)
66 (:search-function . auth-source-macos-keychain-search)
67 (:create-function . auth-source-macos-keychain-create))))
68
69(ert-deftest auth-source-backend-parse-macos-keychain-generic-symbol ()
70 (auth-source-validate-backend 'macos-keychain-generic
71 '((:source . "default")
72 (:type . macos-keychain-generic)
73 (:search-function . auth-source-macos-keychain-search)
74 (:create-function . auth-source-macos-keychain-create))))
75
76(ert-deftest auth-source-backend-parse-macos-keychain-internet-default-string ()
77 (auth-source-validate-backend 'macos-keychain-internet
78 '((:source . "default")
79 (:type . macos-keychain-internet)
80 (:search-function . auth-source-macos-keychain-search)
81 (:create-function . auth-source-macos-keychain-create))))
82
83(ert-deftest auth-source-backend-parse-plstore ()
84 (auth-source-validate-backend '(:source "foo.plist")
85 '((:source . "foo.plist")
86 (:type . plstore)
87 (:search-function . auth-source-plstore-search)
88 (:create-function . auth-source-plstore-create))))
89
90(ert-deftest auth-source-backend-parse-netrc ()
91 (auth-source-validate-backend '(:source "foo")
92 '((:source . "foo")
93 (:type . netrc)
94 (:search-function . auth-source-netrc-search)
95 (:create-function . auth-source-netrc-create))))
96
97(ert-deftest auth-source-backend-parse-netrc-string ()
98 (auth-source-validate-backend "foo"
99 '((:source . "foo")
100 (:type . netrc)
101 (:search-function . auth-source-netrc-search)
102 (:create-function . auth-source-netrc-create))))
103
104(ert-deftest auth-source-backend-parse-secrets ()
105 (provide 'secrets) ; simulates the presence of the `secrets' package
106 (let ((secrets-enabled t))
107 (auth-source-validate-backend '(:source (:secrets "foo"))
108 '((:source . "foo")
109 (:type . secrets)
110 (:search-function . auth-source-secrets-search)
111 (:create-function . auth-source-secrets-create)))))
112
113(ert-deftest auth-source-backend-parse-secrets-strings ()
114 (provide 'secrets) ; simulates the presence of the `secrets' package
115 (let ((secrets-enabled t))
116 (auth-source-validate-backend "secrets:foo"
117 '((:source . "foo")
118 (:type . secrets)
119 (:search-function . auth-source-secrets-search)
120 (:create-function . auth-source-secrets-create)))))
121
122(ert-deftest auth-source-backend-parse-secrets-nil-source ()
123 (provide 'secrets) ; simulates the presence of the `secrets' package
124 (let ((secrets-enabled t))
125 (auth-source-validate-backend '(:source (:secrets nil))
126 '((:source . "session")
127 (:type . secrets)
128 (:search-function . auth-source-secrets-search)
129 (:create-function . auth-source-secrets-create)))))
130
131(ert-deftest auth-source-backend-parse-secrets-alias ()
132 (provide 'secrets) ; simulates the presence of the `secrets' package
133 (let ((secrets-enabled t))
134 ;; Redefine `secrets-get-alias' to map 'foo to "foo"
135 (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
136 (auth-source-validate-backend '(:source (:secrets foo))
137 '((:source . "foo")
138 (:type . secrets)
139 (:search-function . auth-source-secrets-search)
140 (:create-function . auth-source-secrets-create))))))
141
142(ert-deftest auth-source-backend-parse-secrets-symbol ()
143 (provide 'secrets) ; simulates the presence of the `secrets' package
144 (let ((secrets-enabled t))
145 ;; Redefine `secrets-get-alias' to map 'default to "foo"
146 (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
147 (auth-source-validate-backend 'default
148 '((:source . "foo")
149 (:type . secrets)
150 (:search-function . auth-source-secrets-search)
151 (:create-function . auth-source-secrets-create))))))
152
153(ert-deftest auth-source-backend-parse-secrets-no-alias ()
154 (provide 'secrets) ; simulates the presence of the `secrets' package
155 (let ((secrets-enabled t))
156 ;; Redefine `secrets-get-alias' to map 'foo to nil (so that
157 ;; "Login" is used by default
158 (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) nil)))
159 (auth-source-validate-backend '(:source (:secrets foo))
160 '((:source . "Login")
161 (:type . secrets)
162 (:search-function . auth-source-secrets-search)
163 (:create-function . auth-source-secrets-create))))))
164
165;; TODO This test shows suspicious behavior of auth-source: the
166;; "secrets" source is used even though nothing in the input indicates
167;; that is what we want
168(ert-deftest auth-source-backend-parse-secrets-no-source ()
169 (provide 'secrets) ; simulates the presence of the `secrets' package
170 (let ((secrets-enabled t))
171 (auth-source-validate-backend '(:source '(foo))
172 '((:source . "session")
173 (:type . secrets)
174 (:search-function . auth-source-secrets-search)
175 (:create-function . auth-source-secrets-create)))))
176
177(provide 'auth-source-tests)
178;;; auth-source-tests.el ends here
diff --git a/test/automated/coding-tests.el b/test/automated/coding-tests.el
new file mode 100644
index 00000000000..ebbf8968fc7
--- /dev/null
+++ b/test/automated/coding-tests.el
@@ -0,0 +1,50 @@
1;;; coding-tests.el --- tests for text encoding and decoding
2
3;; Copyright (C) 2015 Free Software Foundation, Inc.
4
5;; Author: Eli Zaretskii <eliz@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;; Directory to hold test data files.
27(defvar coding-tests-workdir
28 (expand-file-name "coding-tests" temporary-file-directory))
29
30;; Remove all generated test files.
31(defun coding-tests-remove-files ()
32 (delete-directory coding-tests-workdir t))
33
34(ert-deftest ert-test-coding-bogus-coding-systems ()
35 (unwind-protect
36 (let (test-file)
37 (or (file-directory-p coding-tests-workdir)
38 (mkdir coding-tests-workdir t))
39 (setq test-file (expand-file-name "nonexisting" coding-tests-workdir))
40 (if (file-exists-p test-file)
41 (delete-file test-file))
42 (should-error
43 (let ((coding-system-for-read 'bogus))
44 (insert-file-contents test-file)))
45 ;; See bug #21602.
46 (setq test-file (expand-file-name "writing" coding-tests-workdir))
47 (should-error
48 (let ((coding-system-for-write (intern "\"us-ascii\"")))
49 (write-region "some text" nil test-file))))
50 (coding-tests-remove-files)))
diff --git a/test/automated/json-tests.el b/test/automated/json-tests.el
index fd89b7aa994..d1b7a2fa022 100644
--- a/test/automated/json-tests.el
+++ b/test/automated/json-tests.el
@@ -22,15 +22,22 @@
22(require 'ert) 22(require 'ert)
23(require 'json) 23(require 'json)
24 24
25(ert-deftest test-json-plist-reverse ()
26 (should (equal (json--plist-reverse '()) '()))
27 (should (equal (json--plist-reverse '(:a 1)) '(:a 1)))
28 (should (equal (json--plist-reverse '(:a 1 :b 2 :c 3))
29 '(:c 3 :b 2 :a 1))))
30
25(ert-deftest json-encode-simple-alist () 31(ert-deftest json-encode-simple-alist ()
26 (should (equal (json-encode '((a . 1) 32 (should (equal (json-encode '((a . 1)
27 (b . 2))) 33 (b . 2)))
28 "{\"a\":1,\"b\":2}"))) 34 "{\"a\":1,\"b\":2}")))
29 35
30(ert-deftest json-read-simple-alist () 36(ert-deftest json-read-simple-alist ()
31 (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}") 37 (let ((json-object-type 'alist))
32 '((b . 2) 38 (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}")
33 (a . 1))))) 39 '((a . 1)
40 (b . 2))))))
34 41
35(ert-deftest json-encode-string-with-special-chars () 42(ert-deftest json-encode-string-with-special-chars ()
36 (should (equal (json-encode-string "a\n\fb") 43 (should (equal (json-encode-string "a\n\fb")
diff --git a/test/automated/mule-util.el b/test/automated/mule-util.el
index 038881a7915..24b56c0969b 100644
--- a/test/automated/mule-util.el
+++ b/test/automated/mule-util.el
@@ -1,4 +1,4 @@
1;;; mule-util --- tests for international/mule-util.el -*- coding: utf-8; -*- 1;;; mule-util --- tests for international/mule-util.el
2 2
3;; Copyright (C) 2002-2015 Free Software Foundation, Inc. 3;; Copyright (C) 2002-2015 Free Software Foundation, Inc.
4 4
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index d9b4c3e1b06..44b05e2b476 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -5216,7 +5216,6 @@ class SomeClass:
5216(provide 'python-tests) 5216(provide 'python-tests)
5217 5217
5218;; Local Variables: 5218;; Local Variables:
5219;; coding: utf-8
5220;; indent-tabs-mode: nil 5219;; indent-tabs-mode: nil
5221;; End: 5220;; End:
5222 5221
diff --git a/test/indent/octave.m b/test/indent/octave.m
index a7041462f7f..4758f9933cb 100644
--- a/test/indent/octave.m
+++ b/test/indent/octave.m
@@ -1,6 +1,19 @@
1## -*- mode: octave; coding: utf-8 -*- 1## -*- mode: octave; coding: utf-8 -*-
20; # Don't make this a function file 20; # Don't make this a function file
3function res = tcomp (fn) 3function res = tcomp (fn)
4
5 global x y ...
6 z1 z2
7 persistent x y ...
8 z1 z2
9 global x y = 2 ...
10 z1 z2 # FIXME
11
12 do
13 something
14 until x = ...
15 y
16
4 %% res = tcomp (fn) 17 %% res = tcomp (fn)
5 %% imports components and rearranges them. 18 %% imports components and rearranges them.
6 19
@@ -10,6 +23,15 @@ function res = tcomp (fn)
10 23
11 data = dlmread(fn, 3, 0); 24 data = dlmread(fn, 3, 0);
12 25
26 enumeration
27 first (1)
28 second (2)
29 end
30
31 y = enumeration (x); #Beware: "enumeration" can also be a function!
32 y = foo(enumeration (x),
33 2); #Beware: "enumeration" can also be a function!
34
13 x = data(:,2:end); 35 x = data(:,2:end);
14 y = 'hello'; 36 y = 'hello';
15 z = y'; 37 z = y';
diff --git a/test/indent/prolog.prolog b/test/indent/prolog.prolog
index 6bf9437b883..9ac6df1b6c7 100644
--- a/test/indent/prolog.prolog
+++ b/test/indent/prolog.prolog
@@ -1,16 +1,18 @@
1%% -*- mode: prolog; coding: utf-8; fill-column: 78 -*- 1%% -*- mode: prolog; coding: utf-8; fill-column: 78 -*-
2 2
3%% bug#21526 3%% bug#21526
4test1 :- 4test21526_1 :-
5 ( a -> 5 ( a ->
6 ( a -> 6 ( a ->
7 b 7 b
8 ; c 8 ; c
9 ) 9 )
10 ; c 10 ; % Toto
11 c ->
12 d
11 ). 13 ).
12 14
13test2 :- 15test21526_2 :-
14 ( a 16 ( a
15 -> ( a, 17 -> ( a,
16 b 18 b
@@ -19,7 +21,31 @@ test2 :-
19 b2 21 b2
20 ; c1, 22 ; c1,
21 c2 23 c2
22 ) 24 ).
25
26test21526_3 :-
27 X \= Y,
28 \+ a,
29 b,
30 \+ \+ c,
31 d.
32
33test21526_4 :-
34 ( \+ a ->
35 b
36 ; \+ c,
37 \+ d
38 ).
39
40
41test21526_5 :-
42 (a;
43 b ->
44 c).
45
46test21526_predicate(c) :- !,
47 test_goal1,
48 test_goal2.
23 49
24%% Testing correct tokenizing. 50%% Testing correct tokenizing.
25foo(X) :- 0'= = X. 51foo(X) :- 0'= = X.
@@ -74,11 +100,11 @@ subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)) :-
74 %% If X is equal to Y, X is shadowed, so no subst can take place. 100 %% If X is equal to Y, X is shadowed, so no subst can take place.
75 -> Y1 = Y, Bo = Bi 101 -> Y1 = Y, Bo = Bi
76 ; (member((Y, _), FV) 102 ; (member((Y, _), FV)
77 %% If Y appears in FV, it can appear in V, so we need to 103 %% If Y appears in FV, it can appear in V, so we need to
78 %% rename it to avoid name capture. 104 %% rename it to avoid name capture.
79 -> new_atom(Y, Y1), 105 -> new_atom(Y, Y1),
80 subst(Y, Y1, [], Bi, Bi1) 106 subst(Y, Y1, [], Bi, Bi1)
81 ; Y1 = Y, Bi1 = Bi), 107 ; Y1 = Y, Bi1 = Bi),
82 %% Perform substitution on the body. 108 %% Perform substitution on the body.
83 subst(X, V, FV, Bi1, Bo) 109 subst(X, V, FV, Bi1, Bo)
84 ). 110 ).