[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/parseclj a83816010e 039/185: Refactor clj-parse-test.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/parseclj a83816010e 039/185: Refactor clj-parse-test. |
Date: |
Tue, 28 Dec 2021 14:05:12 -0500 (EST) |
branch: elpa/parseclj
commit a83816010e628d805c4c25d7a2a2c7a6d394394c
Author: Daniel Barreto <dbarreto@talpor.com>
Commit: Daniel Barreto <dbarreto@talpor.com>
Refactor clj-parse-test.
All tests are separated now.
---
clj-parse-test.el | 253 ++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 178 insertions(+), 75 deletions(-)
diff --git a/clj-parse-test.el b/clj-parse-test.el
index 90e385fad7..9fd41ab9a2 100644
--- a/clj-parse-test.el
+++ b/clj-parse-test.el
@@ -25,81 +25,184 @@
(require 'clj-parse)
(require 'ert)
-(ert-deftest clj-parse-test ()
- (with-temp-buffer
- (insert "(1 2 3)")
- (goto-char 1)
- (should (equal (clj-parse) '((1 2 3)))))
-
- (with-temp-buffer
- (insert "()")
- (goto-char 1)
- (should (equal (clj-parse) '(()))))
-
- (with-temp-buffer
- (insert "(1)")
- (goto-char 1)
- (should (equal (clj-parse) '((1)))))
-
- (with-temp-buffer
- (insert "(nil true false hello-world)")
- (goto-char 1)
- (should (equal (clj-parse) '((nil t nil hello-world)))))
-
- (with-temp-buffer
- (insert "clojure.string/join")
- (goto-char 1)
- (should (equal (clj-parse) '(clojure.string/join))))
-
- (with-temp-buffer
- (insert "((.9 abc (true) (hello)))")
- (goto-char 1)
- (should (equal (clj-parse) '(((0.9 abc (t) (hello)))))))
-
- (with-temp-buffer
- (insert "\"abc hello \\t\\\"x\"")
- (goto-char 1)
- (should (equal (clj-parse) '("abc hello \t\"x"))))
-
- (with-temp-buffer
- (insert "(\"---\\f---\\\"-'\\'-\\\\-\\r\\n\")")
- (goto-char 1)
- (should (equal (clj-parse) '(("---\f---\"-''-\\-\r\n")))))
-
- (with-temp-buffer
- (insert "(\\newline \\return \\space \\tab \\a \\b \\c \\u0078 \\o171)")
- (goto-char 1)
- (should (equal (clj-parse) '((?\n ?\r ?\ ?\t ?a ?b ?c ?x ?y)))))
-
- (with-temp-buffer
- (insert "\"\\u0078 \\o171\"")
- (goto-char 1)
- (should (equal (clj-parse) '("x y"))))
-
- (with-temp-buffer
- (insert ":foo-bar")
- (goto-char 1)
- (should (equal (clj-parse) '(:foo-bar))))
-
- (with-temp-buffer
- (insert "[123]")
- (goto-char 1)
- (should (equal (clj-parse) '([123]))))
-
- (with-temp-buffer
- (insert "{:count 123}")
- (goto-char 1)
- (should (equal (clj-parse) '(((:count . 123))))))
-
- (with-temp-buffer
- (insert "#{:x}")
- (goto-char 1)
- (should (equal (clj-parse) '((:x)))))
-
- (with-temp-buffer
- (insert "(10 #_11 12 #_#_ 13 14)")
- (goto-char 1)
- (should (equal (clj-parse) '((10 12))))))
+(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)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 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)))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 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)")
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 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)))))))))
(provide 'clj-parse-test)
- [nongnu] elpa/parseclj f5f7ec1660 173/185: Release v1.0.1, (continued)
- [nongnu] elpa/parseclj f5f7ec1660 173/185: Release v1.0.1, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj b34d3e13a2 156/185: Support eval #=(foo...) forms, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj d659079598 174/185: Remove the remaining a.el dependency from non-test code, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 507720a632 170/185: Release 1.0, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 6d1c9c348a 184/185: Update CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 61513d2c99 164/185: Merge pull request #27 from clojure-emacs/shebang-and-symbolic-values, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj e6bce85062 159/185: Update the CHANGELOG, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1f7fe675ae 172/185: Merge pull request #31 from clojure-emacs/remove-a-el-part-2, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a8c4cf30fb 185/185: Correctly bump versions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 7ae887b1de 037/185: Refactor clj-parse.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a83816010e 039/185: Refactor clj-parse-test.,
ELPA Syncer <=
- [nongnu] elpa/parseclj 9d4c0b7b4b 041/185: Merge pull request #2 from volrath/tag-support, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 879ac980a8 056/185: Treat numbers with trailing symbol characters as lex errors, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 2781f0cd7f 088/185: Vocab chage: closer/opener => closing-token/opening-token, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 4fc37462ab 073/185: Make Travis use Cask, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj a71e57df4d 080/185: Rename clj-lex to parseclj-lex, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 168027fed5 094/185: Merge pull request #7 from lambdaisland/reorganize-package, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 45bd6a7431 109/185: Clean up tests, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 1f8e449897 105/185: Simplify error messages, ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj f362018ff1 112/185: Silence the byte-compiler about some unused vars., ELPA Syncer, 2021/12/28
- [nongnu] elpa/parseclj 70804992ee 122/185: Merge pull request #14 from lambdaisland/parseclj-lex-symbol-fix, ELPA Syncer, 2021/12/28