aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2016-12-19 01:05:23 -0400
committerEduardo Julian2016-12-19 01:05:23 -0400
commitd81fa78b72070b05ee9575ee26c54f949f551182 (patch)
treefbc7cc780051d6976b553f74e053dddb6ec124eb /stdlib
parente32a74c4c7a4e9b6b61b20f3ac62149eb649bdd5 (diff)
- Improved the way tests are run.
- Refactored lux/regex tests a bit.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/test.lux40
-rw-r--r--stdlib/test/test/lux/regex.lux45
-rw-r--r--stdlib/test/tests.lux2
3 files changed, 52 insertions, 35 deletions
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index bb5fe1aad..f08e91336 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -48,22 +48,22 @@
(def: #hidden (run' tests)
(-> (List [Text (IO Test) Text]) (Promise Unit))
(do Monad<Promise>
- [printings (mapM @
- (: (-> [Text (IO Test) Text] (Promise Unit))
- (lambda [[module test description]]
- (do @
- [#let [pre (io;run (System.currentTimeMillis []))]
- outcome (io;run test)
- #let [post (io;run (System.currentTimeMillis []))]]
- (case outcome
- (#;Left error)
- (wrap (log! (format "Error: " (:: text;Codec<Text,Text> encode description) " @ " module "\n" error "\n")))
-
- _
- (exec (log! (format "Success: " (:: text;Codec<Text,Text> encode description) " @ " module
- " in " (%i (i.- pre post)) "ms"))
- (wrap []))))))
- tests)]
+ [#let [printings (List/map (: (-> [Text (IO Test) Text] (Promise Unit))
+ (lambda [[module test description]]
+ (do @
+ [#let [pre (io;run (System.currentTimeMillis []))]
+ outcome (io;run test)
+ #let [post (io;run (System.currentTimeMillis []))]
+ #let [description+ (:: text;Codec<Text,Text> encode description)]]
+ (case outcome
+ (#;Left error)
+ (wrap (log! (format "Error: " description+ " @ " module "\n" error "\n")))
+
+ _
+ (exec (log! (format "Success: " description+ " @ " module " in " (%i (i.- pre post)) "ms"))
+ (wrap []))))))
+ tests)]
+ _ (seqM @ printings)]
(wrap [])))
(def: pcg-32-magic-inc Nat +12345)
@@ -197,12 +197,14 @@
[current-module compiler;current-module-name
modules (compiler;imported-modules current-module)
tests (: (Lux (List [Text Text Text]))
- (:: @ map List/join (mapM @ exported-tests (#;Cons current-module modules))))
+ (|> (#;Cons current-module modules)
+ list;reverse
+ (mapM @ exported-tests)
+ (:: @ map List/join)))
#let [tests+ (List/map (lambda [[module-name test desc]]
(` [(~ (ast;text module-name)) (~ (ast;symbol [module-name test])) (~ (ast;text desc))]))
tests)
- groups (list;split-all (|> (list;size tests+) (n./ promise;concurrency-level) (n.+ +1) (n.min +16))
- tests+)]]
+ groups (list;split-all promise;concurrency-level tests+)]]
(wrap (list (` (: (IO Unit)
(io (exec (do Monad<Promise>
[(~@ (List/join (List/map (lambda [group]
diff --git a/stdlib/test/test/lux/regex.lux b/stdlib/test/test/lux/regex.lux
index bb366ac90..e8ff5f8cf 100644
--- a/stdlib/test/test/lux/regex.lux
+++ b/stdlib/test/test/lux/regex.lux
@@ -68,7 +68,7 @@
(assert "Can parse digits."
(and (should-pass (&;regex "\\d") "0")
(should-fail (&;regex "\\d") "m")))
-
+
(assert "Can parse non digits."
(and (should-pass (&;regex "\\D") "m")
(should-fail (&;regex "\\D") "0")))
@@ -76,7 +76,7 @@
(assert "Can parse white-space."
(and (should-pass (&;regex "\\s") " ")
(should-fail (&;regex "\\s") "m")))
-
+
(assert "Can parse non white-space."
(and (should-pass (&;regex "\\S") "m")
(should-fail (&;regex "\\S") " ")))
@@ -84,11 +84,14 @@
(assert "Can parse word characters."
(and (should-pass (&;regex "\\w") "_")
(should-fail (&;regex "\\w") "^")))
-
+
(assert "Can parse non word characters."
(and (should-pass (&;regex "\\W") ".")
(should-fail (&;regex "\\W") "a")))
+ ))
+(test: "Regular Expressions [Special system character classes]"
+ ($_ seq
(assert "Can parse using special character classes."
(and (and (should-pass (&;regex "\\p{Lower}") "m")
(should-fail (&;regex "\\p{Lower}") "M"))
@@ -133,7 +136,7 @@
(should-fail (&;regex "\\p{Print}") "\u1234"))))
))
-(test: "Regular Expressions [Custom character classes]"
+(test: "Regular Expressions [Custom character classes : Part 1]"
($_ seq
(assert "Can parse using custom character classes."
(and (should-pass (&;regex "[abc]") "a")
@@ -151,7 +154,10 @@
(should-pass (&;regex "[a-zA-Z]") "A")
(should-pass (&;regex "[a-zA-Z]") "M")
(should-pass (&;regex "[a-zA-Z]") "Z")))
+ ))
+(test: "Regular Expressions [Custom character classes : Part 2]"
+ ($_ seq
(assert "Can negate custom character classes."
(and (should-fail (&;regex "[^abc]") "a")
(should-pass (&;regex "[^abc]") "m")))
@@ -159,21 +165,27 @@
(assert "Can negate character ranges.."
(and (should-fail (&;regex "[^a-z]") "a")
(should-pass (&;regex "[^a-z]") "0")))
-
+
(assert "Can parse negate combinations of character ranges."
(and (should-fail (&;regex "[^a-zA-Z]") "a")
(should-pass (&;regex "[^a-zA-Z]") "0")))
+ ))
+(test: "Regular Expressions [Custom character classes : Part 3]"
+ ($_ seq
(assert "Can make custom character classes more specific."
- (and (and (should-fail (&;regex "[a-z&&[def]]") "a")
- (should-pass (&;regex "[a-z&&[def]]") "d"))
-
- (and (should-pass (&;regex "[a-z&&[^bc]]") "a")
- (should-fail (&;regex "[a-z&&[^bc]]") "b"))
-
- (and (should-pass (&;regex "[a-z&&[^m-p]]") "a")
- (should-fail (&;regex "[a-z&&[^m-p]]") "m")
- (should-fail (&;regex "[a-z&&[^m-p]]") "p"))))
+ (and (let [RE (&;regex "[a-z&&[def]]")]
+ (and (should-fail RE "a")
+ (should-pass RE "d")))
+
+ (let [RE (&;regex "[a-z&&[^bc]]")]
+ (and (should-pass RE "a")
+ (should-fail RE "b")))
+
+ (let [RE (&;regex "[a-z&&[^m-p]]")]
+ (and (should-pass RE "a")
+ (should-fail RE "m")
+ (should-fail RE "p")))))
))
(test: "Regular Expressions [Reference]"
@@ -181,7 +193,7 @@
(assert "Can build complex regexs by combining simpler ones."
(should-check ["809-345-6789" "809" "345" "6789"] (&;regex "(\\@<number>)-(\\@<number>)-(\\@<number>)") "809-345-6789"))))
-(test: "Regular Expressions [Quantifiers]"
+(test: "Regular Expressions [Fuzzy Quantifiers]"
($_ seq
(assert "Can sequentially combine patterns."
(should-passT "aa" (&;regex "aa") "aa"))
@@ -198,7 +210,10 @@
(and (should-passT "aaa" (&;regex "a+") "aaa")
(should-passT "a" (&;regex "a+") "a")
(should-fail (&;regex "a+") "")))
+ ))
+(test: "Regular Expressions [Specific Quantifiers]"
+ ($_ seq
(assert "Can match a pattern N times."
(and (should-passT "aa" (&;regex "a{2}") "aa")
(should-passT "a" (&;regex "a{1}") "aa")
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index fba3e139f..c5c7fd934 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -57,7 +57,7 @@
## ["_;" random]
["_;" simple]
)
- ## [macro]
+ ## ["_;" macro]
(macro ["_;" ast]
["_;" syntax]
["_;" template]