aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
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/test
parente32a74c4c7a4e9b6b61b20f3ac62149eb649bdd5 (diff)
- Improved the way tests are run.
- Refactored lux/regex tests a bit.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/regex.lux45
-rw-r--r--stdlib/test/tests.lux2
2 files changed, 31 insertions, 16 deletions
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]