From: Paul Eggert Date: Thu, 26 May 2016 20:02:07 +0000 (-0700) Subject: Repair damage from emacs-25 merge X-Git-Tag: emacs-26.0.90~1889 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6ca36676c96954466bc0f1266115dff641697424;p=emacs.git Repair damage from emacs-25 merge * test/lisp/character-fold-tests.el: Remove, as it was renamed to test/lisp/char-fold-tests.el. * test/lisp/emulation/viper-tests.el: Rename from test/automated/viper-tests.el. --- diff --git a/test/automated/viper-tests.el b/test/automated/viper-tests.el deleted file mode 100644 index 8b30f050935..00000000000 --- a/test/automated/viper-tests.el +++ /dev/null @@ -1,160 +0,0 @@ -;;; viper-tests.el --- tests for viper. - -;; Copyright (C) 2016 Free Software Foundation, Inc. - -;; 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 . - -;;; Commentary: - -;;; Code: - - -(require 'viper) - -(defun viper-test-undo-kmacro (kmacro) - "In a clean viper buffer, run KMACRO and return `buffer-string'. - -This function makes as many attempts as possible to clean up -after itself, although it will leave a buffer called -*viper-test-buffer* if it fails (this is deliberate!)." - (let ( - ;; Viper just turns itself off during batch use. - (noninteractive nil) - ;; Switch off start up message or it will chew the key presses - (viper-inhibit-startup-message 't) - ;; Select an expert-level for the same reason. - (viper-expert-level 5) - ;; viper loads this even with -q so make sure it's empty! - (viper-custom-file-name (make-temp-file "viper-tests")) - (before-buffer (current-buffer))) - (unwind-protect - (progn - ;; viper-mode is essentially global, so set it here - (viper-mode) - ;; We must switch to buffer because we are using a keyboard macro - ;; which appears to not go to the current-buffer but what ever is - ;; currently taking keyboard events. We use a named buffer because - ;; then we can see what it in it if it all goes wrong. - (switch-to-buffer - (get-buffer-create - "*viper-test-buffer*")) - (erase-buffer) - ;; The new buffer fails to enter vi state so set it. - (viper-change-state-to-vi) - ;; Run the macro - (execute-kbd-macro kmacro) - (let ((rtn - (buffer-substring-no-properties - (point-min) - (point-max)))) - ;; Kill the buffer iff the macro succeeds - (kill-buffer) - rtn)) - ;; switch everthing off and restore the buffer - (toggle-viper-mode) - (switch-to-buffer before-buffer)))) - -(ert-deftest viper-test-go () - "Test that this file is running." - (should t)) - -(ert-deftest viper-test-fix () - "Test that the viper kmacro fixture is working." - (should - (viper-test-undo-kmacro []))) - -(ert-deftest viper-test-undo-1 () - "Test for VI like undo behaviour. - -Insert 1, then 2 on consecutive lines, followed by undo. This -should leave just 1 in the buffer. - -Test for Bug #22295" - (should - (equal - "1\n" - (viper-test-undo-kmacro - [ - ?a - ?1 - escape - ?o - ?2 - escape - ?u - ] - )))) - -(ert-deftest viper-test-undo-2 () - "Test for VI like undo behaviour. - -Insert \"1 2 3 4 5\" then delete the 2, then the 4, and undo. -Should restore the 4, but leave the 2 deleted. - -Test for Bug #22295" - (should - (equal - "1 3 4 5\n" - (viper-test-undo-kmacro - [ - ?i - ?1 ? ?2 ? ?3 ? ?4 ? ?5 - escape - ?F ?2 ?d ?w - ?w ?d ?w - ?u - ])))) - -(ert-deftest viper-test-undo-3 () - "Test for VI like undo behaviour. - -Insert \"1 2 3 4 5 6\", delete the 2, then the 3 4 and 5. -Should restore the 3 4 and 5 but not the 2. - -Test for Bug #22295" - (should - (equal - "1 3 4 5 6\n" - (viper-test-undo-kmacro - [ - ;; Insert this lot. - ?i ?1 ? ?2 ? ?3 ? ?4 ? ?5 ? ?6 - escape - ;; Start of line. - ?0 - ;; Move to 2, delete - ?w ?d ?w - ;; Delete 3 4 5 - ?. ?. ?. - ;; Undo del 5, then - ?u ?. ?. - ])))) - - -(ert-deftest viper-test-undo-4() - (should - (equal - "" - (viper-test-undo-kmacro - [ - ?i ?1 escape - ?o ?2 escape - ?o ?3 escape - ?u ?. ?. - ]) - ))) - -;;; viper-tests.el ends here diff --git a/test/lisp/character-fold-tests.el b/test/lisp/character-fold-tests.el deleted file mode 100644 index dc7e9270551..00000000000 --- a/test/lisp/character-fold-tests.el +++ /dev/null @@ -1,122 +0,0 @@ -;;; character-fold-tests.el --- Tests for character-fold.el -*- lexical-binding: t; -*- - -;; Copyright (C) 2013-2016 Free Software Foundation, Inc. - -;; Author: Artur Malabarba - -;; 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 . - -;;; Code: - -(require 'ert) -(require 'character-fold) - -(defun character-fold--random-word (n) - (mapconcat (lambda (_) (string (+ 9 (random 117)))) - (make-list n nil) "")) - -(defun character-fold--test-search-with-contents (contents string) - (with-temp-buffer - (insert contents) - (goto-char (point-min)) - (should (search-forward-regexp (character-fold-to-regexp string) nil 'noerror)) - (goto-char (point-min)) - (should (character-fold-search-forward string nil 'noerror)) - (should (character-fold-search-backward string nil 'noerror)))) - - -(ert-deftest character-fold--test-consistency () - (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 40) - (let ((w1 (character-fold--random-word n)) - (w2 (character-fold--random-word n)) - (search-spaces-regexp "\\s-+")) - (character-fold--test-search-with-contents - (concat w1 "\s\n\s\t\f\t\n\r\t" w2) - (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 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 (float-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 (< (- (float-time) time) 1)))))) - -(provide 'character-fold-tests) -;;; character-fold-tests.el ends here diff --git a/test/lisp/emulation/viper-tests.el b/test/lisp/emulation/viper-tests.el new file mode 100644 index 00000000000..8b30f050935 --- /dev/null +++ b/test/lisp/emulation/viper-tests.el @@ -0,0 +1,160 @@ +;;; viper-tests.el --- tests for viper. + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; 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 . + +;;; Commentary: + +;;; Code: + + +(require 'viper) + +(defun viper-test-undo-kmacro (kmacro) + "In a clean viper buffer, run KMACRO and return `buffer-string'. + +This function makes as many attempts as possible to clean up +after itself, although it will leave a buffer called +*viper-test-buffer* if it fails (this is deliberate!)." + (let ( + ;; Viper just turns itself off during batch use. + (noninteractive nil) + ;; Switch off start up message or it will chew the key presses + (viper-inhibit-startup-message 't) + ;; Select an expert-level for the same reason. + (viper-expert-level 5) + ;; viper loads this even with -q so make sure it's empty! + (viper-custom-file-name (make-temp-file "viper-tests")) + (before-buffer (current-buffer))) + (unwind-protect + (progn + ;; viper-mode is essentially global, so set it here + (viper-mode) + ;; We must switch to buffer because we are using a keyboard macro + ;; which appears to not go to the current-buffer but what ever is + ;; currently taking keyboard events. We use a named buffer because + ;; then we can see what it in it if it all goes wrong. + (switch-to-buffer + (get-buffer-create + "*viper-test-buffer*")) + (erase-buffer) + ;; The new buffer fails to enter vi state so set it. + (viper-change-state-to-vi) + ;; Run the macro + (execute-kbd-macro kmacro) + (let ((rtn + (buffer-substring-no-properties + (point-min) + (point-max)))) + ;; Kill the buffer iff the macro succeeds + (kill-buffer) + rtn)) + ;; switch everthing off and restore the buffer + (toggle-viper-mode) + (switch-to-buffer before-buffer)))) + +(ert-deftest viper-test-go () + "Test that this file is running." + (should t)) + +(ert-deftest viper-test-fix () + "Test that the viper kmacro fixture is working." + (should + (viper-test-undo-kmacro []))) + +(ert-deftest viper-test-undo-1 () + "Test for VI like undo behaviour. + +Insert 1, then 2 on consecutive lines, followed by undo. This +should leave just 1 in the buffer. + +Test for Bug #22295" + (should + (equal + "1\n" + (viper-test-undo-kmacro + [ + ?a + ?1 + escape + ?o + ?2 + escape + ?u + ] + )))) + +(ert-deftest viper-test-undo-2 () + "Test for VI like undo behaviour. + +Insert \"1 2 3 4 5\" then delete the 2, then the 4, and undo. +Should restore the 4, but leave the 2 deleted. + +Test for Bug #22295" + (should + (equal + "1 3 4 5\n" + (viper-test-undo-kmacro + [ + ?i + ?1 ? ?2 ? ?3 ? ?4 ? ?5 + escape + ?F ?2 ?d ?w + ?w ?d ?w + ?u + ])))) + +(ert-deftest viper-test-undo-3 () + "Test for VI like undo behaviour. + +Insert \"1 2 3 4 5 6\", delete the 2, then the 3 4 and 5. +Should restore the 3 4 and 5 but not the 2. + +Test for Bug #22295" + (should + (equal + "1 3 4 5 6\n" + (viper-test-undo-kmacro + [ + ;; Insert this lot. + ?i ?1 ? ?2 ? ?3 ? ?4 ? ?5 ? ?6 + escape + ;; Start of line. + ?0 + ;; Move to 2, delete + ?w ?d ?w + ;; Delete 3 4 5 + ?. ?. ?. + ;; Undo del 5, then + ?u ?. ?. + ])))) + + +(ert-deftest viper-test-undo-4() + (should + (equal + "" + (viper-test-undo-kmacro + [ + ?i ?1 escape + ?o ?2 escape + ?o ?3 escape + ?u ?. ?. + ]) + ))) + +;;; viper-tests.el ends here