[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj 553f8618e1 044/185: Rework `clj-parse-deftest` ma
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj 553f8618e1 044/185: Rework `clj-parse-deftest` macro |
Date: |
Tue, 28 Dec 2021 14:05:14 -0500 (EST) |
branch: elpa/parseclj
commit 553f8618e1ecb37190c26b93225b7b5b27b50c99
Author: Daniel Barreto <dbarreto@talpor.com>
Commit: Daniel Barreto <dbarreto@talpor.com>
Rework `clj-parse-deftest` macro
---
clj-parse-test.el | 316 ++++++++++++++++++++++++++----------------------------
1 file changed, 153 insertions(+), 163 deletions(-)
diff --git a/clj-parse-test.el b/clj-parse-test.el
index 9fd41ab9a2..f10c0e4f63 100644
--- a/clj-parse-test.el
+++ b/clj-parse-test.el
@@ -25,184 +25,174 @@
(require 'clj-parse)
(require 'ert)
-(defmacro clj-parse-deftest (name parse-to-fn test-string expected)
- (declare (indent defun))
- `(ert-deftest ,name ()
- (with-temp-buffer
- (insert ,test-string)
- (goto-char 1)
- (should (equal (,parse-to-fn) ,expected)))))
+(defmacro clj-parse-eq-test (parse-to-fn test-string expected)
+ `(with-temp-buffer
+ (insert ,test-string)
+ (goto-char 1)
+ (should (equal (,parse-to-fn) ,expected))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; To Elisp code, ala edn.el
-(clj-parse-deftest clj-parse-to-elisp-simple-list
- clj-parse-to-elisp
- "(1 2 3)"
- '((1 2 3)))
-
-(clj-parse-deftest clj-parse-to-elisp-empty-list
- clj-parse-to-elisp
- "()"
- '(()))
-
-(clj-parse-deftest clj-parse-to-elisp-list-size-1
- clj-parse-to-elisp
- "(1)"
- '((1)))
-
-(clj-parse-deftest clj-parse-to-elisp-leafs
- clj-parse-to-elisp
- "(nil true false hello-world)"
- '((nil t nil hello-world)))
-
-(clj-parse-deftest clj-parse-to-elisp-qualified-symbol
- clj-parse-to-elisp
- "clojure.string/join"
- '(clojure.string/join))
-
-(clj-parse-deftest clj-parse-to-elisp-nested-lists
- clj-parse-to-elisp
- "((.9 abc (true) (hello)))"
- '(((0.9 abc (t) (hello)))))
-
-(clj-parse-deftest clj-parse-to-elisp-strings-1
- clj-parse-to-elisp
- "\"abc hello \\t\\\"x\""
- '("abc hello \t\"x"))
-
-(clj-parse-deftest clj-parse-to-elisp-strings-2
- clj-parse-to-elisp
- "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
- '(("---\f---\"-''-\\-\r\n")))
-
-(clj-parse-deftest clj-parse-to-elisp-chars-1
- clj-parse-to-elisp
- "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
- '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y)))
-
-(clj-parse-deftest clj-parse-to-elisp-chars-2
- clj-parse-to-elisp
- "\"\\u0078 \\o171\""
- '("x y"))
-
-(clj-parse-deftest clj-parse-to-elisp-keywords
- clj-parse-to-elisp
- ":foo-bar"
- '(:foo-bar))
-
-(clj-parse-deftest clj-parse-to-elisp-vector
- clj-parse-to-elisp
- "[123]"
- '([123]))
-
-(clj-parse-deftest clj-parse-to-elisp-map
- clj-parse-to-elisp
- "{:count 123}"
- '(((:count . 123))))
-
-(clj-parse-deftest clj-parse-to-elisp-set
- clj-parse-to-elisp
- "#{:x}"
- '((:x)))
-
-(clj-parse-deftest clj-parse-to-elisp-discarded
- clj-parse-to-elisp
- "(10 #_11 12 #_#_ 13 14)"
- '((10 12 14)))
+(ert-deftest clj-parse-to-elisp-simple-list ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(1 2 3)"
+ '((1 2 3))))
+
+(ert-deftest clj-parse-to-elisp-empty-list ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "()"
+ '(())))
+
+(ert-deftest clj-parse-to-elisp-list-size-1 ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(1)"
+ '((1))))
+
+(ert-deftest clj-parse-to-elisp-leafs ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(nil true false hello-world)"
+ '((nil t nil hello-world))))
+
+(ert-deftest clj-parse-to-elisp-qualified-symbol ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "clojure.string/join"
+ '(clojure.string/join)))
+
+(ert-deftest clj-parse-to-elisp-nested-lists ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "((.9 abc (true) (hello)))"
+ '(((0.9 abc (t) (hello))))))
+
+(ert-deftest clj-parse-to-elisp-strings ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "\"abc hello \\t\\\"x\""
+ '("abc hello \t\"x"))
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
+ '(("---\f---\"-''-\\-\r\n"))))
+
+(ert-deftest clj-parse-to-elisp-chars ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
+ '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y)))
+ (clj-parse-eq-test clj-parse-to-elisp
+ "\"\\u0078 \\o171\""
+ '("x y")))
+
+(ert-deftest clj-parse-to-elisp-keywords ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ ":foo-bar"
+ '(:foo-bar)))
+
+(ert-deftest clj-parse-to-elisp-vector ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "[123]"
+ '([123])))
+
+(ert-deftest clj-parse-to-elisp-map ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "{:count 123}"
+ '(((:count . 123)))))
+
+(ert-deftest clj-parse-to-elisp-set ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "#{:x}"
+ '((:x))))
+
+(ert-deftest clj-parse-to-elisp-discarded ()
+ (clj-parse-eq-test clj-parse-to-elisp
+ "(10 #_11 12 #_#_ 13 14)"
+ '((10 12 14))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; To Clojure/EDN string
-(clj-parse-deftest clj-parse-to-string-simple-list
- clj-parse-to-string
- "( 1 2 3)"
- "(1 2 3)")
-
-(clj-parse-deftest clj-parse-to-string-empty-list
- clj-parse-to-string
- "()"
- "()")
-
-(clj-parse-deftest clj-parse-to-string-list-size-1
- clj-parse-to-string
- "(1)"
- "(1)")
-
-(clj-parse-deftest clj-parse-to-string-leafs
- clj-parse-to-string
- "(nil true false hello-world)"
- "(nil true false hello-world)")
-
-(clj-parse-deftest clj-parse-to-string-qualified-symbol
- clj-parse-to-string
- "clojure.string/join"
- "clojure.string/join")
-
-(clj-parse-deftest clj-parse-to-string-nested-lists
- clj-parse-to-string
- "((.9 abc (true) (hello)))"
- "((.9 abc (true) (hello)))")
-
-(clj-parse-deftest clj-parse-to-string-strings-1
- clj-parse-to-string
- "\"abc hello \\t\\\"x\""
- "\"abc hello \\t\\\"x\"")
-
-(clj-parse-deftest clj-parse-to-string-strings-2
- clj-parse-to-string
- "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
- "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")")
-
-(clj-parse-deftest clj-parse-to-string-chars-1
- clj-parse-to-string
- "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
- "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)")
-
-(clj-parse-deftest clj-parse-to-string-chars-2
- clj-parse-to-string
- "\"\\u0078 \\o171\""
- "\"\\u0078 \\o171\"")
-
-(clj-parse-deftest clj-parse-to-string-keywords
- clj-parse-to-string
- ":foo-bar"
- ":foo-bar")
-
-(clj-parse-deftest clj-parse-to-string-vector
- clj-parse-to-string
- "[123]"
- "[123]")
-
-(clj-parse-deftest clj-parse-to-string-map
- clj-parse-to-string
- "{:count 123}"
- "{:count 123}")
-
-(clj-parse-deftest clj-parse-to-string-set
- clj-parse-to-string
- "#{:x}"
- "#{:x}")
-
-(clj-parse-deftest clj-parse-to-string-discarded
- clj-parse-to-string
- "(10 #_11 12 #_#_ 13 14)"
- "(10 12 14)")
+(ert-deftest clj-parse-to-string-simple-list ()
+ (clj-parse-eq-test clj-parse-to-string
+ "( 1 2 3)"
+ "(1 2 3)"))
+
+(ert-deftest clj-parse-to-string-empty-list ()
+ (clj-parse-eq-test clj-parse-to-string
+ "()"
+ "()"))
+
+(ert-deftest clj-parse-to-string-list-size-1 ()
+ (clj-parse-eq-test clj-parse-to-string
+ "(1)"
+ "(1)"))
+
+(ert-deftest clj-parse-to-string-leafs ()
+ (clj-parse-eq-test clj-parse-to-string
+ "(nil true false hello-world)"
+ "(nil true false hello-world)"))
+
+(ert-deftest clj-parse-to-string-qualified-symbol ()
+ (clj-parse-eq-test clj-parse-to-string
+ "clojure.string/join"
+ "clojure.string/join"))
+
+(ert-deftest clj-parse-to-string-nested-lists ()
+ (clj-parse-eq-test clj-parse-to-string
+ "((.9 abc (true) (hello)))"
+ "((.9 abc (true) (hello)))"))
+
+(ert-deftest clj-parse-to-string-strings ()
+ (clj-parse-eq-test clj-parse-to-string
+ "\"abc hello \\t\\\"x\""
+ "\"abc hello \\t\\\"x\"")
+ (clj-parse-eq-test clj-parse-to-string
+ "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"
+ "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")"))
+
+(ert-deftest clj-parse-to-string-chars ()
+ (clj-parse-eq-test clj-parse-to-string
+ "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)"
+ "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)")
+ (clj-parse-eq-test clj-parse-to-string
+ "\"\\u0078 \\o171\""
+ "\"\\u0078 \\o171\""))
+
+(ert-deftest clj-parse-to-string-keywords ()
+ (clj-parse-eq-test clj-parse-to-string
+ ":foo-bar"
+ ":foo-bar"))
+
+(ert-deftest clj-parse-to-string-vector ()
+ (clj-parse-eq-test clj-parse-to-string
+ "[123]"
+ "[123]"))
+
+(ert-deftest clj-parse-to-string-map ()
+ (clj-parse-eq-test clj-parse-to-string
+ "{:count 123}"
+ "{:count 123}"))
+
+(ert-deftest clj-parse-to-string-set ()
+ (clj-parse-eq-test clj-parse-to-string
+ "#{:x}"
+ "#{:x}"))
+
+(ert-deftest clj-parse-to-string-discarded ()
+ (clj-parse-eq-test clj-parse-to-string
+ "(10 #_11 12 #_#_ 13 14)"
+ "(10 12 14)"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AST
-(clj-parse-deftest clj-parse-ast-simple-list
- clj-parse
- "(1 2 3)"
- '((type . :root)
- (subnodes . (((type . :list)
- (subnodes . (((type . :number) (form . "1") (pos . 2))
- ((type . :number) (form . "2") (pos . 4))
- ((type . :number) (form . "3") (pos . 6)))))))))
+(ert-deftest clj-parse-ast-simple-list ()
+ (clj-parse-eq-test clj-parse
+ "(1 2 3)"
+ '((type . :root)
+ (subnodes . (((type . :list)
+ (subnodes . (((type . :number) (form . "1") (pos . 2))
+ ((type . :number) (form . "2") (pos . 4))
+ ((type . :number) (form . "3") (pos .
6))))))))))
(provide 'clj-parse-test)
- [nongnu] elpa/parseclj 972161dd23 022/185: Make sure we test against the version we think we are testing against, (continued)
- [nongnu] elpa/parseclj 972161dd23 022/185: Make sure we test against the version we think we are testing against, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 792ba04647 024/185: A more elaborate test, nesting works!, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 452fe7cc76 023/185: Implement nil, true, false, symbol, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 67171853f5 026/185: lex characters, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4f54ba52fe 033/185: Add support for sets, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4f647c8cff 036/185: Remove duplicate defination of clj-lex--token-token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1b2b221c98 038/185: Add AST to Elisp and Clojure/EDN printers, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 9404763e11 042/185: Make sure Travis uses the right Emacs, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 29411e2103 045/185: Add a design document to share vision and collect feedback, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 0702332e5d 046/185: Merge branch 'master' of https://github.com/lambdaisland/clj-parse, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 553f8618e1 044/185: Rework `clj-parse-deftest` macro,
ELPA Syncer <=
- [nongnu] elpa/parseclj da89bf82a3 050/185: Allow colons inside symbols, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 81fe979450 051/185: Handle parsing of semicolon-based comments., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a424f87c1b 054/185: :#/# is a valid keyword. :::hello is not, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f34b8460a8 055/185: Correctly parse numbers in scientific notation, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6fe4ce6095 058/185: Add script to compare speed of edn.el and clj-parse.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7d70ee4c38 059/185: Add support for tagged literals, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4367db07aa 061/185: Move tests to tests/, bench to benchmark/, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 46570ce843 060/185: A # can be part of a symbol, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj fcd1a086f6 081/185: Rename clj-ast to parseclj-ast, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 987bd16a57 089/185: Position starts at 1, not at 0 (just like (point)), ELPA Syncer, 2021/12/28