[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f1d1a2e 22/46: tiny-test.el: switched to ERT.
From: |
Oleh Krehel |
Subject: |
[elpa] master f1d1a2e 22/46: tiny-test.el: switched to ERT. |
Date: |
Sun, 22 Mar 2015 17:42:32 +0000 |
branch: master
commit f1d1a2e47df8dbde73e7646ab35b0b6301899350
Author: oleh <address@hidden>
Commit: oleh <address@hidden>
tiny-test.el: switched to ERT.
---
tiny-test.el | 76 +++++++++++++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/tiny-test.el b/tiny-test.el
index 6a09a4f..fb64963 100644
--- a/tiny-test.el
+++ b/tiny-test.el
@@ -1,33 +1,45 @@
-(defun tiny-extract-sexps-test ()
- (equal
- (tiny-extract-sexps "expr1 %(+ x x), nothing %% char %c, hex %x, and expr2
%(* x x), float %0.2f and sym %s")
- '("expr1 %s, nothing %% char %c, hex %x, and expr2 %s, float %0.2f and sym
%s"
- "(+ x x)" nil nil "(* x x)" nil nil)))
+(require 'tiny)
-(defun tiny-mapconcat-parse-test ()
- (let* ((tests
- '(("m10" (nil nil "10" nil nil))
- ("m5%x" (nil nil "5" nil "%x"))
- ("m5 10" ("5" " " "10" nil nil))
- ("m5,10" ("5" "," "10" nil nil))
- ("m5 10*xx" ("5" " " "10" "(* x x)" nil))
- ("m5 10*xx%x" ("5" " " "10" "(* x x)" "%x"))
- ("m5 10*xx|0x%x" ("5" " " "10" "(* x x)" "0x%x"))
- ("m25+x?a%c" (nil nil "25" "(+ x 97)" "%c"))
- ("m25+x?A%c" (nil nil "25" "(+ x 65)" "%c"))
- ("m97,122stringx" ("97" "," "122" "(string x)" nil))
- ("m97,122stringxx" ("97" "," "122" "(string x x)" nil))
- ("m97,120stringxupcasex" ("97" "," "120" "(string x (upcase x))"
nil))
- ("m97,120stringxupcasex)x" ("97" "," "120" "(string x (upcase x)
x)" nil))
- ("m\\n;; 10|%(+ x x) and %(* x x) and %s"
- (nil "\\n;; " "10" nil "%(+ x x) and %(* x x) and %s"))))
- (fails (cl-remove-if
- (lambda (test)
- (equal (cadr test)
- (with-temp-buffer
- (insert (car test))
- (tiny-mapconcat-parse))))
- tests)))
- (when fails
- (message "`tiny-test' fails %s" fails))))
-;; (tiny-mapconcat-parse-test)
+(defun with-text-value (txt fn &rest args)
+ "Return the result of (apply 'FN ARGS), in a temp buffer with TXT,
+with point at the end of TXT."
+ (with-temp-buffer
+ (insert txt)
+ (apply fn args)))
+
+(ert-deftest tiny-mapconcat-parse-test ()
+ (should (equal (with-text-value "m10" #'tiny-mapconcat-parse)
+ '(nil nil "10" nil nil)))
+ (should (equal (with-text-value "m5%x" #'tiny-mapconcat-parse)
+ '(nil nil "5" nil "%x")))
+ (should (equal (with-text-value "m5 10" #'tiny-mapconcat-parse)
+ '("5" " " "10" nil nil)))
+ (should (equal (with-text-value "m5,10" #'tiny-mapconcat-parse)
+ '("5" "," "10" nil nil)))
+ (should (equal (with-text-value "m5 10*xx" #'tiny-mapconcat-parse)
+ '("5" " " "10" "(* x x)" nil)))
+ (should (equal (with-text-value "m5 10*xx%x" #'tiny-mapconcat-parse)
+ '("5" " " "10" "(* x x)" "%x")))
+ (should (equal (with-text-value "m5 10*xx|0x%x" #'tiny-mapconcat-parse)
+ '("5" " " "10" "(* x x)" "0x%x")))
+ (should (equal (with-text-value "m25+x?a%c" #'tiny-mapconcat-parse)
+ '(nil nil "25" "(+ x 97)" "%c")))
+ (should (equal (with-text-value "m25+x?A%c" #'tiny-mapconcat-parse)
+ '(nil nil "25" "(+ x 65)" "%c")))
+ (should (equal (with-text-value "m97,122stringx" #'tiny-mapconcat-parse)
+ '("97" "," "122" "(string x)" nil)))
+ (should (equal (with-text-value "m97,122stringxx" #'tiny-mapconcat-parse)
+ '("97" "," "122" "(string x x)" nil)))
+ (should (equal (with-text-value "m97,120stringxupcasex"
#'tiny-mapconcat-parse)
+ '("97" "," "120" "(string x (upcase x))" nil)))
+ (should (equal (with-text-value "m97,120stringxupcasex)x"
#'tiny-mapconcat-parse)
+ '("97" "," "120" "(string x (upcase x) x)" nil)))
+ (should (equal (with-text-value "m\\n;; 10|%(+ x x) and %(* x x) and %s"
#'tiny-mapconcat-parse)
+ '(nil "\\n;; " "10" nil "%(+ x x) and %(* x x) and %s"))))
+
+(ert-deftest tiny-extract-sexps-test ()
+ (should (equal (tiny-extract-sexps "expr1 %(+ x x), nothing %% char %c, hex
%x, and expr2 %(* x x), float %0.2f and sym %s")
+ '("expr1 %s, nothing %% char %c, hex %x, and expr2 %s, float
%0.2f and sym %s"
+ "(+ x x)" nil nil "(* x x)" nil nil))))
+
+(provide 'tiny-test)
- [elpa] master 29b5b76 16/46: Added README.md, (continued)
- [elpa] master 29b5b76 16/46: Added README.md, Oleh Krehel, 2015/03/22
- [elpa] master b9c35e1 17/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 97b9fdf 14/46: tiny.el: fixed up the previous change., Oleh Krehel, 2015/03/22
- [elpa] master 80e64b8 18/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 2bd9abb 21/46: tiny.el: moved tests to tiny-test.el., Oleh Krehel, 2015/03/22
- [elpa] master b99315d 20/46: tiny.el: updated the doc., Oleh Krehel, 2015/03/22
- [elpa] master 11722a1 19/46: tiny.el: fixed typos., Oleh Krehel, 2015/03/22
- [elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize', Oleh Krehel, 2015/03/22
- [elpa] master 5df4f79 25/46: tiny.el: removed `tiny-beginning-of-string', Oleh Krehel, 2015/03/22
- [elpa] master 8a3cab0 27/46: tiny.el: removed `tiny-replace-preceding-sexp', Oleh Krehel, 2015/03/22
- [elpa] master f1d1a2e 22/46: tiny-test.el: switched to ERT.,
Oleh Krehel <=
- [elpa] master 4c87ade 29/46: tiny.el: fixed a bug in `tiny-mapconcat-parse'., Oleh Krehel, 2015/03/22
- [elpa] master a6e4144 30/46: tiny.el (tiny-extract-sexps): can handle e.g. %0.1f(...) style formatting., Oleh Krehel, 2015/03/22
- [elpa] master 80cd28f 28/46: tiny-test.el: added a test for `tiny-replace-this-sexp', Oleh Krehel, 2015/03/22
- [elpa] master 08ba593 24/46: tiny.el: fixed `tiny-tokenize', Oleh Krehel, 2015/03/22
- [elpa] master e6abbc6 31/46: tiny.el (tiny-date): renamed from t-date. In format string it's just "date", Oleh Krehel, 2015/03/22
- [elpa] master c59bc94 36/46: tiny.el (tiny-extract-sexps): add missing let binding, Oleh Krehel, 2015/03/22
- [elpa] master cf74dd1 34/46: tiny.el: fix docs, Oleh Krehel, 2015/03/22
- [elpa] master b843226 26/46: tiny.el: removed `tiny-replace-sexp-desperately', Oleh Krehel, 2015/03/22
- [elpa] master 7893a02 35/46: tiny.el: add autoload to `tiny-expand', Oleh Krehel, 2015/03/22
- [elpa] master 075e4d0 33/46: Fix "m10|%0.2f", Oleh Krehel, 2015/03/22