]> code.delx.au - gnu-emacs-elpa/commitdiff
tiny.el: moved tests to tiny-test.el.
authoroleh <wave@mail.ua>
Mon, 7 Oct 2013 07:05:39 +0000 (09:05 +0200)
committeroleh <wave@mail.ua>
Mon, 7 Oct 2013 07:05:39 +0000 (09:05 +0200)
tiny-test.el [new file with mode: 0644]
tiny.el

diff --git a/tiny-test.el b/tiny-test.el
new file mode 100644 (file)
index 0000000..6a09a4f
--- /dev/null
@@ -0,0 +1,33 @@
+(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)))
+
+(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)
diff --git a/tiny.el b/tiny.el
index a8eba21543b6b0011891ebbc4e7532fe08849d2e..7f03d94998d25d15e2a693d3548c1a40b8f64d79 100644 (file)
--- a/tiny.el
+++ b/tiny.el
@@ -225,12 +225,6 @@ corresponds to a `format'-style % form in STR.
       (error (message "Malformed sexp: %s" (substring str beg))))
     (cons str (nreverse forms))))
 
-(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)))
-
 (defun tiny-mapconcat-parse ()
   "Try to match a snippet of this form:
 m[START][SEPARATOR]END[EXPR]|[FORMAT]
@@ -373,34 +367,6 @@ Return nil if nothing was matched, otherwise
          (apply #'concat (nreverse out))
          (make-string n-paren ?\)))))))
 
-(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 t-date (s &optional shift)
   (let ((time (->> (current-time)
                 decode-time