aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-04-01 18:38:42 -0400
committerEduardo Julian2017-04-01 18:38:42 -0400
commit129865dc11ee4441b71fe3e8539c01634f2f1df0 (patch)
treec180706df7f81308274abaa844c90591908b73ef /stdlib/test
parentae7c062bdf4ab8337f0eedae78b38df24e62822c (diff)
- Added a macro for pattern-matching using regular-expressions.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/lexer/regex.lux16
1 files changed, 16 insertions, 0 deletions
diff --git a/stdlib/test/test/lux/lexer/regex.lux b/stdlib/test/test/lux/lexer/regex.lux
index c5c21df2a..1a21111f8 100644
--- a/stdlib/test/test/lux/lexer/regex.lux
+++ b/stdlib/test/test/lux/lexer/regex.lux
@@ -267,3 +267,19 @@
(&;regex "(\\d{3})-((\\d{3})-(\\d{4}))|b(.)d")
"809-345-6789")))
))
+
+(test: "Pattern-matching"
+ [sample1 (R;text +3)
+ sample2 (R;text +3)
+ sample3 (R;text +4)]
+ (case (format sample1 "-" sample2 "-" sample3)
+ (&;^regex "(.{3})-(.{3})-(.{4})"
+ [_ match1 match2 match3])
+ (assert "Can pattern-match using regular-expressions."
+ (and (T/= sample1 match1)
+ (T/= sample2 match2)
+ (T/= sample3 match3)))
+
+ _
+ (assert "Cannot pattern-match using regular-expressions."
+ false)))