From debbugs-submit-bounces@debbugs.gnu.org Wed May 21 23:48:30 2014 Received: (at submit) by debbugs.gnu.org; 22 May 2014 03:48:30 +0000 Received: from localhost ([127.0.0.1]:55761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WnJzZ-00018t-1r for submit@debbugs.gnu.org; Wed, 21 May 2014 23:48:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50929) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WnJzW-00018Z-6Z for submit@debbugs.gnu.org; Wed, 21 May 2014 23:48:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnJzM-0000bf-FX for submit@debbugs.gnu.org; Wed, 21 May 2014 23:48:20 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnJzM-0000ba-BC for submit@debbugs.gnu.org; Wed, 21 May 2014 23:48:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnJzH-0002QN-Uy for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 23:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnJzC-0000YU-KW for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 23:48:11 -0400 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:61496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnJzC-0000Y3-74 for bug-gnu-emacs@gnu.org; Wed, 21 May 2014 23:48:06 -0400 Received: by mail-pd0-f169.google.com with SMTP id w10so2039219pde.28 for ; Wed, 21 May 2014 20:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:organization:user-agent:face:message-id :mime-version:content-type; bh=vcE0/t6N2VNEs0d8yk64puu78ai5d7ISsTi5IX0QdSY=; b=fF7NYLprY2hbL0Tvhxs6/TbwM7deAsSDPzYbl9BNxKTZEwOJy7j88UVugQHa576EAb 3MXMjBwi19/TKAngRWHY1xTS7zcjDKIttRGstlbBf0Z2uS7ZVnEjQ4jREmqEw8QqNnU2 BjBwwiEOTW29Sh5BpW0H6XenRiy0dIg05t+HkaWJ0eNrdRpk/8aRSunV4UopT69+l68e CXiXLvH+l834t9IjpzHibWhWW0keAErrFS4t/1DvQj3fZvllCecX0tdbXsrSOWGPN3Q/ Ni8UYaRVmBdQYGRDsmVUwj2i8LI+Hi+4K50WrzkpSDLrr7K8V1xy7sOvFfMtKPR5R00F lWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:organization :user-agent:face:message-id:mime-version:content-type; bh=vcE0/t6N2VNEs0d8yk64puu78ai5d7ISsTi5IX0QdSY=; b=c4IGJwDUgXFAgUeX+oflniy9Vv4xcmPIlSZ/lPw+P1K8wlHjYnT0E79uflDeZQ8EZy RhkOcGeGtqefx+vXsTZsEHMFyeS8S/CoApTwgUUQ42FDh2Q43qgU2sM5I0zImIji+FYL TLCv/qek1vrKlDKcdoCsJ3BHw6attrd4n/J+R/STNLki0+/maG0HA5TVkvyRotm8poml XlYDa/FAKGiR1Iv0iXTZBzzFOPIDqI/HqfgzNW4JOYi2Jx8R3EC9YuD+pxk+bfxZFbH8 Mx1gq49Kopym62fTVduNekAX8TqvVrlOfAZcRCqmH6E8CE3W6Fj+OFNRCX0WG0VI0fuY ZYMQ== X-Gm-Message-State: ALoCoQnJW7FB9nHwXUk8ePWR1ZTVZ2p77OwU5EXzOelN1sSAdQ0oNkreMumEx88jv7FPsZXjWcO1EyKns7c8NFrW8VY4spp3p0yxXvZaj6yByPnzHAyIq4GE8DXrBFLVEVTNnWcLXibB X-Received: by 10.66.250.202 with SMTP id ze10mr64261804pac.153.1400730484323; Wed, 21 May 2014 20:48:04 -0700 (PDT) Received: from mpn-glaptop.roam.corp.google.com (rrcs-24-43-221-254.west.biz.rr.com. [24.43.221.254]) by mx.google.com with ESMTPSA id id10sm10519854pbc.35.2014.05.21.20.48.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 May 2014 20:48:03 -0700 (PDT) From: Michal Nazarewicz To: emacs-devel@gnu.org, bug-gnu-emacs@gnu.org Subject: [PATCH] Add basic test suits for tildify package. Date: Wed, 21 May 2014 17:37:50 -1000 Organization: Google Inc User-Agent: Notmuch/0.17+15~gb65ca8e (http://notmuchmail.org) Emacs/24.4.50.1 (x86_64-unknown-linux-gnu) X-Face: PbkBB1w#)bOqd`iCe"Ds{e+!C7`pkC9a|f)Qo^BMQvy\q5x3?vDQJeN(DS?|-^$uMti[3D*#^_Ts"pU$jBQLq~Ud6iNwAw_r_o_4]|JO?]}P_}Nc&"p#D(ZgUb4uCNPe7~a[DbPG0T~!&c.y$Ur,=N4RT>]dNpd; KFrfMCylc}gc??'U2j,!8%xdD Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACQElEQVQ4jW3TMWvbQBQHcBk1xE6WyALX1069oZBMlq+ouUwpEQQ6uRjttkWP4CmBgGM0BQLBdPFZYPsyFUo6uEtKDQ7oy/U96XR2Ux8ehH/89Z6enqxBcS7Lg81jmSuujrfCZcLI/TYYvbGj+jbgFpHJ/bqQAUISj8iLyu4LuFHJTosxsucO4jSDNE0Hq3hwK/ceQ5sx97b8LcUDsILfk+ovHkOIsMbBfg43VuQ5Ln9YAGCkUdKJoXR9EclFBhixy3EGVz1K6eEkhxCAkeMMnqoAhAKwhoUJkDrCqvbecaYINlFKSRS1i12VKH1XpUd4qxL876EkMcDvHj3s5RBajHHMlA5iK32e0C7VgG0RlzFPvoYHZLRmAC0BmNcBruhkE0KsMsbEc62ZwUJDxWUdMsMhVqovoT96i/DnX/ASvz/6hbCabELLk/6FF/8PNpPCGqcZTGFcBhhAaZZDbQPaAB3+KrWWy2XgbYDNIinkdWAFcCpraDE/knwe5DBqGmgzESl1p2E4MWAz0VUPgYYzmfWb9yS4vCvgsxJriNTHoIBz5YteBvg+VGISQWUqhMiByPIPpygeDBE6elD973xWwKkEiHZAHKjhuPsFnBuArrzxtakRcISv+XMIPl4aGBUJm8Emk7qBYU8IlgNEIpiJhk/No24jHwkKTFHDWfPniR4iw5vJaw2nzSjfq2zffcE/GDjRC2dn0J0XwPAbDL84TvaFCJEU4Oml9pRyEUhR3Cl2t01AoEjRbs0sYugp14/4X5n4pU4EHHnMAAAAAElFTkSuQmCC X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --- lisp/ChangeLog | 5 ++ lisp/textmodes/tildify.el | 22 +++++---- test/ChangeLog | 4 ++ test/automated/tildify-tests.el | 106 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 test/automated/tildify-tests.el diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 09796f7..c2b1612 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-05-21 Michal Nazarewicz + + * textmodes/tildify.el (tildify-buffer, tildify-region): Add + dont-ask option. + 2014-05-19 Leo Liu * emacs-lisp/cl-lib.el (cl-endp): Conform to CL's semantics. diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 9732e7f..339f900 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1997-2014 Free Software Foundation, Inc. ;; Author: Milan Zamazal -;; Version: 4.5 +;; Version: 4.5.1 ;; Keywords: text, TeX, SGML, wp ;; This file is part of GNU Emacs. @@ -172,20 +172,22 @@ END-REGEX defines end of the corresponding text part and can be either: ;;; *** 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 @@ This function performs no refilling of the changed text." (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 *** diff --git a/test/ChangeLog b/test/ChangeLog index 3fed975..17468c2 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2014-05-21 Michal Nazarewicz + + * automated/tildify-tests.el: New file. + 2014-05-15 Dmitry Antipov * automated/fns-tests.el: New file. diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el new file mode 100644 index 0000000..4223029 --- /dev/null +++ b/test/automated/tildify-tests.el @@ -0,0 +1,106 @@ +;;; tildify-test.el --- ERT tests for teldify.el + +;; Copyright (C) 2014 Free Software Foundation, Inc. + +;; Author: Michal Nazarewicz +;; 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 . + +;;; 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 "

" with-nbsp "

\n" + "
" sentence "
\n" + "\n" + "

" with-nbsp "

\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 -- 1.9.1.423.g4596e3a From debbugs-submit-bounces@debbugs.gnu.org Tue May 27 21:02:47 2014 Received: (at 17547-done) by debbugs.gnu.org; 28 May 2014 01:02:47 +0000 Received: from localhost ([127.0.0.1]:33840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WpSGU-0006Sm-IB for submit@debbugs.gnu.org; Tue, 27 May 2014 21:02:47 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:64405) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WpSGR-0006SV-8T for 17547-done@debbugs.gnu.org; Tue, 27 May 2014 21:02:44 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYGAIDvNVNLd/fU/2dsb2JhbABZgwY7gw/APYEXF3SCJQEBAQECAVYjBQsLDiYSFA0LDSQTCYdcAwkIyl0Nhy8XjF6BOhEBUAeEOASOVIYPBYF5jlgDg12BaoNMIYEsBwIX X-IPAS-Result: ArYGAIDvNVNLd/fU/2dsb2JhbABZgwY7gw/APYEXF3SCJQEBAQECAVYjBQsLDiYSFA0LDSQTCYdcAwkIyl0Nhy8XjF6BOhEBUAeEOASOVIYPBYF5jlgDg12BaoNMIYEsBwIX X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="64502096" Received: from 75-119-247-212.dsl.teksavvy.com (HELO pastel.home) ([75.119.247.212]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 27 May 2014 21:02:37 -0400 Received: by pastel.home (Postfix, from userid 20848) id EDFFC60094; Tue, 27 May 2014 21:02:36 -0400 (EDT) From: Stefan Monnier To: Michal Nazarewicz Subject: Re: [PATCH] Add basic test suits for tildify package. Message-ID: References: Date: Tue, 27 May 2014 21:02:36 -0400 In-Reply-To: (Michal Nazarewicz's message of "Wed, 21 May 2014 17:37:50 -1000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 17547-done Cc: Milan Zamazal , 17547-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) [ Please try not to send the same email to both emacs-devel and bug-gnu-emacs. ] Thanks, installed. Stefan >>>>> "Michal" == Michal Nazarewicz writes: > --- > lisp/ChangeLog | 5 ++ > lisp/textmodes/tildify.el | 22 +++++---- > test/ChangeLog | 4 ++ > test/automated/tildify-tests.el | 106 ++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 128 insertions(+), 9 deletions(-) > create mode 100644 test/automated/tildify-tests.el > diff --git a/lisp/ChangeLog b/lisp/ChangeLog > index 09796f7..c2b1612 100644 > --- a/lisp/ChangeLog > +++ b/lisp/ChangeLog > @@ -1,3 +1,8 @@ > +2014-05-21 Michal Nazarewicz > + > + * textmodes/tildify.el (tildify-buffer, tildify-region): Add > + dont-ask option. > + > 2014-05-19 Leo Liu > * emacs-lisp/cl-lib.el (cl-endp): Conform to CL's semantics. > diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el > index 9732e7f..339f900 100644 > --- a/lisp/textmodes/tildify.el > +++ b/lisp/textmodes/tildify.el > @@ -3,7 +3,7 @@ > ;; Copyright (C) 1997-2014 Free Software Foundation, Inc. > ;; Author: Milan Zamazal > -;; Version: 4.5 > +;; Version: 4.5.1 > ;; Keywords: text, TeX, SGML, wp > ;; This file is part of GNU Emacs. > @@ -172,20 +172,22 @@ END-REGEX defines end of the corresponding text part and can be either: > ;;; *** 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 @@ This function performs no refilling of the changed text." > (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 *** > diff --git a/test/ChangeLog b/test/ChangeLog > index 3fed975..17468c2 100644 > --- a/test/ChangeLog > +++ b/test/ChangeLog > @@ -1,3 +1,7 @@ > +2014-05-21 Michal Nazarewicz > + > + * automated/tildify-tests.el: New file. > + > 2014-05-15 Dmitry Antipov > * automated/fns-tests.el: New file. > diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el > new file mode 100644 > index 0000000..4223029 > --- /dev/null > +++ b/test/automated/tildify-tests.el > @@ -0,0 +1,106 @@ > +;;; tildify-test.el --- ERT tests for teldify.el > + > +;; Copyright (C) 2014 Free Software Foundation, Inc. > + > +;; Author: Michal Nazarewicz > +;; 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 . > + > +;;; 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 "

" with-nbsp "

\n" > + "
" sentence "
\n" > + "\n" > + "

" with-nbsp "

\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 > -- > 1.9.1.423.g4596e3a From unknown Mon Jun 23 02:23:11 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 25 Jun 2014 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator