[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/paredit 980a4f4 091/224: Add rudimentary and preliminary t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/paredit 980a4f4 091/224: Add rudimentary and preliminary test suite. |
Date: |
Sat, 7 Aug 2021 09:22:25 -0400 (EDT) |
branch: elpa/paredit
commit 980a4f4bcc258da09d8519ee6077b88bd5ecdcc4
Author: Taylor R Campbell <campbell@mumble.net>
Commit: Taylor R Campbell <campbell@mumble.net>
Add rudimentary and preliminary test suite.
Ignore-this: 8d80152ebf5aed8071f76e387063c0a9
darcs-hash:20110322203017-00fcc-2439f0ee58f137a114c40930fa6a19599d89bf0a
---
test.el | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 184 insertions(+)
diff --git a/test.el b/test.el
new file mode 100644
index 0000000..3dd9f83
--- /dev/null
+++ b/test.el
@@ -0,0 +1,184 @@
+;;; -*- Mode: Emacs-Lisp -*-
+
+;;; Rudimentary, kludgey test suite for paredit -- work in progress!
+
+;; Copyright (C) 2005--2011 Taylor R. Campbell
+
+;; This file is part of paredit.
+;;
+;; Paredit 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.
+;;
+;; Paredit 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 paredit. If not, see <http://www.gnu.org/licenses/>.
+
+(defun paredit-test-failure-default (command before after expected)
+ (message "%S failed test: after %S, got %S but expected %S."
+ command before after expected))
+
+(defvar paredit-test-failure-function 'paredit-test-failure-default
+ "Function to call when `paredit-test' fails.
+Three arguments: the paredit command, the text of the buffer
+ before, and the text of the buffer after.")
+
+(defun paredit-test-failed (command before after expected)
+ (funcall paredit-test-failure-function command before after expected))
+
+(defun paredit-test (command examples)
+ (dolist (example examples)
+ (let ((before (car example)))
+ (dolist (after (cdr example))
+ (with-temp-buffer
+ (scheme-mode)
+ (insert before)
+ (goto-char (point-min))
+ (search-forward "|")
+ (backward-delete-char +1)
+ (funcall command)
+ (insert ?\|)
+ (if (not (string= after (buffer-string)))
+ (progn
+ (message "Got: %s" (buffer-string))
+ (paredit-test-failed command before (buffer-string) after))))
+ (setq before after)))))
+
+(paredit-do-commands (spec keys command examples)
+ nil ;string case
+ ;; `paredit-backslash' has a funny example.
+ (if (not (eq command 'paredit-backslash))
+ (paredit-test command examples)))
+
+(defun paredit-test-bracketed (entries examples)
+ (dolist (entry entries)
+ (let ((command (car entry))
+ (left (car (cdr entry)))
+ (right (car (cdr (cdr entry)))))
+ (paredit-test command
+ (mapcar
+ (lambda (example)
+ (mapcar (lambda (step)
+ (replace-regexp-in-string "(" (string left)
+ (replace-regexp-in-string ")" (string right) step)))
+ example))
+ examples)))))
+
+;++ Test `paredit-open-...' with the region active.
+;++ Test `paredit-open-...' with prefix arguments.
+
+(paredit-test-bracketed '((paredit-open-round ?\( ?\))
+ (paredit-open-square ?\[ ?\])
+ (paredit-open-curly ?\{ ?\})
+ (paredit-open-angled ?\< ?\>))
+ '(("(foo|bar)" "(foo (|) bar)")
+ ("(foo| bar)" "(foo (|) bar)")
+ ("(foo |bar)" "(foo (|) bar)")
+ ("(foo|\n bar)" "(foo (|)\n bar)")
+ ("(foo |(bar) baz)" "(foo (|) (bar) baz)")
+ ("(foo (bar)| baz)" "(foo (bar) (|) baz)")
+ ("(foo |\"bar\" baz)" "(foo (|) \"bar\" baz)")
+ ("(foo \"bar\"| baz)" "(foo \"bar\" (|) baz)")
+ ("foo|" "foo (|)")
+ ("|foo" "(|) foo")))
+
+(paredit-test-bracketed '((paredit-close-round ?\( ?\))
+ (paredit-close-square ?\[ ?\])
+ (paredit-close-curly ?\{ ?\})
+ (paredit-close-angled ?\< ?\>))
+ '(("(#\\|x)" "(#\\|x)")
+ ("(#\\|])" "(#\\|])")
+ ("(#\\| )" "(#\\| )")
+ ("(#\\|\")" "(#\\|\")")
+ ("(\"|\")" "(\")|\")")
+ ("(\"|\")" "(\")|\")")))
+
+(paredit-test-bracketed '((paredit-close-round ?\( ?\))
+ (paredit-close-square ?\[ ?\])
+ (paredit-close-curly ?\{ ?\})
+ ;; (paredit-close-angled ?\< ?\>)
+ )
+ '(("(|" "()|")
+ ;++ No way to express expected errors.
+ ;; ("foo|" error)
+ ("(foo| ;\n )" "(foo ;\n )|")
+ ("(foo| ;\n bar)" "(foo ;\n bar)|")
+ ("(foo| ;\n bar )" "(foo ;\n bar)|")))
+
+(paredit-test-bracketed '((paredit-close-round-and-newline ?\( ?\))
+ (paredit-close-square-and-newline ?\[ ?\])
+ (paredit-close-curly-and-newline ?\{ ?\})
+ ;; (paredit-close-angled-and-newline ?\< ?\>)
+ )
+ '(("(foo #\\|( )" "(foo #\\()\n|")
+ ("(foo|\n ) ;bar" "(foo) ;bar\n|")
+ ("((foo|\n) (bar))" "((foo)\n |(bar))")))
+
+(paredit-test 'paredit-newline
+ '(("\"foo|bar\"" "\"foo\n|bar\"")
+ ("(frob grovel ;full |(lexical)\n mumble)"
+ "(frob grovel ;full\n |(lexical)\n mumble)")
+ ("(frob grovel ;full (|lexical)\n mumble)"
+ "(frob grovel ;full (\n ;|lexical)\n mumble)")
+ ("#\\|(" "#\\(\n|")))
+
+(paredit-test 'paredit-reindent-defun
+ ;++ Test filling paragraphs in comments and strings.
+ '(("|(define (square x)\n (* x x))"
+ "|(define (square x)\n (* x x))")
+ ("(define (square x)\n (* x x))|"
+ "(define (square x)\n (* x x))|")
+ ("(define (square x)\n (* x x))|\n(frob\n wotz)"
+ "(define (square x)\n (* x x))|\n(frob\n wotz)")
+ ("(define (square x)\n (* x x))\n|(frob\n wotz)"
+ "(define (square x)\n (* x x))\n|(frob\n wotz)")
+ ("(define (square x)\n | (* x x))"
+ "(define (square x)\n | (* x x))")
+ ("(define (square x)\n | (* x x))"
+ "(define (square x)\n |(* x x))")
+ ("(define (square x)\n (* |x x))"
+ "(define (square x)\n (* |x x))")))
+
+(paredit-test 'paredit-semicolon
+ '(("#\\|(" ";|#\\(")))
+
+(paredit-test 'paredit-comment-dwim
+ '(("\"foo|bar;baz\" ;quux"
+ "\"foobar;baz\" ;|quux")
+ ;; Uh oh! Bug in `comment-indent'...
+ ;; ("\"foo\nbar|baz;quux\" ;zot"
+ ;; "\"foo\nbarbaz;quux\" ;|zot")
+ ;; I think the loop in `paredit-comment-on-line' is bogus. Can you
+ ;; elicit more than one iteration of it? That is, can you cause
+ ;; `comment-search-forward' to wind up inside a character or a
+ ;; string?
+ ))
+
+(paredit-test 'paredit-forward-delete
+ '(("f|oo" "f|o")
+ (";f|(oo" ";f|oo")
+ (";|;(foo)" ";|(foo)")
+ ("|;;(foo)" "|;(foo)" "|(foo)")
+ (";foo|\n(bar)\n(baz\n quux)" ";foo|(bar)\n(baz\n quux)")
+ ;; (";foo|\n(bar\n baz)" error)
+ ("|;;foo(" "|;foo(")
+ ;; ("|;;foo(" "|;foo(" error)
+ ))
+
+(paredit-test 'paredit-backward-delete
+ '(("fo|o" "f|o")
+ (";fo(|o" ";fo|o")
+ (";|;(foo)" "|;(foo)")
+ (";;|(foo)" ";|(foo)" "|(foo)")
+ (";foo\n|(bar)\n(baz\n quux)" ";foo|(bar)\n(baz\n quux)")
+ ;; (";foo\n|(bar\n baz)" error)
+ (";;|foo(" ";|foo(")
+ ;; (";;|foo(" ";|foo(" error)
+ ))
+
+;++ Killing commands...ugh...
- [nongnu] elpa/paredit c655f5c 052/224: Change header and footer to conform to elisp guidelines., (continued)
- [nongnu] elpa/paredit c655f5c 052/224: Change header and footer to conform to elisp guidelines., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2b094af 065/224: Bind M-? to `paredit-convolute-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4d6f3fc 090/224: Fix `imbalanced' -> `unbalanced' in `paredit-kill-region' docstring., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 52670b7 079/224: Fix spacing in `paredit-newline' example., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit bd439e3 083/224: Avoid trailing space when `paredit-comment-dwim' inserts code comments., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2c972a9 095/224: Omit angled delimiters from the `paredit-open-...' tests., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 2a64a4c 064/224: Eliminate confusing comment over `paredit-splice-sexp'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 48480a1 084/224: Omit needless line break in `paredit-join-sexps'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 4d3ad1e 069/224: Simplify definition of `paredit-count-sexps-forward'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 8a2d457 093/224: Reindent in `paredit-open-round' &c. like `paredit-wrap-round' &c., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 980a4f4 091/224: Add rudimentary and preliminary test suite.,
ELPA Syncer <=
- [nongnu] elpa/paredit 33f9c67 100/224: Use `error', not `message', to report test failures in test.el., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 79e7555 086/224: Be more careful about deleting comment starts & ends., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 121a8b4 104/224: Make backslash escape prompt less confusing., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 41bbc20 078/224: Make `paredit-comment-dwim' code comment example work in isolation., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 5e210b2 087/224: Fix bug in recent change to more carefully delete comment ends., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit d9ecc6d 094/224: Handle scan errors in `paredit-scan-sexps-hack'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 6c14694 113/224: Use `call-interactively' rather than `funcall' in `paredit-test'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 9cac6fa 106/224: Specify that paredit should work in XEmacs 21.5.28 or later., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 0bb4b62 110/224: Check for expected errors in `paredit-close-FOO'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/paredit 3c48233 122/224: Fix checks on deletion of comment boundaries., ELPA Syncer, 2021/08/07