summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-12-29 21:39:08 -0800
committerJohn Wiegley <johnw@newartisans.com>2015-12-29 21:39:08 -0800
commitec0a80cc283badc7f7fd5ef78512dde6d34b1355 (patch)
tree7190e0fb3d4aa06018d8cf997f06b806fb09a9c8 /test/lisp
parentd259328fb87db8cc67d52771efcfa653e52c5b71 (diff)
parente823c34072bf045800d91e12c7ddb61fa23c6e30 (diff)
downloademacs-25-merge.tar.gz
Merge emacs-25 into master (using imerge)emacs-25-merge
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/abbrev-tests.el53
-rw-r--r--test/lisp/autorevert-tests.el4
-rw-r--r--test/lisp/calendar/icalendar-tests.el56
-rw-r--r--test/lisp/character-fold-tests.el72
-rw-r--r--test/lisp/emacs-lisp/package-tests.el14
-rw-r--r--test/lisp/faces-tests.el5
-rw-r--r--test/lisp/gnus/auth-source-tests.el45
-rw-r--r--test/lisp/gnus/message-tests.el6
-rw-r--r--test/lisp/help-fns-tests.el10
-rw-r--r--test/lisp/json-tests.el297
-rw-r--r--test/lisp/net/tramp-tests.el47
-rw-r--r--test/lisp/progmodes/elisp-mode-tests.el4
-rw-r--r--test/lisp/simple-tests.el89
-rw-r--r--test/lisp/subr-tests.el112
-rw-r--r--test/lisp/url/url-expand-tests.el105
15 files changed, 740 insertions, 179 deletions
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index 17aea5d0f82..37917ec5353 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -22,10 +22,21 @@
;;; Commentary:
+;; `kill-all-abbrevs-test' will remove all user *and* system abbrevs
+;; if called noninteractively with the init file loaded.
+
;;; Code:
(require 'ert)
(require 'abbrev)
+(require 'seq)
+
+;; set up test abbrev table and abbrev entry
+(defun setup-test-abbrev-table ()
+ (defvar ert-test-abbrevs nil)
+ (define-abbrev-table 'ert-test-abbrevs '(("a-e-t" "abbrev-ert-test")))
+ (abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value")
+ ert-test-abbrevs)
(ert-deftest abbrev-table-p-test ()
(should-not (abbrev-table-p 42))
@@ -70,5 +81,47 @@
(should (abbrev-table-p new-foo-abbrev-table)))
(should-not (string-equal (buffer-name) "*Backtrace*")))
+(ert-deftest kill-all-abbrevs-test ()
+ "Test undefining all defined abbrevs"
+ (unless noninteractive
+ (ert-skip "Cannot test kill-all-abbrevs in interactive mode"))
+
+ (let ((num-tables 0))
+ ;; ensure at least one abbrev exists
+ (should (abbrev-table-p (setup-test-abbrev-table)))
+ (setf num-tables (length abbrev-table-name-list))
+ (kill-all-abbrevs)
+
+ ;; no tables should have been removed/added
+ (should (= num-tables (length abbrev-table-name-list)))
+ ;; number of empty tables should be the same as number of tables
+ (should (= num-tables (length (seq-filter
+ (lambda (table)
+ (abbrev-table-empty-p (symbol-value table)))
+ abbrev-table-name-list))))))
+
+(ert-deftest abbrev-table-name-test ()
+ "Test returning name of abbrev-table"
+ (let ((ert-test-abbrevs (setup-test-abbrev-table))
+ (no-such-table nil))
+ (should (equal 'ert-test-abbrevs (abbrev-table-name ert-test-abbrevs)))
+ (should (equal nil (abbrev-table-name no-such-table)))))
+
+(ert-deftest clear-abbrev-table-test ()
+ "Test clearing single abbrev table"
+ (let ((ert-test-abbrevs (setup-test-abbrev-table)))
+ (should (equal "a-e-t" (symbol-name
+ (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+ (should (equal "abbrev-ert-test" (symbol-value
+ (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+
+ (clear-abbrev-table ert-test-abbrevs)
+
+ (should (equal "nil" (symbol-name
+ (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+ (should (equal nil (symbol-value
+ (abbrev-symbol "a-e-t" ert-test-abbrevs))))
+ (should (equal t (abbrev-table-empty-p ert-test-abbrevs)))))
+
(provide 'abbrev-tests)
;;; abbrev-tests.el ends here
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index 6f186973ee7..043f80de49e 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -39,7 +39,9 @@
(null (string-match
(format-message "Reverting buffer `%s'." (buffer-name buffer))
(buffer-string)))
- (read-event nil nil 0.1)))))
+ (if (with-current-buffer buffer auto-revert-use-notify)
+ (read-event nil nil 0.1)
+ (sleep-for 0.1))))))
(ert-deftest auto-revert-test00-auto-revert-mode ()
"Check autorevert for a file."
diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el
index 7e05d49883e..829cbf2d765 100644
--- a/test/lisp/calendar/icalendar-tests.el
+++ b/test/lisp/calendar/icalendar-tests.el
@@ -2231,7 +2231,63 @@ END:VCALENDAR"
Class: PUBLIC
UID: 040000008200E00074C5B7101A82E0080000000020FFAED0CFEFCC01000000000000000010000000575268034ECDB649A15349B1BF240F15
" nil)
+
+ ;; 2015-12-05, mixed line endings and empty lines, see Bug#22092.
+ (icalendar-tests--test-import
+ "BEGIN:VCALENDAR\r
+PRODID:-//www.norwegian.no//iCalendar MIMEDIR//EN\r
+VERSION:2.0\r
+METHOD:REQUEST\r
+BEGIN:VEVENT\r
+UID:RFCALITEM1\r
+SEQUENCE:1512040950\r
+DTSTAMP:20141204T095043Z\r
+ORGANIZER:noreply@norwegian.no\r
+DTSTART:20141208T173000Z\r
+
+DTEND:20141208T215500Z\r
+
+LOCATION:Stavanger-Sola\r
+
+DESCRIPTION:Fly med Norwegian, reservasjon. Fra Stavanger til Troms&#248; 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Troms&#248; 8. des 2014 21:00, DY390\r
+
+X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\"><html><head><META NAME=\"Generator\" CONTENT=\"MS Exchange Server version 08.00.0681.000\"><title></title></head><body><b><font face=\"Calibri\" size=\"3\">Reisereferanse</p></body></html>
+SUMMARY:Norwegian til Tromsoe-Langnes -\r
+
+CATEGORIES:Appointment\r
+
+
+PRIORITY:5\r
+
+CLASS:PUBLIC\r
+
+TRANSP:OPAQUE\r
+END:VEVENT\r
+END:VCALENDAR
+"
+"&2014/12/8 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Troms&#248; 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Troms&#248; 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
+"&8/12/2014 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Troms&#248; 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Troms&#248; 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
+"&12/8/2014 18:30-22:55 Norwegian til Tromsoe-Langnes -
+ Desc: Fly med Norwegian, reservasjon. Fra Stavanger til Troms&#248; 8. des 2014 18:30, DY545Fly med Norwegian, reservasjon . Fra Stavanger til Troms&#248; 8. des 2014 21:00, DY390
+ Location: Stavanger-Sola
+ Organizer: noreply@norwegian.no
+ Class: PUBLIC
+ UID: RFCALITEM1
+"
)
+ )
(provide 'icalendar-tests)
;;; icalendar-tests.el ends here
diff --git a/test/lisp/character-fold-tests.el b/test/lisp/character-fold-tests.el
index 2b1a15c9e76..c0568625649 100644
--- a/test/lisp/character-fold-tests.el
+++ b/test/lisp/character-fold-tests.el
@@ -37,13 +37,13 @@
(ert-deftest character-fold--test-consistency ()
- (dotimes (n 100)
+ (dotimes (n 30)
(let ((w (character-fold--random-word n)))
;; A folded string should always match the original string.
(character-fold--test-search-with-contents w w))))
(ert-deftest character-fold--test-lax-whitespace ()
- (dotimes (n 100)
+ (dotimes (n 40)
(let ((w1 (character-fold--random-word n))
(w2 (character-fold--random-word n))
(search-spaces-regexp "\\s-+"))
@@ -52,7 +52,73 @@
(concat w1 " " w2))
(character-fold--test-search-with-contents
(concat w1 "\s\n\s\t\f\t\n\r\t" w2)
- (concat w1 (make-string 90 ?\s) w2)))))
+ (concat w1 (make-string 10 ?\s) w2)))))
+
+(defun character-fold--test-match-exactly (string &rest strings-to-match)
+ (let ((re (concat "\\`" (character-fold-to-regexp string) "\\'")))
+ (dolist (it strings-to-match)
+ (should (string-match re it)))
+ ;; Case folding
+ (let ((case-fold-search t))
+ (dolist (it strings-to-match)
+ (should (string-match (upcase re) (downcase it)))
+ (should (string-match (downcase re) (upcase it)))))))
+
+(ert-deftest character-fold--test-some-defaults ()
+ (dolist (it '(("ffl" . "ffl") ("ffi" . "ffi")
+ ("fi" . "fi") ("ff" . "ff")
+ ("ä" . "ä")))
+ (character-fold--test-search-with-contents (cdr it) (car it))
+ (let ((multi (char-table-extra-slot character-fold-table 0))
+ (character-fold-table (make-char-table 'character-fold-table)))
+ (set-char-table-extra-slot character-fold-table 0 multi)
+ (character-fold--test-match-exactly (car it) (cdr it)))))
+
+(ert-deftest character-fold--test-fold-to-regexp ()
+ (let ((character-fold-table (make-char-table 'character-fold-table))
+ (multi (make-char-table 'character-fold-table)))
+ (set-char-table-extra-slot character-fold-table 0 multi)
+ (aset character-fold-table ?a "xx")
+ (aset character-fold-table ?1 "44")
+ (aset character-fold-table ?\s "-!-")
+ (character-fold--test-match-exactly "a1a1" "xx44xx44")
+ (character-fold--test-match-exactly "a1 a 1" "xx44-!--!-xx-!-44")
+ (aset multi ?a '(("1" . "99")
+ ("2" . "88")
+ ("12" . "77")))
+ (character-fold--test-match-exactly "a" "xx")
+ (character-fold--test-match-exactly "a1" "xx44" "99")
+ (character-fold--test-match-exactly "a12" "77" "xx442" "992")
+ (character-fold--test-match-exactly "a2" "88")
+ (aset multi ?1 '(("2" . "yy")))
+ (character-fold--test-match-exactly "a1" "xx44" "99")
+ (character-fold--test-match-exactly "a12" "77" "xx442" "992")
+ ;; Support for this case is disabled. See function definition or:
+ ;; https://lists.gnu.org/archive/html/emacs-devel/2015-11/msg02562.html
+ ;; (character-fold--test-match-exactly "a12" "xxyy")
+ ))
+
+(ert-deftest character-fold--speed-test ()
+ (dolist (string (append '("tty-set-up-initial-frame-face"
+ "tty-set-up-initial-frame-face-frame-faceframe-faceframe-faceframe-face")
+ (mapcar #'character-fold--random-word '(10 50 100
+ 50 100))))
+ (message "Testing %s" string)
+ ;; Make sure we didn't just fallback on the trivial search.
+ (should-not (string= (regexp-quote string)
+ (character-fold-to-regexp string)))
+ (with-temp-buffer
+ (save-excursion (insert string))
+ (let ((time (time-to-seconds (current-time))))
+ ;; Our initial implementation of case-folding in char-folding
+ ;; created a lot of redundant paths in the regexp. Because of
+ ;; that, if a really long string "almost" matches, the regexp
+ ;; engine took a long time to realize that it doesn't match.
+ (should-not (character-fold-search-forward (concat string "c") nil 'noerror))
+ ;; Ensure it took less than a second.
+ (should (< (- (time-to-seconds (current-time))
+ time)
+ 1))))))
(provide 'character-fold-tests)
;;; character-fold-tests.el ends here
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index 6b3069c2a54..7206084f324 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -242,6 +242,20 @@ Must called from within a `tar-mode' buffer."
(should (package-installed-p 'simple-single))
(should (package-installed-p 'simple-depend))))
+(ert-deftest package-test-macro-compilation ()
+ "Install a package which includes a dependency."
+ (with-package-test (:basedir "data/package")
+ (package-install-file (expand-file-name "macro-problem-package-1.0/"))
+ (require 'macro-problem)
+ ;; `macro-problem-func' uses a macro from `macro-aux'.
+ (should (equal (macro-problem-func) '(progn a b)))
+ (package-install-file (expand-file-name "macro-problem-package-2.0/"))
+ ;; After upgrading, `macro-problem-func' depends on a new version
+ ;; of the macro from `macro-aux'.
+ (should (equal (macro-problem-func) '(1 b)))
+ ;; `macro-problem-10-and-90' depends on an entirely new macro from `macro-aux'.
+ (should (equal (macro-problem-10-and-90) '(10 90)))))
+
(ert-deftest package-test-install-two-dependencies ()
"Install a package which includes a dependency."
(with-package-test ()
diff --git a/test/lisp/faces-tests.el b/test/lisp/faces-tests.el
index 007bc805120..ff9dfc53fbe 100644
--- a/test/lisp/faces-tests.el
+++ b/test/lisp/faces-tests.el
@@ -38,6 +38,11 @@
(should (equal (background-color-at-point) "black"))
(should (equal (foreground-color-at-point) "black")))
(with-temp-buffer
+ (insert (propertize "STRING" 'face '(:foreground "black" :background "black")))
+ (goto-char (point-min))
+ (should (equal (background-color-at-point) "black"))
+ (should (equal (foreground-color-at-point) "black")))
+ (with-temp-buffer
(emacs-lisp-mode)
(setq-local font-lock-comment-face 'faces--test1)
(setq-local font-lock-constant-face 'faces--test2)
diff --git a/test/lisp/gnus/auth-source-tests.el b/test/lisp/gnus/auth-source-tests.el
index 0b49b9013f7..dd70d546d5c 100644
--- a/test/lisp/gnus/auth-source-tests.el
+++ b/test/lisp/gnus/auth-source-tests.el
@@ -174,5 +174,50 @@
(:search-function . auth-source-secrets-search)
(:create-function . auth-source-secrets-create)))))
+(defun auth-source--test-netrc-parse-entry (entry host user port)
+ "Parse a netrc entry from buffer."
+ (auth-source-forget-all-cached)
+ (setq port (auth-source-ensure-strings port))
+ (with-temp-buffer
+ (insert entry)
+ (goto-char (point-min))
+ (let* ((check (lambda(alist)
+ (and alist
+ (auth-source-search-collection
+ host
+ (or
+ (auth-source--aget alist "machine")
+ (auth-source--aget alist "host")
+ t))
+ (auth-source-search-collection
+ user
+ (or
+ (auth-source--aget alist "login")
+ (auth-source--aget alist "account")
+ (auth-source--aget alist "user")
+ t))
+ (auth-source-search-collection
+ port
+ (or
+ (auth-source--aget alist "port")
+ (auth-source--aget alist "protocol")
+ t)))))
+ (entries (auth-source-netrc-parse-entries check 1)))
+ entries)))
+
+(ert-deftest auth-source-test-netrc-parse-entry ()
+ (should (equal (auth-source--test-netrc-parse-entry
+ "machine mymachine1 login user1 password pass1\n" t t t)
+ '((("password" . "pass1")
+ ("login" . "user1")
+ ("machine" . "mymachine1")))))
+ (should (equal (auth-source--test-netrc-parse-entry
+ "machine mymachine1 login user1 password pass1 port 100\n"
+ t t t)
+ '((("port" . "100")
+ ("password" . "pass1")
+ ("login" . "user1")
+ ("machine" . "mymachine1"))))))
+
(provide 'auth-source-tests)
;;; auth-source-tests.el ends here
diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el
index 49a72b0e67a..790b5c15125 100644
--- a/test/lisp/gnus/message-tests.el
+++ b/test/lisp/gnus/message-tests.el
@@ -40,9 +40,9 @@
"and here's a closer ")
(let ((last-command-event ?\)))
(ert-simulate-command '(self-insert-command 1)))
- ;; Syntax propertization doesn't kick in batch mode
- (when noninteractive
- (syntax-propertize (point-max)))
+ ;; Auto syntax propertization doesn't kick in until
+ ;; parse-sexp-lookup-properties is set.
+ (setq-local parse-sexp-lookup-properties t)
(backward-sexp)
(should (string= "here's an opener "
(buffer-substring-no-properties
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index b8772eb84d6..79e90f7819c 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -57,4 +57,14 @@
(should (search-forward
"(defgh\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f X)"))))
+(ert-deftest help-fns-test-describe-symbol ()
+ "Test the `describe-symbol' function."
+ ;; 'describe-symbol' would originally signal an error for
+ ;; 'font-lock-comment-face'.
+ (describe-symbol 'font-lock-comment-face)
+ (with-current-buffer "*Help*"
+ (should (> (point-max) 1))
+ (goto-char (point-min))
+ (should (looking-at "^font-lock-comment-face is "))))
+
;;; help-fns.el ends here
diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el
index 8f0cd6f0857..bb043dc4e05 100644
--- a/test/lisp/json-tests.el
+++ b/test/lisp/json-tests.el
@@ -22,6 +22,38 @@
(require 'ert)
(require 'json)
+(defmacro json-tests--with-temp-buffer (content &rest body)
+ "Create a temporary buffer with CONTENT and evaluate BODY there.
+Point is moved to beginning of the buffer."
+ (declare (indent 1))
+ `(with-temp-buffer
+ (insert ,content)
+ (goto-char (point-min))
+ ,@body))
+
+;;; Utilities
+
+(ert-deftest test-json-join ()
+ (should (equal (json-join '() ", ") ""))
+ (should (equal (json-join '("a" "b" "c") ", ") "a, b, c")))
+
+(ert-deftest test-json-alist-p ()
+ (should (json-alist-p '()))
+ (should (json-alist-p '((a 1) (b 2) (c 3))))
+ (should (json-alist-p '((:a 1) (:b 2) (:c 3))))
+ (should (json-alist-p '(("a" 1) ("b" 2) ("c" 3))))
+ (should-not (json-alist-p '(:a :b :c)))
+ (should-not (json-alist-p '(:a 1 :b 2 :c 3)))
+ (should-not (json-alist-p '((:a 1) (:b 2) 3))))
+
+(ert-deftest test-json-plist-p ()
+ (should (json-plist-p '()))
+ (should (json-plist-p '(:a 1 :b 2 :c 3)))
+ (should-not (json-plist-p '(a 1 b 2 c 3)))
+ (should-not (json-plist-p '("a" 1 "b" 2 "c" 3)))
+ (should-not (json-plist-p '(:a :b :c)))
+ (should-not (json-plist-p '((:a 1) (:b 2) (:c 3)))))
+
(ert-deftest test-json-plist-reverse ()
(should (equal (json--plist-reverse '()) '()))
(should (equal (json--plist-reverse '(:a 1)) '(:a 1)))
@@ -34,49 +66,32 @@
(should (equal (json--plist-to-alist '(:a 1 :b 2 :c 3))
'((:a . 1) (:b . 2) (:c . 3)))))
-(ert-deftest test-json-encode-plist ()
- (let ((plist '(:a 1 :b 2)))
- (should (equal (json-encode plist) "{\"a\":1,\"b\":2}"))))
-
-(ert-deftest json-encode-simple-alist ()
- (should (equal (json-encode '((a . 1)
- (b . 2)))
- "{\"a\":1,\"b\":2}")))
-
-(ert-deftest test-json-encode-hash-table ()
- (let ((hash-table (make-hash-table))
- (json-encoding-object-sort-predicate 'string<))
- (puthash :a 1 hash-table)
- (puthash :b 2 hash-table)
- (puthash :c 3 hash-table)
- (should (equal (json-encode hash-table)
- "{\"a\":1,\"b\":2,\"c\":3}"))))
-
-(ert-deftest test-json-encode-alist-with-sort-predicate ()
- (let ((alist '((:c . 3) (:a . 1) (:b . 2)))
- (json-encoding-object-sort-predicate 'string<))
- (should (equal (json-encode alist) "{\"a\":1,\"b\":2,\"c\":3}"))))
+(ert-deftest test-json-advance ()
+ (json-tests--with-temp-buffer "{ \"a\": 1 }"
+ (json-advance 0)
+ (should (= (point) (point-min)))
+ (json-advance 3)
+ (should (= (point) (+ (point-min) 3)))))
-(ert-deftest test-json-encode-plist-with-sort-predicate ()
- (let ((plist '(:c 3 :a 1 :b 2))
- (json-encoding-object-sort-predicate 'string<))
- (should (equal (json-encode plist) "{\"a\":1,\"b\":2,\"c\":3}"))))
+(ert-deftest test-json-peek ()
+ (json-tests--with-temp-buffer ""
+ (should (eq (json-peek) :json-eof)))
+ (json-tests--with-temp-buffer "{ \"a\": 1 }"
+ (should (equal (json-peek) ?{))))
-(ert-deftest json-read-simple-alist ()
- (let ((json-object-type 'alist))
- (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}")
- '((a . 1)
- (b . 2))))))
+(ert-deftest test-json-pop ()
+ (json-tests--with-temp-buffer ""
+ (should-error (json-pop) :type 'json-end-of-file))
+ (json-tests--with-temp-buffer "{ \"a\": 1 }"
+ (should (equal (json-pop) ?{))
+ (should (= (point) (+ (point-min) 1)))))
-(ert-deftest json-encode-string-with-special-chars ()
- (should (equal (json-encode-string "a\n\fb")
- "\"a\\n\\fb\""))
- (should (equal (json-encode-string "\nasdфыв\u001f\u007ffgh\t")
- "\"\\nasdфыв\\u001f\u007ffgh\\t\"")))
+(ert-deftest test-json-skip-whitespace ()
+ (json-tests--with-temp-buffer "\t\r\n\f\b { \"a\": 1 }"
+ (json-skip-whitespace)
+ (should (equal (char-after (point)) ?{))))
-(ert-deftest json-read-string-with-special-chars ()
- (should (equal (json-read-from-string "\"\\nasd\\u0444\\u044b\\u0432fgh\\t\"")
- "\nasdфывfgh\t")))
+;;; Paths
(ert-deftest test-json-path-to-position-with-objects ()
(let* ((json-string "{\"foo\": {\"bar\": {\"baz\": \"value\"}}}")
@@ -97,5 +112,209 @@
(matched-path (json-path-to-position 5 json-string)))
(should (null matched-path))))
+;;; Keywords
+
+(ert-deftest test-json-read-keyword ()
+ (json-tests--with-temp-buffer "true"
+ (should (json-read-keyword "true")))
+ (json-tests--with-temp-buffer "true"
+ (should-error
+ (json-read-keyword "false") :type 'json-unknown-keyword))
+ (json-tests--with-temp-buffer "foo"
+ (should-error
+ (json-read-keyword "foo") :type 'json-unknown-keyword)))
+
+(ert-deftest test-json-encode-keyword ()
+ (should (equal (json-encode-keyword t) "true"))
+ (should (equal (json-encode-keyword json-false) "false"))
+ (should (equal (json-encode-keyword json-null) "null")))
+
+;;; Numbers
+
+(ert-deftest test-json-read-number ()
+ (json-tests--with-temp-buffer "3"
+ (should (= (json-read-number) 3)))
+ (json-tests--with-temp-buffer "-5"
+ (should (= (json-read-number) -5)))
+ (json-tests--with-temp-buffer "123.456"
+ (should (= (json-read-number) 123.456)))
+ (json-tests--with-temp-buffer "1e3"
+ (should (= (json-read-number) 1e3)))
+ (json-tests--with-temp-buffer "2e+3"
+ (should (= (json-read-number) 2e3)))
+ (json-tests--with-temp-buffer "3E3"
+ (should (= (json-read-number) 3e3)))
+ (json-tests--with-temp-buffer "1e-7"
+ (should (= (json-read-number) 1e-7)))
+ (json-tests--with-temp-buffer "abc"
+ (should-error (json-read-number) :type 'json-number-format)))
+
+(ert-deftest test-json-encode-number ()
+ (should (equal (json-encode-number 3) "3"))
+ (should (equal (json-encode-number -5) "-5"))
+ (should (equal (json-encode-number 123.456) "123.456")))
+
+;; Strings
+
+(ert-deftest test-json-read-escaped-char ()
+ (json-tests--with-temp-buffer "\\\""
+ (should (equal (json-read-escaped-char) ?\"))))
+
+(ert-deftest test-json-read-string ()
+ (json-tests--with-temp-buffer "\"foo \\\"bar\\\"\""
+ (should (equal (json-read-string) "foo \"bar\"")))
+ (json-tests--with-temp-buffer "\"abcαβγ\""
+ (should (equal (json-read-string) "abcαβγ")))
+ (json-tests--with-temp-buffer "\"\\nasd\\u0444\\u044b\\u0432fgh\\t\""
+ (should (equal (json-read-string) "\nasdфывfgh\t")))
+ (json-tests--with-temp-buffer "foo"
+ (should-error (json-read-string) :type 'json-string-format)))
+
+(ert-deftest test-json-encode-string ()
+ (should (equal (json-encode-string "foo") "\"foo\""))
+ (should (equal (json-encode-string "a\n\fb") "\"a\\n\\fb\""))
+ (should (equal (json-encode-string "\nasdфыв\u001f\u007ffgh\t")
+ "\"\\nasdфыв\\u001f\u007ffgh\\t\"")))
+
+(ert-deftest test-json-encode-key ()
+ (should (equal (json-encode-key "foo") "\"foo\""))
+ (should (equal (json-encode-key 'foo) "\"foo\""))
+ (should (equal (json-encode-key :foo) "\"foo\""))
+ (should-error (json-encode-key 5) :type 'json-key-format)
+ (should-error (json-encode-key ["foo"]) :type 'json-key-format)
+ (should-error (json-encode-key '("foo")) :type 'json-key-format))
+
+;;; Objects
+
+(ert-deftest test-json-new-object ()
+ (let ((json-object-type 'alist))
+ (should (equal (json-new-object) '())))
+ (let ((json-object-type 'plist))
+ (should (equal (json-new-object) '())))
+ (let* ((json-object-type 'hash-table)
+ (json-object (json-new-object)))
+ (should (hash-table-p json-object))
+ (should (= (hash-table-count json-object) 0))))
+
+(ert-deftest test-json-add-to-object ()
+ (let* ((json-object-type 'alist)
+ (json-key-type nil)
+ (obj (json-new-object)))
+ (setq obj (json-add-to-object obj "a" 1))
+ (setq obj (json-add-to-object obj "b" 2))
+ (should (equal (assq 'a obj) '(a . 1)))
+ (should (equal (assq 'b obj) '(b . 2))))
+ (let* ((json-object-type 'plist)
+ (json-key-type nil)
+ (obj (json-new-object)))
+ (setq obj (json-add-to-object obj "a" 1))
+ (setq obj (json-add-to-object obj "b" 2))
+ (should (= (plist-get obj :a) 1))
+ (should (= (plist-get obj :b) 2)))
+ (let* ((json-object-type 'hash-table)
+ (json-key-type nil)
+ (obj (json-new-object)))
+ (setq obj (json-add-to-object obj "a" 1))
+ (setq obj (json-add-to-object obj "b" 2))
+ (should (= (gethash "a" obj) 1))
+ (should (= (gethash "b" obj) 2))))
+
+(ert-deftest test-json-read-object ()
+ (json-tests--with-temp-buffer "{ \"a\": 1, \"b\": 2 }"
+ (let ((json-object-type 'alist))
+ (should (equal (json-read-object) '((a . 1) (b . 2))))))
+ (json-tests--with-temp-buffer "{ \"a\": 1, \"b\": 2 }"
+ (let ((json-object-type 'plist))
+ (should (equal (json-read-object) '(:a 1 :b 2)))))
+ (json-tests--with-temp-buffer "{ \"a\": 1, \"b\": 2 }"
+ (let* ((json-object-type 'hash-table)
+ (hash-table (json-read-object)))
+ (should (= (gethash "a" hash-table) 1))
+ (should (= (gethash "b" hash-table) 2))))
+ (json-tests--with-temp-buffer "{ \"a\": 1 \"b\": 2 }"
+ (should-error (json-read-object) :type 'json-object-format)))
+
+(ert-deftest test-json-encode-hash-table ()
+ (let ((hash-table (make-hash-table))
+ (json-encoding-object-sort-predicate 'string<)
+ (json-encoding-pretty-print nil))
+ (puthash :a 1 hash-table)
+ (puthash :b 2 hash-table)
+ (puthash :c 3 hash-table)
+ (should (equal (json-encode hash-table)
+ "{\"a\":1,\"b\":2,\"c\":3}"))))
+
+(ert-deftest json-encode-simple-alist ()
+ (let ((json-encoding-pretty-print nil))
+ (should (equal (json-encode '((a . 1) (b . 2)))
+ "{\"a\":1,\"b\":2}"))))
+
+(ert-deftest test-json-encode-plist ()
+ (let ((plist '(:a 1 :b 2))
+ (json-encoding-pretty-print nil))
+ (should (equal (json-encode plist) "{\"a\":1,\"b\":2}"))))
+
+(ert-deftest test-json-encode-plist-with-sort-predicate ()
+ (let ((plist '(:c 3 :a 1 :b 2))
+ (json-encoding-object-sort-predicate 'string<)
+ (json-encoding-pretty-print nil))
+ (should (equal (json-encode plist) "{\"a\":1,\"b\":2,\"c\":3}"))))
+
+(ert-deftest test-json-encode-alist-with-sort-predicate ()
+ (let ((alist '((:c . 3) (:a . 1) (:b . 2)))
+ (json-encoding-object-sort-predicate 'string<)
+ (json-encoding-pretty-print nil))
+ (should (equal (json-encode alist) "{\"a\":1,\"b\":2,\"c\":3}"))))
+
+(ert-deftest test-json-encode-list ()
+ (let ((json-encoding-pretty-print nil))
+ (should (equal (json-encode-list '(:a 1 :b 2))
+ "{\"a\":1,\"b\":2}"))
+ (should (equal (json-encode-list '((:a . 1) (:b . 2)))
+ "{\"a\":1,\"b\":2}"))
+ (should (equal (json-encode-list '(1 2 3 4)) "[1,2,3,4]"))))
+
+;;; Arrays
+
+(ert-deftest test-json-read-array ()
+ (let ((json-array-type 'vector))
+ (json-tests--with-temp-buffer "[1, 2, \"a\", \"b\"]"
+ (should (equal (json-read-array) [1 2 "a" "b"]))))
+ (let ((json-array-type 'list))
+ (json-tests--with-temp-buffer "[1, 2, \"a\", \"b\"]"
+ (should (equal (json-read-array) '(1 2 "a" "b")))))
+ (json-tests--with-temp-buffer "[1 2]"
+ (should-error (json-read-array) :type 'json-error)))
+
+(ert-deftest test-json-encode-array ()
+ (let ((json-encoding-pretty-print nil))
+ (should (equal (json-encode-array [1 2 "a" "b"])
+ "[1,2,\"a\",\"b\"]"))))
+
+;;; Reader
+
+(ert-deftest test-json-read ()
+ (json-tests--with-temp-buffer "{ \"a\": 1 }"
+ ;; We don't care exactly what the return value is (that is tested
+ ;; in `test-json-read-object'), but it should parse without error.
+ (should (json-read)))
+ (json-tests--with-temp-buffer ""
+ (should-error (json-read) :type 'json-end-of-file))
+ (json-tests--with-temp-buffer "xxx"
+ (should-error (json-read) :type 'json-readtable-error)))
+
+(ert-deftest test-json-read-from-string ()
+ (let ((json-string "{ \"a\": 1 }"))
+ (json-tests--with-temp-buffer json-string
+ (should (equal (json-read-from-string json-string)
+ (json-read))))))
+
+;;; JSON encoder
+
+(ert-deftest test-json-encode ()
+ (should (equal (json-encode "foo") "\"foo\""))
+ (with-temp-buffer
+ (should-error (json-encode (current-buffer)) :type 'json-error)))
+
(provide 'json-tests)
;;; json-tests.el ends here
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index c5cab7d5991..23171d6e983 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -1608,6 +1608,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(vc-handled-backends
(with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
(cond
+ ((tramp-find-executable v vc-git-program (tramp-get-remote-path v))
+ '(Git))
+ ((tramp-find-executable v vc-hg-program (tramp-get-remote-path v))
+ '(Hg))
((tramp-find-executable v vc-bzr-program (tramp-get-remote-path v))
(setq tramp-remote-process-environment
(cons (format "BZR_HOME=%s"
@@ -1618,10 +1622,6 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(tramp-dissect-file-name tramp-test-temporary-file-directory)
nil 'keep-password)
'(Bzr))
- ((tramp-find-executable v vc-git-program (tramp-get-remote-path v))
- '(Git))
- ((tramp-find-executable v vc-hg-program (tramp-get-remote-path v))
- '(Hg))
(t nil)))))
(skip-unless vc-handled-backends)
(message "%s" vc-handled-backends)
@@ -1637,7 +1637,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(let ((default-directory tmp-name1))
;; Create empty repository, and register the file.
- (vc-create-repo (car vc-handled-backends))
+ ;; Sometimes, creation of repository fails (bzr!); we skip
+ ;; the test then.
+ (condition-case nil
+ (vc-create-repo (car vc-handled-backends))
+ (error (skip-unless nil)))
;; The structure of VC-FILESET is not documented. Let's
;; hope it won't change.
(condition-case nil
@@ -1772,6 +1776,14 @@ Several special characters do not work properly there."
(file-truename tramp-test-temporary-file-directory) nil
(string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
+(defun tramp--test-darwin-p ()
+ "Check, whether the remote host runs Mac OS X.
+Several special characters do not work properly there."
+ ;; We must refill the cache. `file-truename' does it.
+ (with-parsed-tramp-file-name
+ (file-truename tramp-test-temporary-file-directory) nil
+ (string-match "^Darwin" (tramp-get-connection-property v "uname" ""))))
+
(defun tramp--test-check-files (&rest files)
"Run a simple but comprehensive test over every file in FILES."
;; We must use `file-truename' for the temporary directory, because
@@ -1987,7 +1999,10 @@ Use the `perl' command."
(let ((tramp-connection-properties
(append
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
- "stat" nil))
+ "stat" nil)
+ ;; See `tramp-sh-handle-file-truename'.
+ (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
+ "readlink" nil))
tramp-connection-properties)))
(tramp--test-special-characters)))
@@ -2005,21 +2020,25 @@ Use the `ls' command."
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
"perl" nil)
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
- "stat" nil))
+ "stat" nil)
+ ;; See `tramp-sh-handle-file-truename'.
+ (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
+ "readlink" nil))
tramp-connection-properties)))
(tramp--test-special-characters)))
(defun tramp--test-utf8 ()
"Perform the test in `tramp-test32-utf8*'."
+ (tramp--instrument-test-case 10
(let ((coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8)
(file-name-coding-system 'utf-8))
(tramp--test-check-files
(unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
- (unless (tramp--test-hpux-p)
+ (unless (or (tramp--test-hpux-p) (tramp--test-darwin-p))
"أصبح بوسعك الآن تنزيل نسخة كاملة من موسوعة ويكيبيديا العربية لتصفحها بلا اتصال بالإنترنت")
"银河系漫游指南系列"
- "Автостопом по гала́ктике")))
+ "Автостопом по гала́ктике"))))
(ert-deftest tramp-test32-utf8 ()
"Check UTF8 encoding in file names and file contents."
@@ -2059,7 +2078,10 @@ Use the `perl' command."
(let ((tramp-connection-properties
(append
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
- "stat" nil))
+ "stat" nil)
+ ;; See `tramp-sh-handle-file-truename'.
+ (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
+ "readlink" nil))
tramp-connection-properties)))
(tramp--test-utf8)))
@@ -2077,7 +2099,10 @@ Use the `ls' command."
`((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
"perl" nil)
(,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
- "stat" nil))
+ "stat" nil)
+ ;; See `tramp-sh-handle-file-truename'.
+ (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
+ "readlink" nil))
tramp-connection-properties)))
(tramp--test-utf8)))
diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el
index 97f86a969aa..2d0452f69d7 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -543,7 +543,7 @@ to (xref-elisp-test-descr-to-target xref)."
;; FIXME: deftype
(xref-elisp-deftest find-defs-defun-c-defvar-c
- (elisp--xref-find-definitions 'system-name)
+ (xref-backend-definitions 'elisp "system-name")
(list
(xref-make "(defvar system-name)"
(xref-make-elisp-location 'system-name 'defvar "src/editfns.c"))
@@ -552,7 +552,7 @@ to (xref-elisp-test-descr-to-target xref)."
)
(xref-elisp-deftest find-defs-defun-el-defvar-c
- (elisp--xref-find-definitions 'abbrev-mode)
+ (xref-backend-definitions 'elisp "abbrev-mode")
;; It's a minor mode, but the variable is defined in buffer.c
(list
(xref-make "(defvar abbrev-mode)"
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 07b5eaa93e4..771241ad7ef 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -138,6 +138,12 @@
(open-line 1)))
'("- - " . "\n(a b c d)"))))
+;; For a while, from 24 Oct - 21 Nov 2015, `open-line' in the Emacs
+;; development tree became sensitive to `electric-indent-mode', which
+;; it had not been before. This sensitivity was reverted for the
+;; Emacs 25 release, so it could be discussed further (see thread
+;; "Questioning the new behavior of `open-line'." on the Emacs Devel
+;; mailing list, and bug #21884).
(ert-deftest open-line-indent ()
(should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1)
@@ -145,29 +151,34 @@
'("(a b" . "\n c d)")))
(should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1)
- (open-line 1 'interactive))
- '("(a b" . "\n c d)")))
+ (open-line 1))
+ '("(a b" . "\n c d)")))
(should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1)
(let ((current-prefix-arg nil))
(call-interactively #'open-line)
(call-interactively #'open-line)))
- '("(a b" . "\n\n c d)")))
+ '("(a b" . "\n\n c d)")))
(should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1)
- (open-line 5 'interactive))
- '("(a b" . "\n\n\n\n\n c d)")))
+ (open-line 5))
+ '("(a b" . "\n\n\n\n\n c d)")))
(should (equal (simple-test--dummy-buffer
(electric-indent-local-mode 1)
(let ((current-prefix-arg 5))
(call-interactively #'open-line)))
- '("(a b" . "\n\n\n\n\n c d)")))
+ '("(a b" . "\n\n\n\n\n c d)")))
(should (equal (simple-test--dummy-buffer
(forward-char 1)
(electric-indent-local-mode 1)
- (open-line 1 'interactive))
- '("(a b" . "\n c d)"))))
+ (open-line 1))
+ '("(a b " . "\nc d)"))))
+;; From 24 Oct - 21 Nov 2015, `open-line' took a second argument
+;; INTERACTIVE and ran `post-self-insert-hook' if the argument was
+;; true. This test tested that. Currently, however, `open-line'
+;; does not run run `post-self-insert-hook' at all, so for now
+;; this test just makes sure that it doesn't.
(ert-deftest open-line-hook ()
(let* ((x 0)
(inc (lambda () (setq x (1+ x)))))
@@ -177,18 +188,18 @@
(should (= x 0))
(simple-test--dummy-buffer
(add-hook 'post-self-insert-hook inc nil 'local)
- (open-line 1 'interactive))
- (should (= x 1))
+ (open-line 1))
+ (should (= x 0))
(unwind-protect
(progn
(add-hook 'post-self-insert-hook inc)
(simple-test--dummy-buffer
(open-line 1))
- (should (= x 1))
+ (should (= x 0))
(simple-test--dummy-buffer
- (open-line 10 'interactive))
- (should (= x 2)))
+ (open-line 10))
+ (should (= x 0)))
(remove-hook 'post-self-insert-hook inc))))
@@ -215,9 +226,9 @@
;;; auto-boundary tests
-(ert-deftest undo-auto--boundary-timer ()
+(ert-deftest undo-auto-boundary-timer ()
(should
- undo-auto--current-boundary-timer))
+ undo-auto-current-boundary-timer))
(ert-deftest undo-auto--boundaries-added ()
;; The change in the buffer should have caused addition
@@ -252,5 +263,53 @@
'("(s1) (s4)" . " (s2) (s3) (s5)"))))
+;; Test for a regression introduced by undo-auto--boundaries changes.
+;; https://lists.gnu.org/archive/html/emacs-devel/2015-11/msg01652.html
+(defun undo-test-kill-c-a-then-undo ()
+ (with-temp-buffer
+ (switch-to-buffer (current-buffer))
+ (setq buffer-undo-list nil)
+ (insert "a\nb\n\c\n")
+ (goto-char (point-max))
+ ;; We use a keyboard macro because it adds undo events in the same
+ ;; way as if a user were involved.
+ (kmacro-call-macro nil nil nil
+ [left
+ ;; Delete "c"
+ backspace
+ left left left
+ ;; Delete "a"
+ backspace
+ ;; C-/ or undo
+ 67108911
+ ])
+ (point)))
+
+(defun undo-test-point-after-forward-kill ()
+ (with-temp-buffer
+ (switch-to-buffer (current-buffer))
+ (setq buffer-undo-list nil)
+ (insert "kill word forward")
+ ;; Move to word "word".
+ (goto-char 6)
+ (kmacro-call-macro nil nil nil
+ [
+ ;; kill-word
+ C-delete
+ ;; undo
+ 67108911
+ ])
+ (point)))
+
+(ert-deftest undo-point-in-wrong-place ()
+ (should
+ ;; returns 5 with the bug
+ (= 2
+ (undo-test-kill-c-a-then-undo)))
+ (should
+ (= 6
+ (undo-test-point-after-forward-kill))))
+
+
(provide 'simple-test)
;;; simple-test.el ends here
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index ee8db593b49..3fcb7d346a3 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -103,5 +103,117 @@
(should (equal (macroexpand-all '(when a b c d))
'(if a (progn b c d)))))
+(ert-deftest subr-test-version-parsing ()
+ (should (equal (version-to-list ".5") '(0 5)))
+ (should (equal (version-to-list "0.9 alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0.9 snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0.9-alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0.9-snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0.9.snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0.9_snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0.9alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0.9snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "1.0 git") '(1 0 -4)))
+ (should (equal (version-to-list "1.0 pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1.0-git") '(1 0 -4)))
+ (should (equal (version-to-list "1.0-pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1.0.1-a") '(1 0 1 1)))
+ (should (equal (version-to-list "1.0.1-f") '(1 0 1 6)))
+ (should (equal (version-to-list "1.0.1.a") '(1 0 1 1)))
+ (should (equal (version-to-list "1.0.1.f") '(1 0 1 6)))
+ (should (equal (version-to-list "1.0.1_a") '(1 0 1 1)))
+ (should (equal (version-to-list "1.0.1_f") '(1 0 1 6)))
+ (should (equal (version-to-list "1.0.1a") '(1 0 1 1)))
+ (should (equal (version-to-list "1.0.1f") '(1 0 1 6)))
+ (should (equal (version-to-list "1.0.7.5") '(1 0 7 5)))
+ (should (equal (version-to-list "1.0.git") '(1 0 -4)))
+ (should (equal (version-to-list "1.0.pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1.0_git") '(1 0 -4)))
+ (should (equal (version-to-list "1.0_pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1.0git") '(1 0 -4)))
+ (should (equal (version-to-list "1.0pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "22.8 beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22.8-beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22.8.beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22.8_beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22.8beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "6.9.30 Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6.9.30-Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6.9.30.Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6.9.30Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6.9.30_Beta") '(6 9 30 -2)))
+
+ (should (equal
+ (error-message-string (should-error (version-to-list "OTP-18.1.5")))
+ "Invalid version syntax: `OTP-18.1.5' (must start with a number)"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "")))
+ "Invalid version syntax: `' (must start with a number)"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "1.0..7.5")))
+ "Invalid version syntax: `1.0..7.5'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "1.0prepre2")))
+ "Invalid version syntax: `1.0prepre2'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "22.8X3")))
+ "Invalid version syntax: `22.8X3'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "beta22.8alpha3")))
+ "Invalid version syntax: `beta22.8alpha3' (must start with a number)"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "honk")))
+ "Invalid version syntax: `honk' (must start with a number)"))
+ (should (equal
+ (error-message-string (should-error (version-to-list 9)))
+ "Version must be a string"))
+
+ (let ((version-separator "_"))
+ (should (equal (version-to-list "_5") '(0 5)))
+ (should (equal (version-to-list "0_9 alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0_9 snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0_9-alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0_9-snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0_9.alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0_9.snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "0_9alpha1") '(0 9 -3 1)))
+ (should (equal (version-to-list "0_9snapshot") '(0 9 -4)))
+ (should (equal (version-to-list "1_0 git") '(1 0 -4)))
+ (should (equal (version-to-list "1_0 pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1_0-git") '(1 0 -4)))
+ (should (equal (version-to-list "1_0.pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "1_0_1-a") '(1 0 1 1)))
+ (should (equal (version-to-list "1_0_1-f") '(1 0 1 6)))
+ (should (equal (version-to-list "1_0_1.a") '(1 0 1 1)))
+ (should (equal (version-to-list "1_0_1.f") '(1 0 1 6)))
+ (should (equal (version-to-list "1_0_1_a") '(1 0 1 1)))
+ (should (equal (version-to-list "1_0_1_f") '(1 0 1 6)))
+ (should (equal (version-to-list "1_0_1a") '(1 0 1 1)))
+ (should (equal (version-to-list "1_0_1f") '(1 0 1 6)))
+ (should (equal (version-to-list "1_0_7_5") '(1 0 7 5)))
+ (should (equal (version-to-list "1_0_git") '(1 0 -4)))
+ (should (equal (version-to-list "1_0pre2") '(1 0 -1 2)))
+ (should (equal (version-to-list "22_8 beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22_8-beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22_8.beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "22_8beta3") '(22 8 -2 3)))
+ (should (equal (version-to-list "6_9_30 Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6_9_30-Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6_9_30.Beta") '(6 9 30 -2)))
+ (should (equal (version-to-list "6_9_30Beta") '(6 9 30 -2)))
+
+ (should (equal
+ (error-message-string (should-error (version-to-list "1_0__7_5")))
+ "Invalid version syntax: `1_0__7_5'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "1_0prepre2")))
+ "Invalid version syntax: `1_0prepre2'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "22.8X3")))
+ "Invalid version syntax: `22.8X3'"))
+ (should (equal
+ (error-message-string (should-error (version-to-list "beta22_8alpha3")))
+ "Invalid version syntax: `beta22_8alpha3' (must start with a number)"))))
+
(provide 'subr-tests)
;;; subr-tests.el ends here
diff --git a/test/lisp/url/url-expand-tests.el b/test/lisp/url/url-expand-tests.el
deleted file mode 100644
index 2bd28687f8d..00000000000
--- a/test/lisp/url/url-expand-tests.el
+++ /dev/null
@@ -1,105 +0,0 @@
-;;; url-expand-tests.el --- Test suite for relative URI/URL resolution.
-
-;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
-
-;; Author: Alain Schneble <a.s@realize.ch>
-;; Version: 1.0
-
-;; 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:
-
-;; Test cases covering URI reference resolution as described in RFC3986,
-;; section 5. Reference Resolution and especially the relative resolution
-;; rules specified in section 5.2. Relative Resolution.
-
-;; Each test calls `url-expand-file-name', typically with a relative
-;; reference URI and a base URI as string and compares the result (Actual)
-;; against a manually specified URI (Expected)
-
-;;; Code:
-
-(require 'url-expand)
-(require 'ert)
-
-(ert-deftest url-expand-file-name/relative-resolution-normal-examples ()
- "RFC 3986, Section 5.4 Reference Resolution Examples / Section 5.4.1. Normal Examples"
- (should (equal (url-expand-file-name "g:h" "http://a/b/c/d;p?q") "g:h"))
- (should (equal (url-expand-file-name "g" "http://a/b/c/d;p?q") "http://a/b/c/g"))
- (should (equal (url-expand-file-name "./g" "http://a/b/c/d;p?q") "http://a/b/c/g"))
- (should (equal (url-expand-file-name "g/" "http://a/b/c/d;p?q") "http://a/b/c/g/"))
- (should (equal (url-expand-file-name "/g" "http://a/b/c/d;p?q") "http://a/g"))
- (should (equal (url-expand-file-name "//g" "http://a/b/c/d;p?q") "http://g"))
- (should (equal (url-expand-file-name "?y" "http://a/b/c/d;p?q") "http://a/b/c/d;p?y"))
- (should (equal (url-expand-file-name "g?y" "http://a/b/c/d;p?q") "http://a/b/c/g?y"))
- (should (equal (url-expand-file-name "#s" "http://a/b/c/d;p?q") "http://a/b/c/d;p?q#s"))
- (should (equal (url-expand-file-name "g#s" "http://a/b/c/d;p?q") "http://a/b/c/g#s"))
- (should (equal (url-expand-file-name "g?y#s" "http://a/b/c/d;p?q") "http://a/b/c/g?y#s"))
- (should (equal (url-expand-file-name ";x" "http://a/b/c/d;p?q") "http://a/b/c/;x"))
- (should (equal (url-expand-file-name "g;x" "http://a/b/c/d;p?q") "http://a/b/c/g;x"))
- (should (equal (url-expand-file-name "g;x?y#s" "http://a/b/c/d;p?q") "http://a/b/c/g;x?y#s"))
- (should (equal (url-expand-file-name "" "http://a/b/c/d;p?q") "http://a/b/c/d;p?q"))
- (should (equal (url-expand-file-name "." "http://a/b/c/d;p?q") "http://a/b/c/"))
- (should (equal (url-expand-file-name "./" "http://a/b/c/d;p?q") "http://a/b/c/"))
- (should (equal (url-expand-file-name ".." "http://a/b/c/d;p?q") "http://a/b/"))
- (should (equal (url-expand-file-name "../" "http://a/b/c/d;p?q") "http://a/b/"))
- (should (equal (url-expand-file-name "../g" "http://a/b/c/d;p?q") "http://a/b/g"))
- (should (equal (url-expand-file-name "../.." "http://a/b/c/d;p?q") "http://a/"))
- (should (equal (url-expand-file-name "../../" "http://a/b/c/d;p?q") "http://a/"))
- (should (equal (url-expand-file-name "../../g" "http://a/b/c/d;p?q") "http://a/g")))
-
-(ert-deftest url-expand-file-name/relative-resolution-absolute-examples ()
- "RFC 3986, Section 5.4 Reference Resolution Examples / Section 5.4.2. Abnormal Examples"
- (should (equal (url-expand-file-name "../../../g" "http://a/b/c/d;p?q") "http://a/g"))
- (should (equal (url-expand-file-name "../../../../g" "http://a/b/c/d;p?q") "http://a/g"))
-
- (should (equal (url-expand-file-name "/./g" "http://a/b/c/d;p?q") "http://a/g"))
- (should (equal (url-expand-file-name "/../g" "http://a/b/c/d;p?q") "http://a/g"))
- (should (equal (url-expand-file-name "g." "http://a/b/c/d;p?q") "http://a/b/c/g."))
- (should (equal (url-expand-file-name ".g" "http://a/b/c/d;p?q") "http://a/b/c/.g"))
- (should (equal (url-expand-file-name "g.." "http://a/b/c/d;p?q") "http://a/b/c/g.."))
- (should (equal (url-expand-file-name "..g" "http://a/b/c/d;p?q") "http://a/b/c/..g"))
-
- (should (equal (url-expand-file-name "./../g" "http://a/b/c/d;p?q") "http://a/b/g"))
- (should (equal (url-expand-file-name "./g/." "http://a/b/c/d;p?q") "http://a/b/c/g/"))
- (should (equal (url-expand-file-name "g/./h" "http://a/b/c/d;p?q") "http://a/b/c/g/h"))
- (should (equal (url-expand-file-name "g/../h" "http://a/b/c/d;p?q") "http://a/b/c/h"))
- (should (equal (url-expand-file-name "g;x=1/./y" "http://a/b/c/d;p?q") "http://a/b/c/g;x=1/y"))
- (should (equal (url-expand-file-name "g;x=1/../y" "http://a/b/c/d;p?q") "http://a/b/c/y"))
-
- (should (equal (url-expand-file-name "g?y/./x" "http://a/b/c/d;p?q") "http://a/b/c/g?y/./x"))
- (should (equal (url-expand-file-name "g?y/../x" "http://a/b/c/d;p?q") "http://a/b/c/g?y/../x"))
- (should (equal (url-expand-file-name "g#s/./x" "http://a/b/c/d;p?q") "http://a/b/c/g#s/./x"))
- (should (equal (url-expand-file-name "g#s/../x" "http://a/b/c/d;p?q") "http://a/b/c/g#s/../x"))
-
- (should (equal (url-expand-file-name "http:g" "http://a/b/c/d;p?q") "http:g")) ; for strict parsers
- )
-
-(ert-deftest url-expand-file-name/relative-resolution-additional-examples ()
- "Reference Resolution Examples / Arbitrary Examples"
- (should (equal (url-expand-file-name "" "http://host/foobar") "http://host/foobar"))
- (should (equal (url-expand-file-name "?y" "http://a/b/c/d") "http://a/b/c/d?y"))
- (should (equal (url-expand-file-name "?y" "http://a/b/c/d/") "http://a/b/c/d/?y"))
- (should (equal (url-expand-file-name "?y#fragment" "http://a/b/c/d;p?q") "http://a/b/c/d;p?y#fragment"))
- (should (equal (url-expand-file-name "#bar" "http://host") "http://host#bar"))
- (should (equal (url-expand-file-name "#bar" "http://host/") "http://host/#bar"))
- (should (equal (url-expand-file-name "#bar" "http://host/foo") "http://host/foo#bar"))
- (should (equal (url-expand-file-name "foo#bar" "http://host/foobar") "http://host/foo#bar"))
- (should (equal (url-expand-file-name "foo#bar" "http://host/foobar/") "http://host/foobar/foo#bar")))
-
-(provide 'url-expand-tests)
-
-;;; url-expand-tests.el ends here