diff options
author | Phillip Lord <phillip.lord@russet.org.uk> | 2015-11-23 22:02:42 +0000 |
---|---|---|
committer | Phillip Lord <phillip.lord@russet.org.uk> | 2015-11-24 17:04:22 +0000 |
commit | 22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e (patch) | |
tree | 779ff7e07667194416e01c6a6e8bd7b970244c70 /test/lisp/legacy/undo-tests.el | |
parent | c378d6c33f751d1a0b97958f3cacfe0b07c72f58 (diff) | |
download | emacs-22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e.tar.gz emacs-22bbf7ca22f11cc33d887d0162cf2ec6661c3a3e.tar.bz2 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/lisp/legacy/undo-tests.el')
-rw-r--r-- | test/lisp/legacy/undo-tests.el | 448 |
1 files changed, 448 insertions, 0 deletions
diff --git a/test/lisp/legacy/undo-tests.el b/test/lisp/legacy/undo-tests.el new file mode 100644 index 00000000000..f462b269337 --- /dev/null +++ b/test/lisp/legacy/undo-tests.el @@ -0,0 +1,448 @@ +;;; undo-tests.el --- Tests of primitive-undo + +;; Copyright (C) 2012-2015 Free Software Foundation, Inc. + +;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> + +;; This program 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. +;; +;; This program 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 this program. If not, see `http://www.gnu.org/licenses/'. + +;;; Commentary: + +;; Profiling when the code was translate from C to Lisp on 2012-12-24. + +;;; C + +;; (elp-instrument-function 'primitive-undo) +;; (load-file "undo-test.elc") +;; (benchmark 100 '(let ((undo-test5-error nil)) (undo-test-all))) +;; Elapsed time: 305.218000s (104.841000s in 14804 GCs) +;; M-x elp-results +;; Function Name Call Count Elapsed Time Average Time +;; primitive-undo 2600 3.4889999999 0.0013419230 + +;;; Lisp + +;; (load-file "primundo.elc") +;; (elp-instrument-function 'primitive-undo) +;; (benchmark 100 '(undo-test-all)) +;; Elapsed time: 295.974000s (104.582000s in 14704 GCs) +;; M-x elp-results +;; Function Name Call Count Elapsed Time Average Time +;; primitive-undo 2700 3.6869999999 0.0013655555 + +;;; Code: + +(require 'ert) + +(ert-deftest undo-test0 () + "Test basics of \\[undo]." + (with-temp-buffer + (buffer-enable-undo) + (condition-case err + (undo) + (error + (unless (string= "No further undo information" + (cadr err)) + (error err)))) + (undo-boundary) + (insert "This") + (undo-boundary) + (erase-buffer) + (undo-boundary) + (insert "That") + (undo-boundary) + (forward-word -1) + (undo-boundary) + (insert "With ") + (undo-boundary) + (forward-word -1) + (undo-boundary) + (kill-word 1) + (undo-boundary) + (put-text-property (point-min) (point-max) 'face 'bold) + (undo-boundary) + (remove-text-properties (point-min) (point-max) '(face default)) + (undo-boundary) + (set-buffer-multibyte (not enable-multibyte-characters)) + (undo-boundary) + (undo) + (should + (equal (should-error (undo-more nil)) + '(wrong-type-argument number-or-marker-p nil))) + (undo-more 7) + (should (string-equal "" (buffer-string))))) + +(ert-deftest undo-test1 () + "Test undo of \\[undo] command (redo)." + (with-temp-buffer + (buffer-enable-undo) + (undo-boundary) + (insert "This") + (undo-boundary) + (erase-buffer) + (undo-boundary) + (insert "That") + (undo-boundary) + (forward-word -1) + (undo-boundary) + (insert "With ") + (undo-boundary) + (forward-word -1) + (undo-boundary) + (kill-word 1) + (undo-boundary) + (facemenu-add-face 'bold (point-min) (point-max)) + (undo-boundary) + (set-buffer-multibyte (not enable-multibyte-characters)) + (undo-boundary) + (should + (string-equal (buffer-string) + (progn + (undo) + (undo-more 4) + (undo) + ;(undo-more -4) + (buffer-string)))))) + +(ert-deftest undo-test2 () + "Test basic redoing with \\[undo] command." + (with-temp-buffer + (buffer-enable-undo) + (undo-boundary) + (insert "One") + (undo-boundary) + (insert " Zero") + (undo-boundary) + (push-mark nil t) + (delete-region (save-excursion + (forward-word -1) + (point)) (point)) + (undo-boundary) + (beginning-of-line) + (insert "Zero") + (undo-boundary) + (undo) + (should + (string-equal (buffer-string) + (progn + (undo-more 2) + (undo) + (buffer-string)))))) + +(ert-deftest undo-test4 () + "Test \\[undo] of \\[flush-lines]." + (with-temp-buffer + (buffer-enable-undo) + (dotimes (i 1048576) + (if (zerop (% i 2)) + (insert "Evenses") + (insert "Oddses"))) + (undo-boundary) + (should + ;; Avoid string-equal because ERT will save the `buffer-string' + ;; to the explanation. Using `not' will record nil or non-nil. + (not + (null + (string-equal (buffer-string) + (progn + (flush-lines "oddses" (point-min) (point-max)) + (undo-boundary) + (undo) + (undo) + (buffer-string)))))))) + +(ert-deftest undo-test5 () + "Test basic redoing with \\[undo] command." + (with-temp-buffer + (buffer-enable-undo) + (undo-boundary) + (insert "AYE") + (undo-boundary) + (insert " BEE") + (undo-boundary) + (setq buffer-undo-list (cons '(0.0 bogus) buffer-undo-list)) + (push-mark nil t) + (delete-region (save-excursion + (forward-word -1) + (point)) (point)) + (undo-boundary) + (beginning-of-line) + (insert "CEE") + (undo-boundary) + (undo) + (setq buffer-undo-list (cons "bogus" buffer-undo-list)) + (should + (string-equal + (buffer-string) + (progn + (if (and (boundp 'undo-test5-error) (not undo-test5-error)) + (progn + (should (null (undo-more 2))) + (should (undo))) + ;; Errors are generated by new Lisp version of + ;; `primitive-undo' not by built-in C version. + (should + (equal (should-error (undo-more 2)) + '(error "Unrecognized entry in undo list (0.0 bogus)"))) + (should + (equal (should-error (undo)) + '(error "Unrecognized entry in undo list \"bogus\"")))) + (buffer-string)))))) + +;; http://debbugs.gnu.org/14824 +(ert-deftest undo-test-buffer-modified () + "Test undoing marks buffer unmodified." + (with-temp-buffer + (buffer-enable-undo) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + +(ert-deftest undo-test-file-modified () + "Test undoing marks buffer visiting file unmodified." + (let ((tempfile (make-temp-file "undo-test"))) + (unwind-protect + (progn + (with-current-buffer (find-file-noselect tempfile) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p)))) + (delete-file tempfile)))) + +(ert-deftest undo-test-region-not-most-recent () + "Test undo in region of an edit not the most recent." + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "1111") + (undo-boundary) + (goto-char 2) + (insert "2") + (forward-char 2) + (undo-boundary) + (insert "3") + (undo-boundary) + ;; Highlight around "2", not "3" + (push-mark (+ 3 (point-min)) t t) + (setq mark-active t) + (goto-char (point-min)) + (undo) + (should (string= (buffer-string) + "11131")))) + +(ert-deftest undo-test-region-deletion () + "Test undoing a deletion to demonstrate bug 17235." + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "12345") + (search-backward "4") + (undo-boundary) + (delete-forward-char 1) + (search-backward "1") + (undo-boundary) + (insert "xxxx") + (undo-boundary) + (insert "yy") + (search-forward "35") + (undo-boundary) + ;; Select "35" + (push-mark (point) t t) + (setq mark-active t) + (forward-char -2) + (undo) ; Expect "4" to come back + (should (string= (buffer-string) + "xxxxyy12345")))) + +(ert-deftest undo-test-region-example () + "The same example test case described in comments for +undo-make-selective-list." + ;; buf pos: + ;; 123456789 buffer-undo-list undo-deltas + ;; --------- ---------------- ----------- + ;; aaa (1 . 4) (1 . -3) + ;; aaba (3 . 4) N/A (in region) + ;; ccaaba (1 . 3) (1 . -2) + ;; ccaabaddd (7 . 10) (7 . -3) + ;; ccaabdd ("ad" . 6) (6 . 2) + ;; ccaabaddd (6 . 8) (6 . -2) + ;; | |<-- region: "caab", from 2 to 6 + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "aaa") + (goto-char 3) + (undo-boundary) + (insert "b") + (goto-char 1) + (undo-boundary) + (insert "cc") + (goto-char 7) + (undo-boundary) + (insert "ddd") + (search-backward "ad") + (undo-boundary) + (delete-forward-char 2) + (undo-boundary) + ;; Select "dd" + (push-mark (point) t t) + (setq mark-active t) + (goto-char (point-max)) + (undo) + (undo-boundary) + (should (string= (buffer-string) + "ccaabaddd")) + ;; Select "caab" + (push-mark 2 t t) + (setq mark-active t) + (goto-char 6) + (undo) + (undo-boundary) + (should (string= (buffer-string) + "ccaaaddd")))) + +(ert-deftest undo-test-region-eob () + "Test undo in region of a deletion at EOB, demonstrating bug 16411." + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "This sentence corrupted?") + (undo-boundary) + ;; Same as recipe at + ;; http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16411 + (insert "aaa") + (undo-boundary) + (undo) + ;; Select entire buffer + (push-mark (point) t t) + (setq mark-active t) + (goto-char (point-min)) + ;; Should undo the undo of "aaa", ie restore it. + (undo) + (should (string= (buffer-string) + "This sentence corrupted?aaa")))) + +(ert-deftest undo-test-marker-adjustment-nominal () + "Test nominal behavior of marker adjustments." + (with-temp-buffer + (buffer-enable-undo) + (insert "abcdefg") + (undo-boundary) + (let ((m (make-marker))) + (set-marker m 2 (current-buffer)) + (goto-char (point-min)) + (delete-forward-char 3) + (undo-boundary) + (should (= (point-min) (marker-position m))) + (undo) + (undo-boundary) + (should (= 2 (marker-position m)))))) + +(ert-deftest undo-test-region-t-marker () + "Test undo in region containing marker with t insertion-type." + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "abcdefg") + (undo-boundary) + (let ((m (make-marker))) + (set-marker-insertion-type m t) + (set-marker m (point-min) (current-buffer)) ; m at a + (goto-char (+ 2 (point-min))) + (push-mark (point) t t) + (setq mark-active t) + (goto-char (point-min)) + (delete-forward-char 1) ;; delete region covering "ab" + (undo-boundary) + (should (= (point-min) (marker-position m))) + ;; Resurrect "ab". m's insertion type means the reinsertion + ;; moves it forward 2, and then the marker adjustment returns it + ;; to its rightful place. + (undo) + (undo-boundary) + (should (= (point-min) (marker-position m)))))) + +(ert-deftest undo-test-marker-adjustment-moved () + "Test marker adjustment behavior when the marker moves. +Demonstrates bug 16818." + (with-temp-buffer + (buffer-enable-undo) + (insert "abcdefghijk") + (undo-boundary) + (let ((m (make-marker))) + (set-marker m 2 (current-buffer)) ; m at b + (goto-char (point-min)) + (delete-forward-char 3) ; m at d + (undo-boundary) + (set-marker m 4) ; m at g + (undo) + (undo-boundary) + ;; m still at g, but shifted 3 because deletion undone + (should (= 7 (marker-position m)))))) + +(ert-deftest undo-test-region-mark-adjustment () + "Test that the mark's marker adjustment in undo history doesn't +obstruct undo in region from finding the correct change group. +Demonstrates bug 16818." + (with-temp-buffer + (buffer-enable-undo) + (transient-mark-mode 1) + (insert "First line\n") + (insert "Second line\n") + (undo-boundary) + + (goto-char (point-min)) + (insert "aaa") + (undo-boundary) + + (undo) + (undo-boundary) + + (goto-char (point-max)) + (insert "bbb") + (undo-boundary) + + (push-mark (point) t t) + (setq mark-active t) + (goto-char (- (point) 3)) + (delete-forward-char 1) + (undo-boundary) + + (insert "bbb") + (undo-boundary) + + (goto-char (point-min)) + (push-mark (point) t t) + (setq mark-active t) + (goto-char (+ (point) 3)) + (undo) + (undo-boundary) + + (should (string= (buffer-string) "aaaFirst line\nSecond line\nbbb")))) + +(defun undo-test-all (&optional interactive) + "Run all tests for \\[undo]." + (interactive "p") + (if interactive + (ert-run-tests-interactively "^undo-") + (ert-run-tests-batch "^undo-"))) + +(provide 'undo-tests) +;;; undo-tests.el ends here |