aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEduardo Julian2015-08-29 23:17:27 -0400
committerEduardo Julian2015-08-29 23:17:27 -0400
commit196f56b83ed357169efb75b864f81f26c10641f1 (patch)
tree33a17c9f3e2058e14b08f10ab700990447b510ac /test
parent253d5a4a3f7ef5d42c467733e394a28d18a4d9b3 (diff)
- Remove the (unnec) "All'" and "->'" macros.
- Improved the "struct" macro so that (once again) it doesn't ask for the prefixes of the members. - Added tests for the lux.reader namespace.
Diffstat (limited to 'test')
-rw-r--r--test/test/lux/reader.clj57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/test/lux/reader.clj b/test/test/lux/reader.clj
new file mode 100644
index 000000000..9b4954c5a
--- /dev/null
+++ b/test/test/lux/reader.clj
@@ -0,0 +1,57 @@
+(ns text.lux.reader
+ (:use clojure.test)
+ (:require (lux [base :as & :refer [deftags |do return* return fail fail* |let |case]]
+ [reader :as &reader])
+ :reload-all))
+
+;; [Utils]
+(def source (&reader/from "yolo" "lol\nmeme\nnyan cat\n\nlolcat"))
+(def init-state (&/set$ &/$source source (&/init-state nil)))
+
+;; [Tests]
+(deftest test-source-code-reading
+ (is (= 4 (&/|length source))))
+
+(deftest test-text-reading
+ ;; Should be capable of recognizing literal texts.
+ (let [input "lo"]
+ (|case (&/run-state (&reader/read-text input) init-state)
+ (&/$Right state [cursor output])
+ (is (= input output))
+
+ _
+ (is false "Couldn't read.")
+ )))
+
+(deftest test-regex-reading
+ ;; Should be capable of matching simple, grouping regex-patterns.
+ (|case (&/run-state (&reader/read-regex #"l(.)l") init-state)
+ (&/$Right state [cursor output])
+ (is (= "lol" "lol"))
+
+ _
+ (is false "Couldn't read.")
+ ))
+
+(deftest test-regex2-reading
+ ;; Should be capable of matching double, grouping regex-patterns.
+ (|case (&/run-state (&reader/read-regex2 #"(.)(..)") init-state)
+ (&/$Right state [cursor [left right]])
+ (is (and (= "l" left)
+ (= "ol" right)))
+
+ _
+ (is false "Couldn't read.")
+ ))
+
+(deftest test-regex+-reading
+ ;; Should be capable of matching multi-line regex-patterns.
+ (|case (&/run-state (&reader/read-regex+ #"(?is)^(.*?)(cat|$)") init-state)
+ (&/$Right state [cursor output])
+ (is (= "lol\nmeme\nnyan " output))
+
+ _
+ (is false "Couldn't read.")
+ ))
+
+;; (run-all-tests)