summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorK. Handa <handa@gnu.org>2015-10-05 22:56:26 +0900
committerK. Handa <handa@gnu.org>2015-10-05 22:56:26 +0900
commit47e9556c70a7009d7c750fd7bf10a0e6cf41cdce (patch)
tree4e944bd68080adee76291dd7d4f34103e2b55d50 /test
parent52beda922d2cb523a03661bf74b8678c8b45e440 (diff)
parentef171d1d0b42758b5f705847d558436e867372f4 (diff)
downloademacs-47e9556c70a7009d7c750fd7bf10a0e6cf41cdce.tar.gz
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 @@
+;;; auth-source-tests.el --- Tests for auth-source.el -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Damien Cassou <damien@cassou.me>,
+;; Nicolas Petton <nicolas@petton.fr>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'auth-source)
+
+(defvar secrets-enabled t
+ "Enable the secrets backend to test its features.")
+
+(defun auth-source-validate-backend (source validation-alist)
+ (let ((backend (auth-source-backend-parse source)))
+ (should (auth-source-backend-p backend))
+ (dolist (pair validation-alist)
+ (should (equal (eieio-oref backend (car pair)) (cdr pair))))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain ()
+ (auth-source-validate-backend '(:source (:macos-keychain-generic foobar))
+ '((:source . "foobar")
+ (:type . macos-keychain-generic)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain-generic-string ()
+ (auth-source-validate-backend "macos-keychain-generic:foobar"
+ '((:source . "foobar")
+ (:type . macos-keychain-generic)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain-internet-string ()
+ (auth-source-validate-backend "macos-keychain-internet:foobar"
+ '((:source . "foobar")
+ (:type . macos-keychain-internet)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain-internet-symbol ()
+ (auth-source-validate-backend 'macos-keychain-internet
+ '((:source . "default")
+ (:type . macos-keychain-internet)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain-generic-symbol ()
+ (auth-source-validate-backend 'macos-keychain-generic
+ '((:source . "default")
+ (:type . macos-keychain-generic)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-macos-keychain-internet-default-string ()
+ (auth-source-validate-backend 'macos-keychain-internet
+ '((:source . "default")
+ (:type . macos-keychain-internet)
+ (:search-function . auth-source-macos-keychain-search)
+ (:create-function . auth-source-macos-keychain-create))))
+
+(ert-deftest auth-source-backend-parse-plstore ()
+ (auth-source-validate-backend '(:source "foo.plist")
+ '((:source . "foo.plist")
+ (:type . plstore)
+ (:search-function . auth-source-plstore-search)
+ (:create-function . auth-source-plstore-create))))
+
+(ert-deftest auth-source-backend-parse-netrc ()
+ (auth-source-validate-backend '(:source "foo")
+ '((:source . "foo")
+ (:type . netrc)
+ (:search-function . auth-source-netrc-search)
+ (:create-function . auth-source-netrc-create))))
+
+(ert-deftest auth-source-backend-parse-netrc-string ()
+ (auth-source-validate-backend "foo"
+ '((:source . "foo")
+ (:type . netrc)
+ (:search-function . auth-source-netrc-search)
+ (:create-function . auth-source-netrc-create))))
+
+(ert-deftest auth-source-backend-parse-secrets ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ (auth-source-validate-backend '(:source (:secrets "foo"))
+ '((:source . "foo")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create)))))
+
+(ert-deftest auth-source-backend-parse-secrets-strings ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ (auth-source-validate-backend "secrets:foo"
+ '((:source . "foo")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create)))))
+
+(ert-deftest auth-source-backend-parse-secrets-nil-source ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ (auth-source-validate-backend '(:source (:secrets nil))
+ '((:source . "session")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create)))))
+
+(ert-deftest auth-source-backend-parse-secrets-alias ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ ;; Redefine `secrets-get-alias' to map 'foo to "foo"
+ (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
+ (auth-source-validate-backend '(:source (:secrets foo))
+ '((:source . "foo")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create))))))
+
+(ert-deftest auth-source-backend-parse-secrets-symbol ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ ;; Redefine `secrets-get-alias' to map 'default to "foo"
+ (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) "foo")))
+ (auth-source-validate-backend 'default
+ '((:source . "foo")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create))))))
+
+(ert-deftest auth-source-backend-parse-secrets-no-alias ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ ;; Redefine `secrets-get-alias' to map 'foo to nil (so that
+ ;; "Login" is used by default
+ (cl-letf (((symbol-function 'secrets-get-alias) (lambda (_) nil)))
+ (auth-source-validate-backend '(:source (:secrets foo))
+ '((:source . "Login")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create))))))
+
+;; TODO This test shows suspicious behavior of auth-source: the
+;; "secrets" source is used even though nothing in the input indicates
+;; that is what we want
+(ert-deftest auth-source-backend-parse-secrets-no-source ()
+ (provide 'secrets) ; simulates the presence of the `secrets' package
+ (let ((secrets-enabled t))
+ (auth-source-validate-backend '(:source '(foo))
+ '((:source . "session")
+ (:type . secrets)
+ (:search-function . auth-source-secrets-search)
+ (:create-function . auth-source-secrets-create)))))
+
+(provide 'auth-source-tests)
+;;; 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 @@
+;;; coding-tests.el --- tests for text encoding and decoding
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Eli Zaretskii <eliz@gnu.org>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+
+;; Directory to hold test data files.
+(defvar coding-tests-workdir
+ (expand-file-name "coding-tests" temporary-file-directory))
+
+;; Remove all generated test files.
+(defun coding-tests-remove-files ()
+ (delete-directory coding-tests-workdir t))
+
+(ert-deftest ert-test-coding-bogus-coding-systems ()
+ (unwind-protect
+ (let (test-file)
+ (or (file-directory-p coding-tests-workdir)
+ (mkdir coding-tests-workdir t))
+ (setq test-file (expand-file-name "nonexisting" coding-tests-workdir))
+ (if (file-exists-p test-file)
+ (delete-file test-file))
+ (should-error
+ (let ((coding-system-for-read 'bogus))
+ (insert-file-contents test-file)))
+ ;; See bug #21602.
+ (setq test-file (expand-file-name "writing" coding-tests-workdir))
+ (should-error
+ (let ((coding-system-for-write (intern "\"us-ascii\"")))
+ (write-region "some text" nil test-file))))
+ (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 @@
(require 'ert)
(require 'json)
+(ert-deftest test-json-plist-reverse ()
+ (should (equal (json--plist-reverse '()) '()))
+ (should (equal (json--plist-reverse '(:a 1)) '(:a 1)))
+ (should (equal (json--plist-reverse '(:a 1 :b 2 :c 3))
+ '(:c 3 :b 2 :a 1))))
+
(ert-deftest json-encode-simple-alist ()
(should (equal (json-encode '((a . 1)
(b . 2)))
"{\"a\":1,\"b\":2}")))
(ert-deftest json-read-simple-alist ()
- (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}")
- '((b . 2)
- (a . 1)))))
+ (let ((json-object-type 'alist))
+ (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}")
+ '((a . 1)
+ (b . 2))))))
(ert-deftest json-encode-string-with-special-chars ()
(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 @@
-;;; mule-util --- tests for international/mule-util.el -*- coding: utf-8; -*-
+;;; mule-util --- tests for international/mule-util.el
;; Copyright (C) 2002-2015 Free Software Foundation, Inc.
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:
(provide 'python-tests)
;; Local Variables:
-;; coding: utf-8
;; indent-tabs-mode: nil
;; End:
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 @@
## -*- mode: octave; coding: utf-8 -*-
0; # Don't make this a function file
function res = tcomp (fn)
+
+ global x y ...
+ z1 z2
+ persistent x y ...
+ z1 z2
+ global x y = 2 ...
+ z1 z2 # FIXME
+
+ do
+ something
+ until x = ...
+ y
+
%% res = tcomp (fn)
%% imports components and rearranges them.
@@ -10,6 +23,15 @@ function res = tcomp (fn)
data = dlmread(fn, 3, 0);
+ enumeration
+ first (1)
+ second (2)
+ end
+
+ y = enumeration (x); #Beware: "enumeration" can also be a function!
+ y = foo(enumeration (x),
+ 2); #Beware: "enumeration" can also be a function!
+
x = data(:,2:end);
y = 'hello';
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 @@
%% -*- mode: prolog; coding: utf-8; fill-column: 78 -*-
%% bug#21526
-test1 :-
+test21526_1 :-
( a ->
- ( a ->
- b
- ; c
- )
- ; c
+ ( a ->
+ b
+ ; c
+ )
+ ; % Toto
+ c ->
+ d
).
-test2 :-
+test21526_2 :-
( a
-> ( a,
b
@@ -19,7 +21,31 @@ test2 :-
b2
; c1,
c2
- )
+ ).
+
+test21526_3 :-
+ X \= Y,
+ \+ a,
+ b,
+ \+ \+ c,
+ d.
+
+test21526_4 :-
+ ( \+ a ->
+ b
+ ; \+ c,
+ \+ d
+ ).
+
+
+test21526_5 :-
+ (a;
+ b ->
+ c).
+
+test21526_predicate(c) :- !,
+ test_goal1,
+ test_goal2.
%% Testing correct tokenizing.
foo(X) :- 0'= = X.
@@ -74,11 +100,11 @@ subst(X, V, FV, lambda(Y, Ti, Bi), lambda(Y1, To, Bo)) :-
%% If X is equal to Y, X is shadowed, so no subst can take place.
-> Y1 = Y, Bo = Bi
; (member((Y, _), FV)
- %% If Y appears in FV, it can appear in V, so we need to
- %% rename it to avoid name capture.
- -> new_atom(Y, Y1),
- subst(Y, Y1, [], Bi, Bi1)
- ; Y1 = Y, Bi1 = Bi),
+ %% If Y appears in FV, it can appear in V, so we need to
+ %% rename it to avoid name capture.
+ -> new_atom(Y, Y1),
+ subst(Y, Y1, [], Bi, Bi1)
+ ; Y1 = Y, Bi1 = Bi),
%% Perform substitution on the body.
subst(X, V, FV, Bi1, Bo)
).