summaryrefslogtreecommitdiff
path: root/tests/regmin.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regmin.test')
-rw-r--r--tests/regmin.test55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/regmin.test b/tests/regmin.test
new file mode 100644
index 0000000..ed4f1cd
--- /dev/null
+++ b/tests/regmin.test
@@ -0,0 +1,55 @@
+source [file dirname [info script]]/testing.tcl
+
+needs cmd regexp
+testConstraint regexp_are [regexp {\d} 1]
+needs constraint regexp_are
+
+test regexpmin-1.1 {Minimal +} {
+ regexp -inline {x(a|b|c)+?c} xabcabc
+} {xabc b}
+
+test regexpmin-1.2 {Maximal +} {
+ regexp -inline {x(a|b|c)+c} xabcabc
+} {xabcabc b}
+
+test regexpmin-1.3 {Minimal *} {
+ regexp -inline {x(a|b)*?} xababcabc
+} {x {}}
+
+test regexpmin-1.4 {Maximal *} {
+ regexp -inline {x(a|b)*} xababcabc
+} {xabab b}
+
+test regexpmin-1.5 {Maximal ?} {
+ regexp -inline {x(a|b)?} xababcabc
+} {xa a}
+
+test regexpmin-1.6 {Minimal ?} {
+ regexp -inline {x(a|b)??} xababcabc
+} {x {}}
+
+test regexpmin-1.7 {Maximal html} {
+ regexp -inline {<(.+)>} <foo><bar><grill>
+} {<foo><bar><grill> foo><bar><grill}
+
+test regexpmin-1.8 {Minimal html} {
+ regexp -inline {<(.+?)>} <foo><bar><grill>
+} {<foo> foo}
+
+test regexpmin-2.1 {utf8 repeat} utf8 {
+ regexp -inline {a\u00df+} a\udf\udf\udf\udf\ub5z
+} "a\udf\udf\udf\udf"
+
+test regexpmin-2.2 {utf8 min repeat} utf8 {
+ regexp -inline {a\u00df+?} a\udf\udf\udf\udf\ub5z
+} "a\udf"
+
+test regexpmin-3.1 {non-capturing paren} {
+ regexp -inline {x(?:a|b)?} xababcabc
+} {xa}
+
+test regexpmin-3.2 {non-capturing paren} {
+ regexp -inline {x(?:a|b)?.*(b|c)} xababcabc
+} {xababcabc c}
+
+testreport