diff options
Diffstat (limited to 'stdlib/source/test/lux/data/text/regex.lux')
-rw-r--r-- | stdlib/source/test/lux/data/text/regex.lux | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index 83d2cfcc4..f72c19030 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -1,8 +1,8 @@ (.module: [lux #* - ["%" data/text/format (#+ format)] ["_" test (#+ Test)] - [abstract/monad (#+ do)] + [abstract + [monad (#+ do)]] [control pipe ["." try] @@ -11,9 +11,10 @@ ["s" code]]] [data [number (#+ hex)] - ["." text ("#\." equivalence)]] + ["." text ("#\." equivalence) + ["%" format (#+ format)]]] [math - ["r" random]] + ["." random]] ["." meta] [macro [syntax (#+ syntax:)]]] @@ -57,13 +58,8 @@ (case> (^ (#try.Success (~ pattern))) true - (#try.Failure (~ g!message)) - (exec (log! (format "{{{Failure}}} " (~ g!message))) - false) - (~ g!_) - (exec (log! (format "{{{Success}}} " "OH NO")) - false)))))))) + false))))))) (def: basics Test @@ -273,36 +269,34 @@ "123-456-7890"))) )) -(def: pattern-matching - Test - (do r.monad - [sample1 (r.unicode 3) - sample2 (r.unicode 3) - sample3 (r.unicode 4)] - (case (format sample1 "-" sample2 "-" sample3) - (/.^regex "(.{3})-(.{3})-(.{4})" - [_ match1 match2 match3]) - (_.test "Can pattern-match using regular-expressions." - (and (text\= sample1 match1) - (text\= sample2 match2) - (text\= sample3 match3))) - - _ - (_.test "Cannot pattern-match using regular-expressions." - #0)))) - (def: #export test Test - (<| (_.context (%.name (name-of /.regex))) + (<| (_.covering /._) ($_ _.and - ..basics - ..system-character-classes - ..special-system-character-classes - ..custom-character-classes - ..references - ..fuzzy-quantifiers - ..crisp-quantifiers - ..groups - ..alternation - ..pattern-matching + (_.for [/.regex] + ($_ _.and + ..basics + ..system-character-classes + ..special-system-character-classes + ..custom-character-classes + ..references + ..fuzzy-quantifiers + ..crisp-quantifiers + ..groups + ..alternation + )) + (do random.monad + [sample1 (random.unicode 3) + sample2 (random.unicode 3) + sample3 (random.unicode 4)] + (_.cover [/.^regex] + (case (format sample1 "-" sample2 "-" sample3) + (/.^regex "(.{3})-(.{3})-(.{4})" + [_ match1 match2 match3]) + (and (text\= sample1 match1) + (text\= sample2 match2) + (text\= sample3 match3)) + + _ + false))) ))) |