[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117172: * test/automated/tildify-tests.el: New file
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] trunk r117172: * test/automated/tildify-tests.el: New file. |
Date: |
Wed, 28 May 2014 01:00:53 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117172
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17547
author: Michal Nazarewicz <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2014-05-27 21:00:44 -0400
message:
* test/automated/tildify-tests.el: New file.
* lisp/textmodes/tildify.el (tildify-buffer, tildify-region):
Add dont-ask option.
added:
test/automated/tildify-tests.el
tildifytests.el-20140528005849-0ztb8xe7wxesfzgk-1
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/textmodes/tildify.el tildify.el-20091113204419-o5vbwnq5f7feedwu-1683
test/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-8588
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-05-28 00:50:44 +0000
+++ b/lisp/ChangeLog 2014-05-28 01:00:44 +0000
@@ -1,3 +1,8 @@
+2014-05-21 Michal Nazarewicz <address@hidden>
+
+ * textmodes/tildify.el (tildify-buffer, tildify-region):
+ Add dont-ask option.
+
2014-05-28 Stefan Monnier <address@hidden>
* subr.el (zerop): Move from C. Add compiler-macro (bug#17475).
=== modified file 'lisp/textmodes/tildify.el'
--- a/lisp/textmodes/tildify.el 2014-01-01 07:43:34 +0000
+++ b/lisp/textmodes/tildify.el 2014-05-28 01:00:44 +0000
@@ -3,7 +3,7 @@
;; Copyright (C) 1997-2014 Free Software Foundation, Inc.
;; Author: Milan Zamazal <address@hidden>
-;; Version: 4.5
+;; Version: 4.5.1
;; Keywords: text, TeX, SGML, wp
;; This file is part of GNU Emacs.
@@ -172,20 +172,22 @@
;;; *** Interactive functions ***
;;;###autoload
-(defun tildify-region (beg end)
+(defun tildify-region (beg end &optional dont-ask)
"Add hard spaces in the region between BEG and END.
See variables `tildify-pattern-alist', `tildify-string-alist', and
`tildify-ignored-environments-alist' for information about configuration
parameters.
-This function performs no refilling of the changed text."
- (interactive "*r")
+This function performs no refilling of the changed text.
+If DONT-ASK is set, or called interactively with prefix argument, user
+won't be prompted for confirmation of each substitution."
+ (interactive "*rP")
(setq tildify-count 0)
(let (a
z
(marker-end (copy-marker end))
end-env
finish
- (ask t)
+ (ask (not dont-ask))
(case-fold-search nil)
(regexp (tildify-build-regexp)) ; beginnings of environments
aux)
@@ -226,14 +228,16 @@
(message "%d spaces replaced." tildify-count))
;;;###autoload
-(defun tildify-buffer ()
+(defun tildify-buffer (&optional dont-ask)
"Add hard spaces in the current buffer.
See variables `tildify-pattern-alist', `tildify-string-alist', and
`tildify-ignored-environments-alist' for information about configuration
parameters.
-This function performs no refilling of the changed text."
- (interactive "*")
- (tildify-region (point-min) (point-max)))
+This function performs no refilling of the changed text.
+If DONT-ASK is set, or called interactively with prefix argument, user
+won't be prompted for confirmation of each substitution."
+ (interactive "*P")
+ (tildify-region (point-min) (point-max) dont-ask))
;;; *** Auxiliary functions ***
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2014-05-27 14:28:07 +0000
+++ b/test/ChangeLog 2014-05-28 01:00:44 +0000
@@ -1,3 +1,7 @@
+2014-05-21 Michal Nazarewicz <address@hidden>
+
+ * automated/tildify-tests.el: New file.
+
2014-05-27 Stefan Monnier <address@hidden>
* indent/ruby.rb: Add one more test.
=== added file 'test/automated/tildify-tests.el'
--- a/test/automated/tildify-tests.el 1970-01-01 00:00:00 +0000
+++ b/test/automated/tildify-tests.el 2014-05-28 01:00:44 +0000
@@ -0,0 +1,106 @@
+;;; tildify-test.el --- ERT tests for teldify.el
+
+;; Copyright (C) 2014 Free Software Foundation, Inc.
+
+;; Author: Michal Nazarewicz <address@hidden>
+;; Version: 4.5
+;; Keywords: text, TeX, SGML, wp
+
+;; 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:
+
+;; This package defines regression tests for the tildify package.
+
+;;; Code:
+
+(require 'ert)
+(require 'tildify)
+
+(defun tildify-test--example-sentence (space)
+ "Return an example sentence with SPACE where hard space is required."
+ (concat "Lorem ipsum v" space "dolor sit amet, a" space
+ "consectetur adipiscing elit."))
+
+
+(defun tildify-test--example-html (sentence &optional with-nbsp)
+ "Return an example HTML code.
+SENTENCE is placed where spaces should not be replaced with hard spaces, and
+WITH-NBSP is placed where spaces should be replaced with hard spaces. If the
+latter is missing, SENTENCE will be used in all placeholder positions."
+ (let ((with-nbsp (or with-nbsp sentence)))
+ (concat "<p>" with-nbsp "</p>\n"
+ "<pre>" sentence "</pre>\n"
+ "<! -- " sentence " -- >\n"
+ "<p>" with-nbsp "</p>\n"
+ "<" sentence ">\n")))
+
+
+(defun tildify-test--test (modes input expected)
+ "Test tildify running in MODES.
+INPUT is the initial content of the buffer and EXPECTED is expected result
+after `tildify-buffer' is run."
+ (dolist (mode modes)
+ (with-temp-buffer
+ (funcall mode)
+ (let ((header (concat "Testing `tildify-buffer' in "
+ (symbol-name mode) "\n")))
+ (insert header input)
+ (tildify-buffer t)
+ (should (string-equal (concat header expected) (buffer-string)))))
+ (with-temp-buffer
+ (funcall mode)
+ (let ((header (concat "Testing `tildify-region' in "
+ (symbol-name mode) "\n")))
+ (insert header input)
+ (tildify-region (point-min) (point-max) t)
+ (should (string-equal (concat header expected) (buffer-string)))))))
+
+(ert-deftest tildify-test-html ()
+ "Tests tildification in an HTML document"
+ (let* ((sentence (tildify-test--example-sentence " "))
+ (with-nbsp (tildify-test--example-sentence " ")))
+ (tildify-test--test '(html-mode sgml-mode)
+ (tildify-test--example-html sentence sentence)
+ (tildify-test--example-html sentence with-nbsp))))
+
+
+(defun tildify-test--example-tex (sentence &optional with-nbsp)
+ "Return an example (La)Tex code.
+SENTENCE is placed where spaces should not be replaced with hard spaces, and
+WITH-NBSP is placed where spaces should be replaced with hard spaces. If the
+latter is missing, SENTENCE will be used in all placeholder positions."
+ (let ((with-nbsp (or with-nbsp sentence)))
+ (concat with-nbsp "\n"
+ "\\begin{verbatim}\n" sentence "\n\\end{verbatim}\n"
+ "\\verb#" sentence "#\n"
+ "$$" sentence "$$\n"
+ "$" sentence "$\n"
+ "\\[" sentence "\\]\n"
+ "\\v A % " sentence "\n"
+ with-nbsp "\n")))
+
+(ert-deftest tildify-test-tex ()
+ "Tests tildification in a (La)TeX document"
+ (let* ((sentence (tildify-test--example-sentence " "))
+ (with-nbsp (tildify-test--example-sentence "~")))
+ (tildify-test--test '(tex-mode latex-mode plain-tex-mode)
+ (tildify-test--example-tex sentence sentence)
+ (tildify-test--example-tex sentence with-nbsp))))
+
+(provide 'tildify-tests)
+
+;;; tildify-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117172: * test/automated/tildify-tests.el: New file.,
Stefan Monnier <=