diff options
| author | Phillip Lord | 2015-11-23 22:02:42 +0000 |
|---|---|---|
| committer | Phillip Lord | 2015-11-24 17:04:22 +0000 |
| commit | 22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e (patch) | |
| tree | 779ff7e07667194416e01c6a6e8bd7b970244c70 /test/src | |
| parent | c378d6c33f751d1a0b97958f3cacfe0b07c72f58 (diff) | |
| download | emacs-22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e.tar.gz emacs-22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e.zip | |
Rename all test files to reflect source layout.
* CONTRIBUTE,Makefile.in,configure.ac: Update to reflect
test directory moves.
* test/file-organisation.org: New file.
* test/automated/Makefile.in
test/automated/data/decompress/foo.gz
test/automated/data/epg/pubkey.asc
test/automated/data/epg/seckey.asc
test/automated/data/files-bug18141.el.gz
test/automated/data/flymake/test.c
test/automated/data/flymake/test.pl
test/automated/data/package/archive-contents
test/automated/data/package/key.pub
test/automated/data/package/key.sec
test/automated/data/package/multi-file-0.2.3.tar
test/automated/data/package/multi-file-readme.txt
test/automated/data/package/newer-versions/archive-contents
test/automated/data/package/newer-versions/new-pkg-1.0.el
test/automated/data/package/newer-versions/simple-single-1.4.el
test/automated/data/package/package-test-server.py
test/automated/data/package/signed/archive-contents
test/automated/data/package/signed/archive-contents.sig
test/automated/data/package/signed/signed-bad-1.0.el
test/automated/data/package/signed/signed-bad-1.0.el.sig
test/automated/data/package/signed/signed-good-1.0.el
test/automated/data/package/signed/signed-good-1.0.el.sig
test/automated/data/package/simple-depend-1.0.el
test/automated/data/package/simple-single-1.3.el
test/automated/data/package/simple-single-readme.txt
test/automated/data/package/simple-two-depend-1.1.el
test/automated/abbrev-tests.el
test/automated/auto-revert-tests.el
test/automated/calc-tests.el
test/automated/icalendar-tests.el
test/automated/character-fold-tests.el
test/automated/comint-testsuite.el
test/automated/descr-text-test.el
test/automated/electric-tests.el
test/automated/cl-generic-tests.el
test/automated/cl-lib-tests.el
test/automated/eieio-test-methodinvoke.el
test/automated/eieio-test-persist.el
test/automated/eieio-tests.el
test/automated/ert-tests.el
test/automated/ert-x-tests.el
test/automated/generator-tests.el
test/automated/let-alist.el
test/automated/map-tests.el
test/automated/advice-tests.el
test/automated/package-test.el
test/automated/pcase-tests.el
test/automated/regexp-tests.el
test/automated/seq-tests.el
test/automated/subr-x-tests.el
test/automated/tabulated-list-test.el
test/automated/thunk-tests.el
test/automated/timer-tests.el
test/automated/epg-tests.el
test/automated/eshell.el
test/automated/faces-tests.el
test/automated/file-notify-tests.el
test/automated/auth-source-tests.el
test/automated/gnus-tests.el
test/automated/message-mode-tests.el
test/automated/help-fns.el
test/automated/imenu-test.el
test/automated/info-xref.el
test/automated/mule-util.el
test/automated/isearch-tests.el
test/automated/json-tests.el
test/automated/bytecomp-tests.el
test/automated/coding-tests.el
test/automated/core-elisp-tests.el
test/automated/decoder-tests.el
test/automated/files.el
test/automated/font-parse-tests.el
test/automated/lexbind-tests.el
test/automated/occur-tests.el
test/automated/process-tests.el
test/automated/syntax-tests.el
test/automated/textprop-tests.el
test/automated/undo-tests.el
test/automated/man-tests.el
test/automated/completion-tests.el
test/automated/dbus-tests.el
test/automated/newsticker-tests.el
test/automated/sasl-scram-rfc-tests.el
test/automated/tramp-tests.el
test/automated/obarray-tests.el
test/automated/compile-tests.el
test/automated/elisp-mode-tests.el
test/automated/f90.el
test/automated/flymake-tests.el
test/automated/python-tests.el
test/automated/ruby-mode-tests.el
test/automated/subword-tests.el
test/automated/replace-tests.el
test/automated/simple-test.el
test/automated/sort-tests.el
test/automated/subr-tests.el
test/automated/reftex-tests.el
test/automated/sgml-mode-tests.el
test/automated/tildify-tests.el
test/automated/thingatpt.el
test/automated/url-future-tests.el
test/automated/url-util-tests.el
test/automated/add-log-tests.el
test/automated/vc-bzr.el
test/automated/vc-tests.el
test/automated/xml-parse-tests.el
test/BidiCharacterTest.txt
test/biditest.el
test/cedet/cedet-utests.el
test/cedet/ede-tests.el
test/cedet/semantic-ia-utest.el
test/cedet/semantic-tests.el
test/cedet/semantic-utest-c.el
test/cedet/semantic-utest.el
test/cedet/srecode-tests.el
test/cedet/tests/test.c
test/cedet/tests/test.el
test/cedet/tests/test.make
test/cedet/tests/testdoublens.cpp
test/cedet/tests/testdoublens.hpp
test/cedet/tests/testfriends.cpp
test/cedet/tests/testjavacomp.java
test/cedet/tests/testnsp.cpp
test/cedet/tests/testpolymorph.cpp
test/cedet/tests/testspp.c
test/cedet/tests/testsppcomplete.c
test/cedet/tests/testsppreplace.c
test/cedet/tests/testsppreplaced.c
test/cedet/tests/testsubclass.cpp
test/cedet/tests/testsubclass.hh
test/cedet/tests/testtypedefs.cpp
test/cedet/tests/testvarnames.c
test/etags/CTAGS.good
test/etags/ETAGS.good_1
test/etags/ETAGS.good_2
test/etags/ETAGS.good_3
test/etags/ETAGS.good_4
test/etags/ETAGS.good_5
test/etags/ETAGS.good_6
test/etags/a-src/empty.zz
test/etags/a-src/empty.zz.gz
test/etags/ada-src/2ataspri.adb
test/etags/ada-src/2ataspri.ads
test/etags/ada-src/etags-test-for.ada
test/etags/ada-src/waroquiers.ada
test/etags/c-src/a/b/b.c
test/etags/c-src/abbrev.c
test/etags/c-src/c.c
test/etags/c-src/dostorture.c
test/etags/c-src/emacs/src/gmalloc.c
test/etags/c-src/emacs/src/keyboard.c
test/etags/c-src/emacs/src/lisp.h
test/etags/c-src/emacs/src/regex.h
test/etags/c-src/etags.c
test/etags/c-src/exit.c
test/etags/c-src/exit.strange_suffix
test/etags/c-src/fail.c
test/etags/c-src/getopt.h
test/etags/c-src/h.h
test/etags/c-src/machsyscalls.c
test/etags/c-src/machsyscalls.h
test/etags/c-src/sysdep.h
test/etags/c-src/tab.c
test/etags/c-src/torture.c
test/etags/cp-src/MDiagArray2.h
test/etags/cp-src/Range.h
test/etags/cp-src/burton.cpp
test/etags/cp-src/c.C
test/etags/cp-src/clheir.cpp.gz
test/etags/cp-src/clheir.hpp
test/etags/cp-src/conway.cpp
test/etags/cp-src/conway.hpp
test/etags/cp-src/fail.C
test/etags/cp-src/functions.cpp
test/etags/cp-src/screen.cpp
test/etags/cp-src/screen.hpp
test/etags/cp-src/x.cc
test/etags/el-src/TAGTEST.EL
test/etags/el-src/emacs/lisp/progmodes/etags.el
test/etags/erl-src/gs_dialog.erl
test/etags/f-src/entry.for
test/etags/f-src/entry.strange.gz
test/etags/f-src/entry.strange_suffix
test/etags/forth-src/test-forth.fth
test/etags/html-src/algrthms.html
test/etags/html-src/index.shtml
test/etags/html-src/software.html
test/etags/html-src/softwarelibero.html
test/etags/lua-src/allegro.lua
test/etags/objc-src/PackInsp.h
test/etags/objc-src/PackInsp.m
test/etags/objc-src/Subprocess.h
test/etags/objc-src/Subprocess.m
test/etags/objcpp-src/SimpleCalc.H
test/etags/objcpp-src/SimpleCalc.M
test/etags/pas-src/common.pas
test/etags/perl-src/htlmify-cystic
test/etags/perl-src/kai-test.pl
test/etags/perl-src/yagrip.pl
test/etags/php-src/lce_functions.php
test/etags/php-src/ptest.php
test/etags/php-src/sendmail.php
test/etags/prol-src/natded.prolog
test/etags/prol-src/ordsets.prolog
test/etags/ps-src/rfc1245.ps
test/etags/pyt-src/server.py
test/etags/tex-src/gzip.texi
test/etags/tex-src/nonewline.tex
test/etags/tex-src/testenv.tex
test/etags/tex-src/texinfo.tex
test/etags/y-src/atest.y
test/etags/y-src/cccp.c
test/etags/y-src/cccp.y
test/etags/y-src/parse.c
test/etags/y-src/parse.y
test/indent/css-mode.css
test/indent/js-indent-init-dynamic.js
test/indent/js-indent-init-t.js
test/indent/js-jsx.js
test/indent/js.js
test/indent/latex-mode.tex
test/indent/modula2.mod
test/indent/nxml.xml
test/indent/octave.m
test/indent/pascal.pas
test/indent/perl.perl
test/indent/prolog.prolog
test/indent/ps-mode.ps
test/indent/ruby.rb
test/indent/scheme.scm
test/indent/scss-mode.scss
test/indent/sgml-mode-attribute.html
test/indent/shell.rc
test/indent/shell.sh
test/redisplay-testsuite.el
test/rmailmm.el
test/automated/buffer-tests.el
test/automated/cmds-tests.el
test/automated/data-tests.el
test/automated/finalizer-tests.el
test/automated/fns-tests.el
test/automated/inotify-test.el
test/automated/keymap-tests.el
test/automated/print-tests.el
test/automated/libxml-tests.el
test/automated/zlib-tests.el: Files Moved.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/buffer-tests.el | 48 | ||||
| -rw-r--r-- | test/src/cmds-tests.el | 34 | ||||
| -rw-r--r-- | test/src/data-tests.el | 257 | ||||
| -rw-r--r-- | test/src/finalizer-tests.el | 33 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 193 | ||||
| -rw-r--r-- | test/src/inotify-tests.el | 64 | ||||
| -rw-r--r-- | test/src/keymap-tests.el | 43 | ||||
| -rw-r--r-- | test/src/print-tests.el | 62 | ||||
| -rw-r--r-- | test/src/xml-tests.el | 74 | ||||
| -rw-r--r-- | test/src/zlib-tests.el | 45 |
10 files changed, 853 insertions, 0 deletions
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el new file mode 100644 index 00000000000..bb3c92dd6de --- /dev/null +++ b/test/src/buffer-tests.el | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | ;;; buffer-tests.el --- tests for buffer.c functions -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest overlay-modification-hooks-message-other-buf () | ||
| 25 | "Test for bug#21824. | ||
| 26 | After a modification-hook has been run and there is an overlay in | ||
| 27 | the *Messages* buffer, the message coalescing [2 times] wrongly | ||
| 28 | runs the modification-hook of the overlay in the 1st buffer, but | ||
| 29 | with parameters from the *Messages* buffer modification." | ||
| 30 | (let ((buf nil) | ||
| 31 | (msg-ov nil)) | ||
| 32 | (with-temp-buffer | ||
| 33 | (insert "123") | ||
| 34 | (overlay-put (make-overlay 1 3) | ||
| 35 | 'modification-hooks | ||
| 36 | (list (lambda (&rest _) | ||
| 37 | (setq buf (current-buffer))))) | ||
| 38 | (goto-char 2) | ||
| 39 | (insert "x") | ||
| 40 | (unwind-protect | ||
| 41 | (progn | ||
| 42 | (setq msg-ov (make-overlay 1 1 (get-buffer-create "*Messages*"))) | ||
| 43 | (message "a message") | ||
| 44 | (message "a message") | ||
| 45 | (should (eq buf (current-buffer)))) | ||
| 46 | (when msg-ov (delete-overlay msg-ov)))))) | ||
| 47 | |||
| 48 | ;;; buffer-tests.el ends here | ||
diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el new file mode 100644 index 00000000000..7e742a1fa8b --- /dev/null +++ b/test/src/cmds-tests.el | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | ;;; cmds-tests.el --- Testing some Emacs commands | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Nicolas Richard <youngfrog@members.fsf.org> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This program is free software; you can redistribute it and/or modify | ||
| 9 | ;; it under the terms of the GNU General Public License as published by | ||
| 10 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 11 | ;; (at your option) any later version. | ||
| 12 | |||
| 13 | ;; This program is distributed in the hope that it will be useful, | ||
| 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | ;; GNU General Public License for more details. | ||
| 17 | |||
| 18 | ;; You should have received a copy of the GNU General Public License | ||
| 19 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | ;;; Commentary: | ||
| 22 | |||
| 23 | ;; | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | |||
| 28 | (ert-deftest self-insert-command-with-negative-argument () | ||
| 29 | "Test `self-insert-command' with a negative argument." | ||
| 30 | (let ((last-command-event ?a)) | ||
| 31 | (should-error (self-insert-command -1)))) | ||
| 32 | |||
| 33 | (provide 'cmds-tests) | ||
| 34 | ;;; cmds-tests.el ends here | ||
diff --git a/test/src/data-tests.el b/test/src/data-tests.el new file mode 100644 index 00000000000..252a1410206 --- /dev/null +++ b/test/src/data-tests.el | |||
| @@ -0,0 +1,257 @@ | |||
| 1 | ;;; data-tests.el --- tests for src/data.c | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; This program is free software: you can redistribute it and/or | ||
| 8 | ;; modify it under the terms of the GNU General Public License as | ||
| 9 | ;; published by the Free Software Foundation, either version 3 of the | ||
| 10 | ;; License, or (at your option) any later version. | ||
| 11 | ;; | ||
| 12 | ;; This program is distributed in the hope that it will be useful, but | ||
| 13 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | ;; General Public License for more details. | ||
| 16 | ;; | ||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see `http://www.gnu.org/licenses/'. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'cl-lib) | ||
| 25 | (eval-when-compile (require 'cl)) | ||
| 26 | |||
| 27 | (ert-deftest data-tests-= () | ||
| 28 | (should-error (=)) | ||
| 29 | (should (= 1)) | ||
| 30 | (should (= 2 2)) | ||
| 31 | (should (= 9 9 9 9 9 9 9 9 9)) | ||
| 32 | (should-not (apply #'= '(3 8 3))) | ||
| 33 | (should-error (= 9 9 'foo)) | ||
| 34 | ;; Short circuits before getting to bad arg | ||
| 35 | (should-not (= 9 8 'foo))) | ||
| 36 | |||
| 37 | (ert-deftest data-tests-< () | ||
| 38 | (should-error (<)) | ||
| 39 | (should (< 1)) | ||
| 40 | (should (< 2 3)) | ||
| 41 | (should (< -6 -1 0 2 3 4 8 9 999)) | ||
| 42 | (should-not (apply #'< '(3 8 3))) | ||
| 43 | (should-error (< 9 10 'foo)) | ||
| 44 | ;; Short circuits before getting to bad arg | ||
| 45 | (should-not (< 9 8 'foo))) | ||
| 46 | |||
| 47 | (ert-deftest data-tests-> () | ||
| 48 | (should-error (>)) | ||
| 49 | (should (> 1)) | ||
| 50 | (should (> 3 2)) | ||
| 51 | (should (> 6 1 0 -2 -3 -4 -8 -9 -999)) | ||
| 52 | (should-not (apply #'> '(3 8 3))) | ||
| 53 | (should-error (> 9 8 'foo)) | ||
| 54 | ;; Short circuits before getting to bad arg | ||
| 55 | (should-not (> 8 9 'foo))) | ||
| 56 | |||
| 57 | (ert-deftest data-tests-<= () | ||
| 58 | (should-error (<=)) | ||
| 59 | (should (<= 1)) | ||
| 60 | (should (<= 2 3)) | ||
| 61 | (should (<= -6 -1 -1 0 0 0 2 3 4 8 999)) | ||
| 62 | (should-not (apply #'<= '(3 8 3 3))) | ||
| 63 | (should-error (<= 9 10 'foo)) | ||
| 64 | ;; Short circuits before getting to bad arg | ||
| 65 | (should-not (<= 9 8 'foo))) | ||
| 66 | |||
| 67 | (ert-deftest data-tests->= () | ||
| 68 | (should-error (>=)) | ||
| 69 | (should (>= 1)) | ||
| 70 | (should (>= 3 2)) | ||
| 71 | (should (>= 666 1 0 0 -2 -3 -3 -3 -4 -8 -8 -9 -999)) | ||
| 72 | (should-not (apply #'>= '(3 8 3))) | ||
| 73 | (should-error (>= 9 8 'foo)) | ||
| 74 | ;; Short circuits before getting to bad arg | ||
| 75 | (should-not (>= 8 9 'foo))) | ||
| 76 | |||
| 77 | ;; Bool vector tests. Compactly represent bool vectors as hex | ||
| 78 | ;; strings. | ||
| 79 | |||
| 80 | (ert-deftest bool-vector-count-population-all-0-nil () | ||
| 81 | (cl-loop for sz in '(0 45 1 64 9 344) | ||
| 82 | do (let* ((bv (make-bool-vector sz nil))) | ||
| 83 | (should | ||
| 84 | (zerop | ||
| 85 | (bool-vector-count-population bv)))))) | ||
| 86 | |||
| 87 | (ert-deftest bool-vector-count-population-all-1-t () | ||
| 88 | (cl-loop for sz in '(0 45 1 64 9 344) | ||
| 89 | do (let* ((bv (make-bool-vector sz t))) | ||
| 90 | (should | ||
| 91 | (eql | ||
| 92 | (bool-vector-count-population bv) | ||
| 93 | sz))))) | ||
| 94 | |||
| 95 | (ert-deftest bool-vector-count-population-1-nil () | ||
| 96 | (let* ((bv (make-bool-vector 45 nil))) | ||
| 97 | (aset bv 40 t) | ||
| 98 | (aset bv 0 t) | ||
| 99 | (should | ||
| 100 | (eql | ||
| 101 | (bool-vector-count-population bv) | ||
| 102 | 2)))) | ||
| 103 | |||
| 104 | (ert-deftest bool-vector-count-population-1-t () | ||
| 105 | (let* ((bv (make-bool-vector 45 t))) | ||
| 106 | (aset bv 40 nil) | ||
| 107 | (aset bv 0 nil) | ||
| 108 | (should | ||
| 109 | (eql | ||
| 110 | (bool-vector-count-population bv) | ||
| 111 | 43)))) | ||
| 112 | |||
| 113 | (defun mock-bool-vector-count-consecutive (a b i) | ||
| 114 | (loop for i from i below (length a) | ||
| 115 | while (eq (aref a i) b) | ||
| 116 | sum 1)) | ||
| 117 | |||
| 118 | (defun test-bool-vector-bv-from-hex-string (desc) | ||
| 119 | (let (bv nchars nibbles) | ||
| 120 | (dolist (c (string-to-list desc)) | ||
| 121 | (push (string-to-number | ||
| 122 | (char-to-string c) | ||
| 123 | 16) | ||
| 124 | nibbles)) | ||
| 125 | (setf bv (make-bool-vector (* 4 (length nibbles)) nil)) | ||
| 126 | (let ((i 0)) | ||
| 127 | (dolist (n (nreverse nibbles)) | ||
| 128 | (dotimes (_ 4) | ||
| 129 | (aset bv i (> (logand 1 n) 0)) | ||
| 130 | (incf i) | ||
| 131 | (setf n (lsh n -1))))) | ||
| 132 | bv)) | ||
| 133 | |||
| 134 | (defun test-bool-vector-to-hex-string (bv) | ||
| 135 | (let (nibbles (v (cl-coerce bv 'list))) | ||
| 136 | (while v | ||
| 137 | (push (logior | ||
| 138 | (lsh (if (nth 0 v) 1 0) 0) | ||
| 139 | (lsh (if (nth 1 v) 1 0) 1) | ||
| 140 | (lsh (if (nth 2 v) 1 0) 2) | ||
| 141 | (lsh (if (nth 3 v) 1 0) 3)) | ||
| 142 | nibbles) | ||
| 143 | (setf v (nthcdr 4 v))) | ||
| 144 | (mapconcat (lambda (n) (format "%X" n)) | ||
| 145 | (nreverse nibbles) | ||
| 146 | ""))) | ||
| 147 | |||
| 148 | (defun test-bool-vector-count-consecutive-tc (desc) | ||
| 149 | "Run a test case for bool-vector-count-consecutive. | ||
| 150 | DESC is a string describing the test. It is a sequence of | ||
| 151 | hexadecimal digits describing the bool vector. We exhaustively | ||
| 152 | test all counts at all possible positions in the vector by | ||
| 153 | comparing the subr with a much slower lisp implementation." | ||
| 154 | (let ((bv (test-bool-vector-bv-from-hex-string desc))) | ||
| 155 | (loop | ||
| 156 | for lf in '(nil t) | ||
| 157 | do (loop | ||
| 158 | for pos from 0 upto (length bv) | ||
| 159 | for cnt = (mock-bool-vector-count-consecutive bv lf pos) | ||
| 160 | for rcnt = (bool-vector-count-consecutive bv lf pos) | ||
| 161 | unless (eql cnt rcnt) | ||
| 162 | do (error "FAILED testcase %S %3S %3S %3S" | ||
| 163 | pos lf cnt rcnt))))) | ||
| 164 | |||
| 165 | (defconst bool-vector-test-vectors | ||
| 166 | '("" | ||
| 167 | "0" | ||
| 168 | "F" | ||
| 169 | "0F" | ||
| 170 | "F0" | ||
| 171 | "00000000000000000000000000000FFFFF0000000" | ||
| 172 | "44a50234053fba3340000023444a50234053fba33400000234" | ||
| 173 | "12341234123456123412346001234123412345612341234600" | ||
| 174 | "44a50234053fba33400000234" | ||
| 175 | "1234123412345612341234600" | ||
| 176 | "44a50234053fba33400000234" | ||
| 177 | "1234123412345612341234600" | ||
| 178 | "44a502340" | ||
| 179 | "123412341" | ||
| 180 | "0000000000000000000000000" | ||
| 181 | "FFFFFFFFFFFFFFFF1")) | ||
| 182 | |||
| 183 | (ert-deftest bool-vector-count-consecutive () | ||
| 184 | (mapc #'test-bool-vector-count-consecutive-tc | ||
| 185 | bool-vector-test-vectors)) | ||
| 186 | |||
| 187 | (defun test-bool-vector-apply-mock-op (mock a b c) | ||
| 188 | "Compute (slowly) the correct result of a bool-vector set operation." | ||
| 189 | (let (changed nv) | ||
| 190 | (assert (eql (length b) (length c))) | ||
| 191 | (if a (setf nv a) | ||
| 192 | (setf a (make-bool-vector (length b) nil)) | ||
| 193 | (setf changed t)) | ||
| 194 | |||
| 195 | (loop for i below (length b) | ||
| 196 | for mockr = (funcall mock | ||
| 197 | (if (aref b i) 1 0) | ||
| 198 | (if (aref c i) 1 0)) | ||
| 199 | for r = (not (= 0 mockr)) | ||
| 200 | do (progn | ||
| 201 | (unless (eq (aref a i) r) | ||
| 202 | (setf changed t)) | ||
| 203 | (setf (aref a i) r))) | ||
| 204 | (if changed a))) | ||
| 205 | |||
| 206 | (defun test-bool-vector-binop (mock real) | ||
| 207 | "Test a binary set operation." | ||
| 208 | (loop for s1 in bool-vector-test-vectors | ||
| 209 | for bv1 = (test-bool-vector-bv-from-hex-string s1) | ||
| 210 | for vecs2 = (cl-remove-if-not | ||
| 211 | (lambda (x) (eql (length x) (length s1))) | ||
| 212 | bool-vector-test-vectors) | ||
| 213 | do (loop for s2 in vecs2 | ||
| 214 | for bv2 = (test-bool-vector-bv-from-hex-string s2) | ||
| 215 | for mock-result = (test-bool-vector-apply-mock-op | ||
| 216 | mock nil bv1 bv2) | ||
| 217 | for real-result = (funcall real bv1 bv2) | ||
| 218 | do (progn | ||
| 219 | (should (equal mock-result real-result)))))) | ||
| 220 | |||
| 221 | (ert-deftest bool-vector-intersection-op () | ||
| 222 | (test-bool-vector-binop | ||
| 223 | #'logand | ||
| 224 | #'bool-vector-intersection)) | ||
| 225 | |||
| 226 | (ert-deftest bool-vector-union-op () | ||
| 227 | (test-bool-vector-binop | ||
| 228 | #'logior | ||
| 229 | #'bool-vector-union)) | ||
| 230 | |||
| 231 | (ert-deftest bool-vector-xor-op () | ||
| 232 | (test-bool-vector-binop | ||
| 233 | #'logxor | ||
| 234 | #'bool-vector-exclusive-or)) | ||
| 235 | |||
| 236 | (ert-deftest bool-vector-set-difference-op () | ||
| 237 | (test-bool-vector-binop | ||
| 238 | (lambda (a b) (logand a (lognot b))) | ||
| 239 | #'bool-vector-set-difference)) | ||
| 240 | |||
| 241 | (ert-deftest bool-vector-change-detection () | ||
| 242 | (let* ((vc1 (test-bool-vector-bv-from-hex-string "abcdef")) | ||
| 243 | (vc2 (test-bool-vector-bv-from-hex-string "012345")) | ||
| 244 | (vc3 (make-bool-vector (length vc1) nil)) | ||
| 245 | (c1 (bool-vector-union vc1 vc2 vc3)) | ||
| 246 | (c2 (bool-vector-union vc1 vc2 vc3))) | ||
| 247 | (should (equal c1 (test-bool-vector-apply-mock-op | ||
| 248 | #'logior | ||
| 249 | nil | ||
| 250 | vc1 vc2))) | ||
| 251 | (should (not c2)))) | ||
| 252 | |||
| 253 | (ert-deftest bool-vector-not () | ||
| 254 | (let* ((v1 (test-bool-vector-bv-from-hex-string "FFFF3")) | ||
| 255 | (v2 (test-bool-vector-bv-from-hex-string "0000C")) | ||
| 256 | (v3 (bool-vector-not v1))) | ||
| 257 | (should (equal v2 v3)))) | ||
diff --git a/test/src/finalizer-tests.el b/test/src/finalizer-tests.el new file mode 100644 index 00000000000..218df05e426 --- /dev/null +++ b/test/src/finalizer-tests.el | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | ;;; finalizer-tests.el --- Finalizer tests -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Daniel Colascione <dancol@dancol.org> | ||
| 6 | ;; Keywords: | ||
| 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 'cl-lib) | ||
| 31 | |||
| 32 | (ert-deftest finalizer-object-type () | ||
| 33 | (should (equal (type-of (make-finalizer nil)) 'finalizer))) | ||
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el new file mode 100644 index 00000000000..b5222db3ca1 --- /dev/null +++ b/test/src/fns-tests.el | |||
| @@ -0,0 +1,193 @@ | |||
| 1 | ;;; fns-tests.el --- tests for src/fns.c | ||
| 2 | |||
| 3 | ;; Copyright (C) 2014-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; This program is free software: you can redistribute it and/or | ||
| 8 | ;; modify it under the terms of the GNU General Public License as | ||
| 9 | ;; published by the Free Software Foundation, either version 3 of the | ||
| 10 | ;; License, or (at your option) any later version. | ||
| 11 | ;; | ||
| 12 | ;; This program is distributed in the hope that it will be useful, but | ||
| 13 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | ;; General Public License for more details. | ||
| 16 | ;; | ||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see `http://www.gnu.org/licenses/'. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'cl-lib) | ||
| 25 | (eval-when-compile (require 'cl)) | ||
| 26 | |||
| 27 | (ert-deftest fns-tests-reverse () | ||
| 28 | (should-error (reverse)) | ||
| 29 | (should-error (reverse 1)) | ||
| 30 | (should-error (reverse (make-char-table 'foo))) | ||
| 31 | (should (equal [] (reverse []))) | ||
| 32 | (should (equal [0] (reverse [0]))) | ||
| 33 | (should (equal [1 2 3 4] (reverse (reverse [1 2 3 4])))) | ||
| 34 | (should (equal '(a b c d) (reverse (reverse '(a b c d))))) | ||
| 35 | (should (equal "xyzzy" (reverse (reverse "xyzzy")))) | ||
| 36 | (should (equal "こんにちは / コンニチハ" (reverse (reverse "こんにちは / コンニチハ"))))) | ||
| 37 | |||
| 38 | (ert-deftest fns-tests-nreverse () | ||
| 39 | (should-error (nreverse)) | ||
| 40 | (should-error (nreverse 1)) | ||
| 41 | (should-error (nreverse (make-char-table 'foo))) | ||
| 42 | (should (equal (nreverse "xyzzy") "yzzyx")) | ||
| 43 | (let ((A [])) | ||
| 44 | (nreverse A) | ||
| 45 | (should (equal A []))) | ||
| 46 | (let ((A [0])) | ||
| 47 | (nreverse A) | ||
| 48 | (should (equal A [0]))) | ||
| 49 | (let ((A [1 2 3 4])) | ||
| 50 | (nreverse A) | ||
| 51 | (should (equal A [4 3 2 1]))) | ||
| 52 | (let ((A [1 2 3 4])) | ||
| 53 | (nreverse A) | ||
| 54 | (nreverse A) | ||
| 55 | (should (equal A [1 2 3 4]))) | ||
| 56 | (let* ((A [1 2 3 4]) | ||
| 57 | (B (nreverse (nreverse A)))) | ||
| 58 | (should (equal A B)))) | ||
| 59 | |||
| 60 | (ert-deftest fns-tests-reverse-bool-vector () | ||
| 61 | (let ((A (make-bool-vector 10 nil))) | ||
| 62 | (dotimes (i 5) (aset A i t)) | ||
| 63 | (should (equal [nil nil nil nil nil t t t t t] (vconcat (reverse A)))) | ||
| 64 | (should (equal A (reverse (reverse A)))))) | ||
| 65 | |||
| 66 | (ert-deftest fns-tests-nreverse-bool-vector () | ||
| 67 | (let ((A (make-bool-vector 10 nil))) | ||
| 68 | (dotimes (i 5) (aset A i t)) | ||
| 69 | (nreverse A) | ||
| 70 | (should (equal [nil nil nil nil nil t t t t t] (vconcat A))) | ||
| 71 | (should (equal [t t t t t nil nil nil nil nil] (vconcat (nreverse A)))))) | ||
| 72 | |||
| 73 | (ert-deftest fns-tests-compare-strings () | ||
| 74 | (should-error (compare-strings)) | ||
| 75 | (should-error (compare-strings "xyzzy" "xyzzy")) | ||
| 76 | (should (= (compare-strings "xyzzy" 0 10 "zyxxy" 0 5) -1)) | ||
| 77 | (should-error (compare-strings "xyzzy" 0 5 "zyxxy" -1 2)) | ||
| 78 | (should-error (compare-strings "xyzzy" 'foo nil "zyxxy" 0 1)) | ||
| 79 | (should-error (compare-strings "xyzzy" 0 'foo "zyxxy" 2 3)) | ||
| 80 | (should-error (compare-strings "xyzzy" 0 2 "zyxxy" 'foo 3)) | ||
| 81 | (should-error (compare-strings "xyzzy" nil 3 "zyxxy" 4 'foo)) | ||
| 82 | (should (eq (compare-strings "" nil nil "" nil nil) t)) | ||
| 83 | (should (eq (compare-strings "" 0 0 "" 0 0) t)) | ||
| 84 | (should (eq (compare-strings "test" nil nil "test" nil nil) t)) | ||
| 85 | (should (eq (compare-strings "test" nil nil "test" nil nil t) t)) | ||
| 86 | (should (eq (compare-strings "test" nil nil "test" nil nil nil) t)) | ||
| 87 | (should (eq (compare-strings "Test" nil nil "test" nil nil t) t)) | ||
| 88 | (should (= (compare-strings "Test" nil nil "test" nil nil) -1)) | ||
| 89 | (should (= (compare-strings "Test" nil nil "test" nil nil) -1)) | ||
| 90 | (should (= (compare-strings "test" nil nil "Test" nil nil) 1)) | ||
| 91 | (should (= (compare-strings "foobaz" nil nil "barbaz" nil nil) 1)) | ||
| 92 | (should (= (compare-strings "barbaz" nil nil "foobar" nil nil) -1)) | ||
| 93 | (should (= (compare-strings "foobaz" nil nil "farbaz" nil nil) 2)) | ||
| 94 | (should (= (compare-strings "farbaz" nil nil "foobar" nil nil) -2)) | ||
| 95 | (should (eq (compare-strings "abcxyz" 0 2 "abcprq" 0 2) t)) | ||
| 96 | (should (eq (compare-strings "abcxyz" 0 -3 "abcprq" 0 -3) t)) | ||
| 97 | (should (= (compare-strings "abcxyz" 0 6 "abcprq" 0 6) 4)) | ||
| 98 | (should (= (compare-strings "abcprq" 0 6 "abcxyz" 0 6) -4)) | ||
| 99 | (should (eq (compare-strings "xyzzy" -3 4 "azza" -3 3) t)) | ||
| 100 | (should (eq (compare-strings "こんにちはコンニチハ" nil nil "こんにちはコンニチハ" nil nil) t)) | ||
| 101 | (should (= (compare-strings "んにちはコンニチハこ" nil nil "こんにちはコンニチハ" nil nil) 1)) | ||
| 102 | (should (= (compare-strings "こんにちはコンニチハ" nil nil "んにちはコンニチハこ" nil nil) -1))) | ||
| 103 | |||
| 104 | (defun fns-tests--collate-enabled-p () | ||
| 105 | "Check whether collation functions are enabled." | ||
| 106 | (and | ||
| 107 | ;; When there is no collation library, collation functions fall back | ||
| 108 | ;; to their lexicographic counterparts. We don't need to test then. | ||
| 109 | (not (ignore-errors (string-collate-equalp "" "" t))) | ||
| 110 | ;; We use a locale, which might not be installed. Check it. | ||
| 111 | (ignore-errors | ||
| 112 | (string-collate-equalp | ||
| 113 | "" "" (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) | ||
| 114 | |||
| 115 | (ert-deftest fns-tests-collate-strings () | ||
| 116 | (skip-unless (fns-tests--collate-enabled-p)) | ||
| 117 | |||
| 118 | (should (string-collate-equalp "xyzzy" "xyzzy")) | ||
| 119 | (should-not (string-collate-equalp "xyzzy" "XYZZY")) | ||
| 120 | |||
| 121 | ;; In POSIX or C locales, collation order is lexicographic. | ||
| 122 | (should (string-collate-lessp "XYZZY" "xyzzy" "POSIX")) | ||
| 123 | ;; In a language specific locale, collation order is different. | ||
| 124 | (should (string-collate-lessp | ||
| 125 | "xyzzy" "XYZZY" | ||
| 126 | (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))) | ||
| 127 | |||
| 128 | ;; Ignore case. | ||
| 129 | (should (string-collate-equalp "xyzzy" "XYZZY" nil t)) | ||
| 130 | |||
| 131 | ;; Locale must be valid. | ||
| 132 | (should-error (string-collate-equalp "xyzzy" "xyzzy" "en_DE.UTF-8"))) | ||
| 133 | |||
| 134 | ;; There must be a check for valid codepoints. (Check not implemented yet) | ||
| 135 | ; (should-error | ||
| 136 | ; (string-collate-equalp (string ?\x00110000) (string ?\x00110000))) | ||
| 137 | ;; Invalid UTF-8 sequences shall be indicated. How to create such strings? | ||
| 138 | |||
| 139 | (ert-deftest fns-tests-sort () | ||
| 140 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (< x y))) | ||
| 141 | '(-1 2 3 4 5 5 7 8 9))) | ||
| 142 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (> x y))) | ||
| 143 | '(9 8 7 5 5 4 3 2 -1))) | ||
| 144 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (< x y))) | ||
| 145 | [-1 2 3 4 5 5 7 8 9])) | ||
| 146 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (> x y))) | ||
| 147 | [9 8 7 5 5 4 3 2 -1])) | ||
| 148 | (should (equal | ||
| 149 | (sort | ||
| 150 | (vector | ||
| 151 | '(8 . "xxx") '(9 . "aaa") '(8 . "bbb") '(9 . "zzz") | ||
| 152 | '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff")) | ||
| 153 | (lambda (x y) (< (car x) (car y)))) | ||
| 154 | [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") | ||
| 155 | (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))) | ||
| 156 | |||
| 157 | (ert-deftest fns-tests-collate-sort () | ||
| 158 | ;; See https://lists.gnu.org/archive/html/emacs-devel/2015-10/msg02505.html. | ||
| 159 | :expected-result (if (eq system-type 'cygwin) :failed :passed) | ||
| 160 | (skip-unless (fns-tests--collate-enabled-p)) | ||
| 161 | |||
| 162 | ;; Punctuation and whitespace characters are relevant for POSIX. | ||
| 163 | (should | ||
| 164 | (equal | ||
| 165 | (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") | ||
| 166 | (lambda (a b) (string-collate-lessp a b "POSIX"))) | ||
| 167 | '("1 1" "1 2" "1.1" "1.2" "11" "12"))) | ||
| 168 | ;; Punctuation and whitespace characters are not taken into account | ||
| 169 | ;; for collation in other locales. | ||
| 170 | (should | ||
| 171 | (equal | ||
| 172 | (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") | ||
| 173 | (lambda (a b) | ||
| 174 | (let ((w32-collate-ignore-punctuation t)) | ||
| 175 | (string-collate-lessp | ||
| 176 | a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) | ||
| 177 | '("11" "1 1" "1.1" "12" "1 2" "1.2"))) | ||
| 178 | |||
| 179 | ;; Diacritics are different letters for POSIX, they sort lexicographical. | ||
| 180 | (should | ||
| 181 | (equal | ||
| 182 | (sort '("Ævar" "Agustín" "Adrian" "Eli") | ||
| 183 | (lambda (a b) (string-collate-lessp a b "POSIX"))) | ||
| 184 | '("Adrian" "Agustín" "Eli" "Ævar"))) | ||
| 185 | ;; Diacritics are sorted between similar letters for other locales. | ||
| 186 | (should | ||
| 187 | (equal | ||
| 188 | (sort '("Ævar" "Agustín" "Adrian" "Eli") | ||
| 189 | (lambda (a b) | ||
| 190 | (let ((w32-collate-ignore-punctuation t)) | ||
| 191 | (string-collate-lessp | ||
| 192 | a b (if (eq system-type 'windows-nt) "enu_USA" "en_US.UTF-8"))))) | ||
| 193 | '("Adrian" "Ævar" "Agustín" "Eli")))) | ||
diff --git a/test/src/inotify-tests.el b/test/src/inotify-tests.el new file mode 100644 index 00000000000..187b59054cd --- /dev/null +++ b/test/src/inotify-tests.el | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | ;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Rüdiger Sonderfeld <ruediger@c-plusplus.de> | ||
| 6 | ;; Keywords: internal | ||
| 7 | ;; Human-Keywords: internal | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Code: | ||
| 25 | |||
| 26 | (require 'ert) | ||
| 27 | |||
| 28 | (declare-function inotify-add-watch "inotify.c" (file-name aspect callback)) | ||
| 29 | (declare-function inotify-rm-watch "inotify.c" (watch-descriptor)) | ||
| 30 | |||
| 31 | ;; (ert-deftest filewatch-file-watch-aspects-check () | ||
| 32 | ;; "Test whether `file-watch' properly checks the aspects." | ||
| 33 | ;; (let ((temp-file (make-temp-file "filewatch-aspects"))) | ||
| 34 | ;; (should (stringp temp-file)) | ||
| 35 | ;; (should-error (file-watch temp-file 'wrong nil) | ||
| 36 | ;; :type 'error) | ||
| 37 | ;; (should-error (file-watch temp-file '(modify t) nil) | ||
| 38 | ;; :type 'error) | ||
| 39 | ;; (should-error (file-watch temp-file '(modify all-modify) nil) | ||
| 40 | ;; :type 'error) | ||
| 41 | ;; (should-error (file-watch temp-file '(access wrong modify) nil) | ||
| 42 | ;; :type 'error))) | ||
| 43 | |||
| 44 | (ert-deftest inotify-file-watch-simple () | ||
| 45 | "Test if watching a normal file works." | ||
| 46 | |||
| 47 | (skip-unless (featurep 'inotify)) | ||
| 48 | (let ((temp-file (make-temp-file "inotify-simple")) | ||
| 49 | (events 0)) | ||
| 50 | (let ((wd | ||
| 51 | (inotify-add-watch temp-file t (lambda (_ev) | ||
| 52 | (setq events (1+ events)))))) | ||
| 53 | (unwind-protect | ||
| 54 | (progn | ||
| 55 | (with-temp-file temp-file | ||
| 56 | (insert "Foo\n")) | ||
| 57 | (read-event nil nil 5) | ||
| 58 | (should (> events 0))) | ||
| 59 | (inotify-rm-watch wd) | ||
| 60 | (delete-file temp-file))))) | ||
| 61 | |||
| 62 | (provide 'inotify-tests) | ||
| 63 | |||
| 64 | ;;; inotify-tests.el ends here. | ||
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el new file mode 100644 index 00000000000..973b2407391 --- /dev/null +++ b/test/src/keymap-tests.el | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | ;;; keymap-tests.el --- Test suite for src/keymap.c | ||
| 2 | |||
| 3 | ;; Copyright (C) 2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Juanma Barranquero <lekktu@gmail.com> | ||
| 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 | (ert-deftest keymap-store_in_keymap-FASTINT-on-nonchars () | ||
| 27 | "Check for bug fixed in \"Fix assertion violation in define-key\", | ||
| 28 | commit 86c19714b097aa477d339ed99ffb5136c755a046." | ||
| 29 | (let ((def (lookup-key Buffer-menu-mode-map [32]))) | ||
| 30 | (unwind-protect | ||
| 31 | (progn | ||
| 32 | (should-not (eq def 'undefined)) | ||
| 33 | ;; This will cause an assertion violation if the bug is present. | ||
| 34 | ;; We could run an inferior Emacs process and check for the return | ||
| 35 | ;; status, but in some environments an assertion failure triggers | ||
| 36 | ;; an abort dialog that requires user intervention anyway. | ||
| 37 | (define-key Buffer-menu-mode-map [(32 . 32)] 'undefined) | ||
| 38 | (should (eq (lookup-key Buffer-menu-mode-map [32]) 'undefined))) | ||
| 39 | (define-key Buffer-menu-mode-map [32] def)))) | ||
| 40 | |||
| 41 | (provide 'keymap-tests) | ||
| 42 | |||
| 43 | ;;; keymap-tests.el ends here | ||
diff --git a/test/src/print-tests.el b/test/src/print-tests.el new file mode 100644 index 00000000000..fe8c56553a8 --- /dev/null +++ b/test/src/print-tests.el | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | ;;; print-tests.el --- tests for src/print.c -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2014-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; This program is free software; you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; This program is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest print-hex-backslash () | ||
| 25 | (should (string= (let ((print-escape-multibyte t) | ||
| 26 | (print-escape-newlines t)) | ||
| 27 | (prin1-to-string "\u00A2\ff")) | ||
| 28 | "\"\\x00a2\\ff\""))) | ||
| 29 | |||
| 30 | (ert-deftest terpri () | ||
| 31 | (should (string= (with-output-to-string | ||
| 32 | (princ 'abc) | ||
| 33 | (should (terpri nil t))) | ||
| 34 | "abc\n")) | ||
| 35 | (should (string= (with-output-to-string | ||
| 36 | (should-not (terpri nil t)) | ||
| 37 | (princ 'xyz)) | ||
| 38 | "xyz")) | ||
| 39 | (message nil) | ||
| 40 | (if noninteractive | ||
| 41 | (progn (should (terpri nil t)) | ||
| 42 | (should-not (terpri nil t)) | ||
| 43 | (princ 'abc) | ||
| 44 | (should (terpri nil t)) | ||
| 45 | (should-not (terpri nil t))) | ||
| 46 | (should (string= (progn (should-not (terpri nil t)) | ||
| 47 | (princ 'abc) | ||
| 48 | (should (terpri nil t)) | ||
| 49 | (current-message)) | ||
| 50 | "abc\n"))) | ||
| 51 | (let ((standard-output | ||
| 52 | (with-current-buffer (get-buffer-create "*terpri-test*") | ||
| 53 | (insert "--------") | ||
| 54 | (point-max-marker)))) | ||
| 55 | (should (terpri nil t)) | ||
| 56 | (should-not (terpri nil t)) | ||
| 57 | (should (string= (with-current-buffer (marker-buffer standard-output) | ||
| 58 | (buffer-string)) | ||
| 59 | "--------\n")))) | ||
| 60 | |||
| 61 | (provide 'print-tests) | ||
| 62 | ;;; print-tests.el ends here | ||
diff --git a/test/src/xml-tests.el b/test/src/xml-tests.el new file mode 100644 index 00000000000..aa97b30f73c --- /dev/null +++ b/test/src/xml-tests.el | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | ;;; libxml-parse-tests.el --- Test suite for libxml parsing. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2014-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Ulf Jasper <ulf.jasper@web.de> | ||
| 6 | ;; Keywords: internal | ||
| 7 | ;; Human-Keywords: internal | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 14 | ;; (at your option) any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | |||
| 24 | ;;; Commentary: | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (require 'ert) | ||
| 29 | |||
| 30 | (defvar libxml-tests--data-comments-preserved | ||
| 31 | `(;; simple case | ||
| 32 | ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>" | ||
| 33 | . (foo ((baz . "true")) "bar")) | ||
| 34 | ;; toplevel comments -- first document child must not get lost | ||
| 35 | (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->" | ||
| 36 | "<!--comment-2-->") | ||
| 37 | . (top nil (foo nil "bar") (comment nil "comment-1") | ||
| 38 | (comment nil "comment-2"))) | ||
| 39 | (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">" | ||
| 40 | "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->") | ||
| 41 | . (top nil (comment nil "comment-a") (foo ((a . "b")) (bar nil "blub")) | ||
| 42 | (comment nil "comment-b") (comment nil "comment-c")))) | ||
| 43 | "Alist of XML strings and their expected parse trees for preserved comments.") | ||
| 44 | |||
| 45 | (defvar libxml-tests--data-comments-discarded | ||
| 46 | `(;; simple case | ||
| 47 | ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>" | ||
| 48 | . (foo ((baz . "true")) "bar")) | ||
| 49 | ;; toplevel comments -- first document child must not get lost | ||
| 50 | (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->" | ||
| 51 | "<!--comment-2-->") | ||
| 52 | . (foo nil "bar")) | ||
| 53 | (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">" | ||
| 54 | "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->") | ||
| 55 | . (foo ((a . "b")) (bar nil "blub")))) | ||
| 56 | "Alist of XML strings and their expected parse trees for discarded comments.") | ||
| 57 | |||
| 58 | |||
| 59 | (ert-deftest libxml-tests () | ||
| 60 | "Test libxml." | ||
| 61 | (when (fboundp 'libxml-parse-xml-region) | ||
| 62 | (with-temp-buffer | ||
| 63 | (dolist (test libxml-tests--data-comments-preserved) | ||
| 64 | (erase-buffer) | ||
| 65 | (insert (car test)) | ||
| 66 | (should (equal (cdr test) | ||
| 67 | (libxml-parse-xml-region (point-min) (point-max))))) | ||
| 68 | (dolist (test libxml-tests--data-comments-discarded) | ||
| 69 | (erase-buffer) | ||
| 70 | (insert (car test)) | ||
| 71 | (should (equal (cdr test) | ||
| 72 | (libxml-parse-xml-region (point-min) (point-max) nil t))))))) | ||
| 73 | |||
| 74 | ;;; libxml-tests.el ends here | ||
diff --git a/test/src/zlib-tests.el b/test/src/zlib-tests.el new file mode 100644 index 00000000000..c6c084dd69f --- /dev/null +++ b/test/src/zlib-tests.el | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | ;;; zlib-tests.el --- Test suite for zlib. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2013-2015 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Lars Ingebrigtsen <larsi@gnus.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 | (defvar zlib-tests-data-directory | ||
| 27 | (expand-file-name "data/decompress" (getenv "EMACS_TEST_DIRECTORY")) | ||
| 28 | "Directory containing zlib test data.") | ||
| 29 | |||
| 30 | (ert-deftest zlib--decompress () | ||
| 31 | "Test decompressing a gzipped file." | ||
| 32 | (when (and (fboundp 'zlib-available-p) | ||
| 33 | (zlib-available-p)) | ||
| 34 | (should (string= | ||
| 35 | (with-temp-buffer | ||
| 36 | (set-buffer-multibyte nil) | ||
| 37 | (insert-file-contents-literally | ||
| 38 | (expand-file-name "foo.gz" zlib-tests-data-directory)) | ||
| 39 | (zlib-decompress-region (point-min) (point-max)) | ||
| 40 | (buffer-string)) | ||
| 41 | "foo\n")))) | ||
| 42 | |||
| 43 | (provide 'zlib-tests) | ||
| 44 | |||
| 45 | ;;; zlib-tests.el ends here. | ||