--- a/RegressionTests__RxTests.st Wed Oct 18 11:14:29 2017 +0200
+++ b/RegressionTests__RxTests.st Wed Oct 18 11:25:43 2017 +0200
@@ -16,7 +16,7 @@
documentation to be added.
[author:]
- Claus Gittinger (cg@alan)
+ Claus Gittinger (cg@alan)
[instance variables:]
@@ -49,24 +49,24 @@
!
frequentMatchProfile
- "
- TimeProfiler profile: [self frequentMatchProfile]
- Time millisecondsToRun: [self frequentMatchProfile]
- "
-
- | stream matcher count |
- stream := self bigHonkingStream.
- count := 0.
- matcher := '\<\w+' asRegex.
- [
- [matcher searchStream: stream] whileTrue: [count := count + 1].
- ]
- valueNowOrOnUnwindDo: [stream close].
- ^count
+ "
+ TimeProfiler profile: [self frequentMatchProfile]
+ Time millisecondsToRun: [self frequentMatchProfile]
+ "
+
+ | stream matcher count |
+ stream := self bigHonkingStream.
+ count := 0.
+ matcher := '\<\w+' asRegex.
+ [
+ [matcher searchStream: stream] whileTrue: [count := count + 1].
+ ]
+ valueNowOrOnUnwindDo: [stream close].
+ ^count
!
rareMatchProfile
- "
+ " o:Regex::RxMatcher
TimeProfiler profile: [self rareMatchProfile]
Time millisecondsToRun: [self rareMatchProfile]
"
@@ -110,11 +110,11 @@
abc xabcy y & abc
abc ababc y & abc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'abc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'abc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
self should:[ (matcher search:'xbc') = false ].
@@ -134,11 +134,11 @@
"patt. input match-expected matched-expression
ab*c abc y & abc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab*c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab*c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
@@ -153,11 +153,11 @@
ab*bc abbc y & abbc
ab*bc abbbbc y & abbbbc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab*bc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab*bc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
self should:[ (matcher search:'abbc') = true ].
@@ -177,11 +177,11 @@
ab+bc abq n - -
ab+bc abbbbc y & abbbbc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab+bc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab+bc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abbc') = true ].
self should:[ (matcher subexpression:1) = 'abbc' ].
self should:[ (matcher search:'abc') = false ].
@@ -200,11 +200,11 @@
ab?bc abc y & abc
ab?bc abbbbc n - -
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab?bc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab?bc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abbc') = true ].
self should:[ (matcher subexpression:1) = 'abbc' ].
self should:[ (matcher search:'abc') = true ].
@@ -220,11 +220,11 @@
"patt. input match-expected matched-expression
ab?c abc y & abc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab?c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab?c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
@@ -239,11 +239,11 @@
^abc$ abcc n - -
^abc$ aabc n - -
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'^abc$' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'^abc$' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
self should:[ (matcher search:'abcc') = false ].
@@ -258,11 +258,11 @@
"patt. input match-expected matched-expression
^abc abcc y & abc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'^abc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'^abc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abcc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
@@ -275,11 +275,11 @@
"patt. input match-expected matched-expression
abc$ aabc y & abc
"
-
+
|matcher|
- self
- should:[ (matcher := self compileRegex:'abc$' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'abc$' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aabc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
@@ -290,12 +290,12 @@
test009
"patt. input match-expected matched-expression
- ^ abc y &
+ ^ abc y &
"
-
+
|matcher|
- self should:[ (matcher := self compileRegex:'^' into:RxMatcher) ~= nil ].
+ self should:[ (matcher := self compileRegex:'^' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
"
@@ -305,12 +305,12 @@
test010
"patt. input match-expected matched-expression
- $ abc y &
+ $ abc y &
"
-
+
|matcher|
- self should:[ (matcher := self compileRegex:'$' into:RxMatcher) ~= nil ].
+ self should:[ (matcher := self compileRegex:'$' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
"
@@ -321,8 +321,8 @@
test011
|matcher|
- self
- should:[ (matcher := self compileRegex:'a.c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a.c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
self should:[ (matcher search:'axc') = true ].
@@ -332,26 +332,26 @@
test012
|matcher|
- self
- should:[ (matcher := self compileRegex:'a.*c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a.*c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'axyzc') = true ].
self should:[ (matcher subexpression:1) = 'axyzc' ].
self should:[ (matcher search:'axy zc') = true ].
self should:[ (matcher subexpression:1) = 'axy zc' ].
- self
- should:[
- (matcher search:'axy
- zc')
- = false
- ].
+ self
+ should:[
+ (matcher search:'axy
+ zc')
+ = false
+ ].
self should:[ (matcher search:'axyzd') = false ].
!
test013
|matcher|
- self
- should:[ (matcher := self compileRegex:'.a.*' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'.a.*' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'1234abc') = true ].
self should:[ (matcher subexpression:1) = '4abc' ].
self should:[ (matcher search:'abcd') = false ].
@@ -360,8 +360,8 @@
test014
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\w+c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\w+c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' abbbbc ') = true ].
self should:[ (matcher subexpression:1) = 'abbbbc' ].
self should:[ (matcher search:'abb bc') = false ].
@@ -370,8 +370,8 @@
test015
|matcher|
- self
- should:[ (matcher := self compileRegex:'\w+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\w+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' foobar quux') = true ].
self should:[ (matcher subexpression:1) = 'foobar' ].
self should:[ (matcher search:' ~!!@#$%^&*()-+=\|/?.>,<') = false ].
@@ -380,8 +380,8 @@
test016
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\W+c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\W+c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a c') = true ].
self should:[ (matcher subexpression:1) = 'a c' ].
self should:[ (matcher search:'a bc') = false ].
@@ -390,8 +390,8 @@
test017
|matcher|
- self
- should:[ (matcher := self compileRegex:'\W+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\W+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'foo!!@#$bar') = true ].
self should:[ (matcher subexpression:1) = '!!@#$' ].
self should:[ (matcher search:'foobar') = false ].
@@ -400,8 +400,8 @@
test018
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\s*c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\s*c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a c') = true ].
self should:[ (matcher subexpression:1) = 'a c' ].
self should:[ (matcher search:'a bc') = false ].
@@ -410,8 +410,8 @@
test019
|matcher|
- self
- should:[ (matcher := self compileRegex:'\s+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\s+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc3457 sd') = true ].
self should:[ (matcher subexpression:1) = ' ' ].
self should:[ (matcher search:'1234$^*^&asdfb') = false ].
@@ -420,8 +420,8 @@
test020
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\S*c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\S*c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aqwertyc') = true ].
self should:[ (matcher subexpression:1) = 'aqwertyc' ].
self should:[ (matcher search:'ab c') = false ].
@@ -430,20 +430,20 @@
test021
|matcher|
- self
- should:[ (matcher := self compileRegex:'\S+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\S+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' asdf ') = true ].
self should:[ (matcher subexpression:1) = 'asdf' ].
- self
- should:[ (matcher search:'
- ') = false ].
+ self
+ should:[ (matcher search:'
+ ') = false ].
!
test022
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\d+c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\d+c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a0123456789c') = true ].
self should:[ (matcher subexpression:1) = 'a0123456789c' ].
self should:[ (matcher search:'a12b34c') = false ].
@@ -452,8 +452,8 @@
test023
|matcher|
- self
- should:[ (matcher := self compileRegex:'\d+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\d+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'foo@#$%123ASD #$$%^&') = true ].
self should:[ (matcher subexpression:1) = '123' ].
self should:[ (matcher search:'foo!!@#$asdfl;') = false ].
@@ -462,8 +462,8 @@
test024
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\D+c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\D+c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aqwertyc') = true ].
self should:[ (matcher subexpression:1) = 'aqwertyc' ].
self should:[ (matcher search:'aqw6ertc') = false ].
@@ -472,8 +472,8 @@
test025
|matcher|
- self
- should:[ (matcher := self compileRegex:'\D+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\D+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'1234 abc 456') = true ].
self should:[ (matcher subexpression:1) = ' abc ' ].
self should:[ (matcher search:'1234567890') = false ].
@@ -482,8 +482,8 @@
test026
|matcher|
- self
- should:[ (matcher := self compileRegex:'(f|o)+\b' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(f|o)+\b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'foo') = true ].
self should:[ (matcher subexpression:1) = 'foo' ].
self should:[ (matcher search:' foo ') = true ].
@@ -493,8 +493,8 @@
test027
|matcher|
- self
- should:[ (matcher := self compileRegex:'\ba\w+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\ba\w+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'land ancient') = true ].
self should:[ (matcher subexpression:1) = 'ancient' ].
self should:[ (matcher search:'antique vase') = true ].
@@ -505,8 +505,8 @@
test028
|matcher|
- self
- should:[ (matcher := self compileRegex:'(f|o)+\B' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(f|o)+\B' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'quuxfoobar') = true ].
self should:[ (matcher subexpression:1) = 'foo' ].
self should:[ (matcher search:'quuxfoo ') = true ].
@@ -516,8 +516,8 @@
test029
|matcher|
- self
- should:[ (matcher := self compileRegex:'\Ba\w+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\Ba\w+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'land ancient') = true ].
self should:[ (matcher subexpression:1) = 'and' ].
self should:[ (matcher search:'antique vase') = true ].
@@ -530,8 +530,8 @@
test030
|matcher|
- self
- should:[ (matcher := self compileRegex:'fooa\>.*' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'fooa\>.*' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'fooa ') = true ].
self should:[ (matcher search:'fooa123') = false ].
self should:[ (matcher search:'fooa bar') = true ].
@@ -542,8 +542,8 @@
test031
|matcher|
- self
- should:[ (matcher := self compileRegex:'\>.+abc' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\>.+abc' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' abcde fg') = false ].
self should:[ (matcher search:'foo abcde') = true ].
self should:[ (matcher subexpression:1) = ' abc' ].
@@ -553,8 +553,8 @@
test032
|matcher|
- self
- should:[ (matcher := self compileRegex:'\<foo.*' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'\<foo.*' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'foo') = true ].
self should:[ (matcher search:'foobar') = true ].
self should:[ (matcher search:'qfoobarq foonix') = true ].
@@ -567,8 +567,8 @@
test033
|matcher|
- self
- should:[ (matcher := self compileRegex:'.+\<foo' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'.+\<foo' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'foo') = false ].
self should:[ (matcher search:'ab foo') = true ].
self should:[ (matcher subexpression:1) = 'ab foo' ].
@@ -578,8 +578,8 @@
test034
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[bc]d' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[bc]d' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = false ].
self should:[ (matcher search:'abd') = true ].
self should:[ (matcher subexpression:1) = 'abd' ].
@@ -588,8 +588,8 @@
test035
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[b-d]e' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[b-d]e' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abd') = false ].
self should:[ (matcher search:'ace') = true ].
self should:[ (matcher subexpression:1) = 'ace' ].
@@ -598,8 +598,8 @@
test036
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[b-d]' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[b-d]' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aac') = true ].
self should:[ (matcher subexpression:1) = 'ac' ].
!
@@ -607,8 +607,8 @@
test037
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[-b]' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[-b]' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a-') = true ].
self should:[ (matcher subexpression:1) = 'a-' ].
!
@@ -616,8 +616,8 @@
test038
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[b-]' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[b-]' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a-') = true ].
self should:[ (matcher subexpression:1) = 'a-' ].
!
@@ -625,42 +625,42 @@
test039
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[a-b-c]' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[a-b-c]' into:Regex::RxMatcher) = nil ].
!
test040
|matcher|
- self
- should:[ (matcher := self compileRegex:'[k]' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[k]' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'ab') = false ].
!
test041
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[b-a]' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[b-a]' into:Regex::RxMatcher) = nil ].
!
test042
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[]b' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[]b' into:Regex::RxMatcher) = nil ].
!
test043
|matcher|
- self should:[ (matcher := self compileRegex:'a[' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'a[' into:Regex::RxMatcher) = nil ].
!
test044
|matcher|
- self should:[ (matcher := self compileRegex:'a]' into:RxMatcher) ~= nil ].
+ self should:[ (matcher := self compileRegex:'a]' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a]') = true ].
self should:[ (matcher subexpression:1) = 'a]' ].
!
@@ -668,8 +668,8 @@
test045
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[]]b' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[]]b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a]b') = true ].
self should:[ (matcher subexpression:1) = 'a]b' ].
!
@@ -677,8 +677,8 @@
test046
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[^bc]d' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[^bc]d' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aed') = true ].
self should:[ (matcher subexpression:1) = 'aed' ].
self should:[ (matcher search:'abd') = false ].
@@ -687,8 +687,8 @@
test047
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[^-b]c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[^-b]c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'adc') = true ].
self should:[ (matcher subexpression:1) = 'adc' ].
self should:[ (matcher search:'a-c') = false ].
@@ -697,8 +697,8 @@
test048
|matcher|
- self
- should:[ (matcher := self compileRegex:'a[^]b]c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a[^]b]c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a]c') = false ].
self should:[ (matcher search:'adc') = true ].
self should:[ (matcher subexpression:1) = 'adc' ].
@@ -707,8 +707,8 @@
test049
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\de]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\de]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'01234') = true ].
self should:[ (matcher subexpression:1) = '01234' ].
self should:[ (matcher search:'0123e456') = true ].
@@ -720,8 +720,8 @@
test050
|matcher|
- self
- should:[ (matcher := self compileRegex:'[e\d]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[e\d]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'01234') = true ].
self should:[ (matcher subexpression:1) = '01234' ].
self should:[ (matcher search:'0123e456') = true ].
@@ -733,8 +733,8 @@
test051
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\D]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\D]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'123abc45def78') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
!
@@ -742,8 +742,8 @@
test052
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:digit:]e]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:digit:]e]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'01234') = true ].
self should:[ (matcher subexpression:1) = '01234' ].
self should:[ (matcher search:'0123e456') = true ].
@@ -755,8 +755,8 @@
test053
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\s]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\s]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'2 spaces') = true ].
self should:[ (matcher subexpression:1) = ' ' ].
!
@@ -764,8 +764,8 @@
test054
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\S]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\S]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' word12!!@#$ ') = true ].
self should:[ (matcher subexpression:1) = 'word12!!@#$' ].
!
@@ -773,8 +773,8 @@
test055
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\w]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\w]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' foo123bar 45') = true ].
self should:[ (matcher subexpression:1) = 'foo123bar' ].
!
@@ -782,8 +782,8 @@
test056
|matcher|
- self
- should:[ (matcher := self compileRegex:'[\W]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[\W]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'fii234!!@#$34f') = true ].
self should:[ (matcher subexpression:1) = '!!@#$' ].
!
@@ -791,8 +791,8 @@
test057
|matcher|
- self
- should:[ (matcher := self compileRegex:'[^[:alnum:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[^[:alnum:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'fii234!!@#$34f') = true ].
self should:[ (matcher subexpression:1) = '!!@#$' ].
!
@@ -800,10 +800,10 @@
test058
|matcher|
- self
- should:[
- (matcher := self compileRegex:'[%&[:alnum:]]+' into:RxMatcher) ~= nil
- ].
+ self
+ should:[
+ (matcher := self compileRegex:'[%&[:alnum:]]+' into:Regex::RxMatcher) ~= nil
+ ].
self should:[ (matcher search:'foo%3') = true ].
self should:[ (matcher subexpression:1) = 'foo%3' ].
self should:[ (matcher search:'foo34&rt4$57a') = true ].
@@ -814,8 +814,8 @@
test059
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:alpha:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:alpha:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' 123foo3 ') = true ].
self should:[ (matcher subexpression:1) = 'foo' ].
self should:[ (matcher search:'123foo') = true ].
@@ -827,16 +827,16 @@
test060
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:cntrl:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:cntrl:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' a 1234asdf') = false ].
!
test061
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:lower:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:lower:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'UPPERlower1234') = true ].
self should:[ (matcher subexpression:1) = 'lower' ].
self should:[ (matcher search:'lowerUPPER') = true ].
@@ -846,8 +846,8 @@
test062
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:upper:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:upper:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'UPPERlower1234') = true ].
self should:[ (matcher subexpression:1) = 'UPPER' ].
self should:[ (matcher search:'lowerUPPER ') = true ].
@@ -857,8 +857,8 @@
test063
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:space:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:space:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'2 spaces') = true ].
self should:[ (matcher subexpression:1) = ' ' ].
!
@@ -866,8 +866,8 @@
test064
|matcher|
- self
- should:[ (matcher := self compileRegex:'[^[:space:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[^[:space:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' word12!!@#$ ') = true ].
self should:[ (matcher subexpression:1) = 'word12!!@#$' ].
!
@@ -875,8 +875,8 @@
test065
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:graph:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:graph:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
!
@@ -884,8 +884,8 @@
test066
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:print:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:print:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
!
@@ -893,8 +893,8 @@
test067
|matcher|
- self
- should:[ (matcher := self compileRegex:'[^[:punct:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[^[:punct:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'!!hello,world!!') = true ].
self should:[ (matcher subexpression:1) = 'hello' ].
!
@@ -902,8 +902,8 @@
test068
|matcher|
- self
- should:[ (matcher := self compileRegex:'[[:xdigit:]]+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[[:xdigit:]]+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:' x10FCD ') = true ].
self should:[ (matcher subexpression:1) = '10FCD' ].
self should:[ (matcher search:' hgfedcba0123456789ABCDEFGH ') = true ].
@@ -913,8 +913,8 @@
test069
|matcher|
- self
- should:[ (matcher := self compileRegex:'ab|cd' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'ab|cd' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'ab' ].
self should:[ (matcher search:'abcd') = true ].
@@ -924,8 +924,8 @@
test070
|matcher|
- self
- should:[ (matcher := self compileRegex:'()ef' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'()ef' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'def') = true ].
self should:[ (matcher subexpression:1) = 'ef' ].
self should:[ (matcher subexpression:2) = '' ].
@@ -934,52 +934,52 @@
test071
|matcher|
- self should:[ (matcher := self compileRegex:'()*' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'()*' into:Regex::RxMatcher) = nil ].
!
test072
|matcher|
- self should:[ (matcher := self compileRegex:'*a' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'*a' into:Regex::RxMatcher) = nil ].
!
test073
|matcher|
- self should:[ (matcher := self compileRegex:'^*' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'^*' into:Regex::RxMatcher) = nil ].
!
test074
|matcher|
- self should:[ (matcher := self compileRegex:'$*' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'$*' into:Regex::RxMatcher) = nil ].
!
test075
|matcher|
- self
- should:[ (matcher := self compileRegex:'(*)b' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(*)b' into:Regex::RxMatcher) = nil ].
!
test076
|matcher|
- self should:[ (matcher := self compileRegex:'$b' into:RxMatcher) ~= nil ].
+ self should:[ (matcher := self compileRegex:'$b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'b') = false ].
!
test077
|matcher|
- self should:[ (matcher := self compileRegex:'a\' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'a\' into:Regex::RxMatcher) = nil ].
!
test078
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\(b' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\(b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a(b') = true ].
self should:[ (matcher subexpression:1) = 'a(b' ].
!
@@ -987,8 +987,8 @@
test079
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\(*b' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\(*b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'ab') = true ].
self should:[ (matcher subexpression:1) = 'ab' ].
self should:[ (matcher search:'a((b') = true ].
@@ -998,8 +998,8 @@
test080
|matcher|
- self
- should:[ (matcher := self compileRegex:'a\\b' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a\\b' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'a\b') = true ].
self should:[ (matcher subexpression:1) = 'a\b' ].
!
@@ -1007,22 +1007,22 @@
test081
|matcher|
- self
- should:[ (matcher := self compileRegex:'abc)' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'abc)' into:Regex::RxMatcher) = nil ].
!
test082
|matcher|
- self
- should:[ (matcher := self compileRegex:'(abc' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(abc' into:Regex::RxMatcher) = nil ].
!
test083
|matcher|
- self
- should:[ (matcher := self compileRegex:'((a))' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'((a))' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'a' ].
self should:[ (matcher subexpression:2) = 'a' ].
@@ -1032,8 +1032,8 @@
test084
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a)b(c)' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a)b(c)' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
self should:[ (matcher subexpression:2) = 'a' ].
@@ -1043,8 +1043,8 @@
test085
|matcher|
- self
- should:[ (matcher := self compileRegex:'a+b+c' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'a+b+c' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'aabbabc') = true ].
self should:[ (matcher subexpression:1) = 'abc' ].
!
@@ -1052,48 +1052,48 @@
test086
|matcher|
- self should:[ (matcher := self compileRegex:'a**' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'a**' into:Regex::RxMatcher) = nil ].
!
test087
|matcher|
- self should:[ (matcher := self compileRegex:'a*?' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:'a*?' into:Regex::RxMatcher) = nil ].
!
test088
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a*)*' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a*)*' into:Regex::RxMatcher) = nil ].
!
test089
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a*)+' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a*)+' into:Regex::RxMatcher) = nil ].
!
test090
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a|)*' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a|)*' into:Regex::RxMatcher) = nil ].
!
test091
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a*|b)*' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a*|b)*' into:Regex::RxMatcher) = nil ].
!
test092
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a+|b)*' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a+|b)*' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'ab') = true ].
self should:[ (matcher subexpression:1) = 'ab' ].
self should:[ (matcher subexpression:2) = 'b' ].
@@ -1102,8 +1102,8 @@
test093
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a+|b)+' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a+|b)+' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'ab') = true ].
self should:[ (matcher subexpression:1) = 'ab' ].
self should:[ (matcher subexpression:2) = 'b' ].
@@ -1112,8 +1112,8 @@
test094
|matcher|
- self
- should:[ (matcher := self compileRegex:'(a+|b)?' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'(a+|b)?' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'ab') = true ].
self should:[ (matcher subexpression:1) = 'a' ].
self should:[ (matcher subexpression:2) = 'a' ].
@@ -1122,8 +1122,8 @@
test095
|matcher|
- self
- should:[ (matcher := self compileRegex:'[^ab]*' into:RxMatcher) ~= nil ].
+ self
+ should:[ (matcher := self compileRegex:'[^ab]*' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'cde') = true ].
self should:[ (matcher subexpression:1) = 'cde' ].
!
@@ -1131,27 +1131,27 @@
test096
|matcher|
- self
- should:[ (matcher := self compileRegex:'(^)*' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(^)*' into:Regex::RxMatcher) = nil ].
!
test097
|matcher|
- self
- should:[ (matcher := self compileRegex:'(ab|)*' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'(ab|)*' into:Regex::RxMatcher) = nil ].
!
test098
|matcher|
- self should:[ (matcher := self compileRegex:')(' into:RxMatcher) = nil ].
+ self should:[ (matcher := self compileRegex:')(' into:Regex::RxMatcher) = nil ].
!
test099
|matcher|
- self should:[ (matcher := self compileRegex:'' into:RxMatcher) ~= nil ].
+ self should:[ (matcher := self compileRegex:'' into:Regex::RxMatcher) ~= nil ].
self should:[ (matcher search:'abc') = true ].
self should:[ (matcher subexpression:1) = '' ].
!
@@ -1159,7 +1159,7 @@
test100
| matcher |
- self should: [ (matcher := self compileRegex: 'abc' into: RxMatcher) ~= nil ].
+ self should: [ (matcher := self compileRegex: 'abc' into:Regex::RxMatcher) ~= nil ].
self should: [ (matcher search: '') = false ].
"
@@ -1170,7 +1170,7 @@
test101
| matcher |
- self should: [ (matcher := self compileRegex: 'a*' into: RxMatcher) ~= nil ].
+ self should: [ (matcher := self compileRegex: 'a*' into:Regex::RxMatcher) ~= nil ].
self should: [ (matcher search: '') = true ].
"
@@ -1181,7 +1181,7 @@
test102
| matcher |
- self should: [ (matcher := self compileRegex: 'abcd' into: RxMatcher) ~= nil ].
+ self should: [ (matcher := self compileRegex: 'abcd' into:Regex::RxMatcher) ~= nil ].
self should: [ (matcher search: 'abcd') = true ].
self should: [ (matcher subexpression: 1) = 'abcd' ].
@@ -1193,7 +1193,7 @@
test103
| matcher |
- self should: [ (matcher := self compileRegex: 'a(bc)d' into: RxMatcher) ~= nil ].
+ self should: [ (matcher := self compileRegex: 'a(bc)d' into:Regex::RxMatcher) ~= nil ].
self should: [ (matcher search: 'abcd') = true ].
self should: [ (matcher subexpression: 1) = 'abcd' ].
self should: [ (matcher subexpression: 2) = 'bc' ].
@@ -1204,394 +1204,394 @@
!
test104
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '([abc])*d' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abbbcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abbbcd' ].
- self should: [ (matcher subexpression: 2) = 'c' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '([abc])*d' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abbbcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abbbcd' ].
+ self should: [ (matcher subexpression: 2) = 'c' ].
!
test105
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '([abc])*bcd' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abcd' ].
- self should: [ (matcher subexpression: 2) = 'a' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '([abc])*bcd' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcd' ].
+ self should: [ (matcher subexpression: 2) = 'a' ].
!
test106
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a|b|c|d|e' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'e') = true ].
- self should: [ (matcher subexpression: 1) = 'e' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a|b|c|d|e' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'e') = true ].
+ self should: [ (matcher subexpression: 1) = 'e' ].
!
test107
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(a|b|c|d|e)f' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'ef') = true ].
- self should: [ (matcher subexpression: 1) = 'ef' ].
- self should: [ (matcher subexpression: 2) = 'e' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(a|b|c|d|e)f' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'ef') = true ].
+ self should: [ (matcher subexpression: 1) = 'ef' ].
+ self should: [ (matcher subexpression: 2) = 'e' ].
!
test108
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'abcd*efg' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcdefg') = true ].
- self should: [ (matcher subexpression: 1) = 'abcdefg' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'abcd*efg' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcdefg') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcdefg' ].
!
test109
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'ab*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'xabyabbbz') = true ].
- self should: [ (matcher subexpression: 1) = 'ab' ].
- self should: [ (matcher search: 'xayabbbz') = true ].
- self should: [ (matcher subexpression: 1) = 'a' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'ab*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'xabyabbbz') = true ].
+ self should: [ (matcher subexpression: 1) = 'ab' ].
+ self should: [ (matcher search: 'xayabbbz') = true ].
+ self should: [ (matcher subexpression: 1) = 'a' ].
!
test110
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(ab|cd)e' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcde') = true ].
- self should: [ (matcher subexpression: 1) = 'cde' ].
- self should: [ (matcher subexpression: 2) = 'cd' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(ab|cd)e' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcde') = true ].
+ self should: [ (matcher subexpression: 1) = 'cde' ].
+ self should: [ (matcher subexpression: 2) = 'cd' ].
!
test111
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[abhgefdc]ij' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'hij') = true ].
- self should: [ (matcher subexpression: 1) = 'hij' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[abhgefdc]ij' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'hij') = true ].
+ self should: [ (matcher subexpression: 1) = 'hij' ].
!
test112
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '^(ab|cd)e' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcde') = false ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '^(ab|cd)e' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcde') = false ].
!
test113
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(abc|)def' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcdef') = true ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(abc|)def' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcdef') = true ].
!
test114
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(a|b)c*d' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'bcd' ].
- self should: [ (matcher subexpression: 2) = 'b' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(a|b)c*d' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'bcd' ].
+ self should: [ (matcher subexpression: 2) = 'b' ].
!
test115
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(ab|ab*)bc' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
- self should: [ (matcher subexpression: 2) = 'a' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(ab|ab*)bc' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
+ self should: [ (matcher subexpression: 2) = 'a' ].
!
test116
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a([bc]*)c*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
- self should: [ (matcher subexpression: 2) = 'bc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a([bc]*)c*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
+ self should: [ (matcher subexpression: 2) = 'bc' ].
!
test117
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a([bc]*)(c*d)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abcd' ].
- self should: [ (matcher subexpression: 2) = 'bc' ].
- self should: [ (matcher subexpression: 3) = 'd' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a([bc]*)(c*d)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcd' ].
+ self should: [ (matcher subexpression: 2) = 'bc' ].
+ self should: [ (matcher subexpression: 3) = 'd' ].
!
test118
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a([bc]+)(c*d)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abcd' ].
- self should: [ (matcher subexpression: 2) = 'bc' ].
- self should: [ (matcher subexpression: 3) = 'd' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a([bc]+)(c*d)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcd' ].
+ self should: [ (matcher subexpression: 2) = 'bc' ].
+ self should: [ (matcher subexpression: 3) = 'd' ].
!
test119
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a([bc]*)(c+d)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abcd' ].
- self should: [ (matcher subexpression: 2) = 'b' ].
- self should: [ (matcher subexpression: 3) = 'cd' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a([bc]*)(c+d)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcd' ].
+ self should: [ (matcher subexpression: 2) = 'b' ].
+ self should: [ (matcher subexpression: 3) = 'cd' ].
!
test120
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a[bcd]*dcdcde' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'adcdcde') = true ].
- self should: [ (matcher subexpression: 1) = 'adcdcde' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a[bcd]*dcdcde' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'adcdcde') = true ].
+ self should: [ (matcher subexpression: 1) = 'adcdcde' ].
!
test121
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: 'a[bcd]+dcdcde' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'adcdcde') = false ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: 'a[bcd]+dcdcde' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'adcdcde') = false ].
!
test122
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '(ab|a)b*c' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '(ab|a)b*c' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test123
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '((a)(b)c)(d)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcd') = true ].
- self should: [ (matcher subexpression: 1) = 'abcd' ].
- self should: [ (matcher subexpression: 3) = 'a' ].
- self should: [ (matcher subexpression: 4) = 'b' ].
- self should: [ (matcher subexpression: 5) = 'd' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '((a)(b)c)(d)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcd') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcd' ].
+ self should: [ (matcher subexpression: 3) = 'a' ].
+ self should: [ (matcher subexpression: 4) = 'b' ].
+ self should: [ (matcher subexpression: 5) = 'd' ].
!
test124
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test125
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test126
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test127
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test128
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test129
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test130
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~ -~ -~]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abc') = true ].
- self should: [ (matcher subexpression: 1) = 'abc' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[ -~ -~ -~ -~ -~ -~ -~]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abc') = true ].
+ self should: [ (matcher subexpression: 1) = 'abc' ].
!
test131
- | matcher |
-
-
- self should: [ (matcher := self compileRegex: '[a-zA-Z_][a-zA-Z0-9_]*' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'alpha') = true ].
- self should: [ (matcher subexpression: 1) = 'alpha' ].
+ | matcher |
+
+
+ self should: [ (matcher := self compileRegex: '[a-zA-Z_][a-zA-Z0-9_]*' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'alpha') = true ].
+ self should: [ (matcher subexpression: 1) = 'alpha' ].
!
test132
- | matcher |
-
- self should: [ (matcher := self compileRegex: '^a(bc+|b[eh])g|.h$' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abh') = true ].
- self should: [ (matcher subexpression: 1) = 'bh' ].
- self should: [ (matcher subexpression: 2) = '' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '^a(bc+|b[eh])g|.h$' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abh') = true ].
+ self should: [ (matcher subexpression: 1) = 'bh' ].
+ self should: [ (matcher subexpression: 2) = '' ].
!
test133
- | matcher |
-
- self should: [ (matcher := self compileRegex: '(bc+d$|ef*g.|h?i(j|k))' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'effgz') = true ].
- self should: [ (matcher subexpression: 1) = 'effgz' ].
- self should: [ (matcher subexpression: 2) = 'effgz' ].
- self should: [ (matcher subexpression: 3) = '' ].
- self should: [ (matcher search: 'ij') = true ].
- self should: [ (matcher subexpression: 1) = 'ij' ].
- self should: [ (matcher subexpression: 2) = 'ij' ].
- self should: [ (matcher subexpression: 3) = 'j' ].
- self should: [ (matcher search: 'effg') = false ].
- self should: [ (matcher search: 'bcdd') = false ].
- self should: [ (matcher search: 'reffgz') = true ].
- self should: [ (matcher subexpression: 1) = 'effgz' ].
- self should: [ (matcher subexpression: 2) = 'effgz' ].
- self should: [ (matcher subexpression: 3) = '' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '(bc+d$|ef*g.|h?i(j|k))' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'effgz') = true ].
+ self should: [ (matcher subexpression: 1) = 'effgz' ].
+ self should: [ (matcher subexpression: 2) = 'effgz' ].
+ self should: [ (matcher subexpression: 3) = '' ].
+ self should: [ (matcher search: 'ij') = true ].
+ self should: [ (matcher subexpression: 1) = 'ij' ].
+ self should: [ (matcher subexpression: 2) = 'ij' ].
+ self should: [ (matcher subexpression: 3) = 'j' ].
+ self should: [ (matcher search: 'effg') = false ].
+ self should: [ (matcher search: 'bcdd') = false ].
+ self should: [ (matcher search: 'reffgz') = true ].
+ self should: [ (matcher subexpression: 1) = 'effgz' ].
+ self should: [ (matcher subexpression: 2) = 'effgz' ].
+ self should: [ (matcher subexpression: 3) = '' ].
!
test134
- | matcher |
-
- self should: [ (matcher := self compileRegex: '(((((((((a)))))))))' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'a') = true ].
- self should: [ (matcher subexpression: 1) = 'a' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '(((((((((a)))))))))' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'a') = true ].
+ self should: [ (matcher subexpression: 1) = 'a' ].
!
test135
- | matcher |
-
- self should: [ (matcher := self compileRegex: 'multiple words of text' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'uh-uh') = false ].
- self should: [ (matcher search: 'multiple words of text, yeah') = true ].
- self should: [ (matcher subexpression: 1) = 'multiple words of text' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: 'multiple words of text' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'uh-uh') = false ].
+ self should: [ (matcher search: 'multiple words of text, yeah') = true ].
+ self should: [ (matcher subexpression: 1) = 'multiple words of text' ].
!
test136
- | matcher |
-
- self should: [ (matcher := self compileRegex: '(.*)c(.*)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: 'abcde') = true ].
- self should: [ (matcher subexpression: 1) = 'abcde' ].
- self should: [ (matcher subexpression: 2) = 'ab' ].
- self should: [ (matcher subexpression: 3) = 'de' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '(.*)c(.*)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: 'abcde') = true ].
+ self should: [ (matcher subexpression: 1) = 'abcde' ].
+ self should: [ (matcher subexpression: 2) = 'ab' ].
+ self should: [ (matcher subexpression: 3) = 'de' ].
!
test137
- | matcher |
-
- self should: [ (matcher := self compileRegex: '\((.*), (.*)\)' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: '(a, b)') = true ].
- self should: [ (matcher subexpression: 2) = 'a' ].
- self should: [ (matcher subexpression: 3) = 'b' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '\((.*), (.*)\)' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: '(a, b)') = true ].
+ self should: [ (matcher subexpression: 2) = 'a' ].
+ self should: [ (matcher subexpression: 3) = 'b' ].
!
test199
|matcher|
- self
- should:[ (matcher := self compileRegex:'a{}b' into:RxMatcher) = nil ].
+ self
+ should:[ (matcher := self compileRegex:'a{}b' into:Regex::RxMatcher) = nil ].
!
test200
- | matcher |
-
- self should: [ (matcher := self compileRegex: '\d{2,5}' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: '1') = false ].
- self should: [ (matcher search: '12') = true ].
- self should: [ (matcher search: '123') = true ].
- self should: [ (matcher search: '1234') = true ].
- self should: [ (matcher search: '12356') = true ].
- self should: [ (matcher search: '123456') = true ].
- self should: [ (matcher subexpression: 1) = '12345' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '\d{2,5}' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: '1') = false ].
+ self should: [ (matcher search: '12') = true ].
+ self should: [ (matcher search: '123') = true ].
+ self should: [ (matcher search: '1234') = true ].
+ self should: [ (matcher search: '12356') = true ].
+ self should: [ (matcher search: '123456') = true ].
+ self should: [ (matcher subexpression: 1) = '12345' ].
!
test201
- | matcher |
-
- self should: [ (matcher := self compileRegex: '[0-9]{2,5}' into: RxMatcher) ~= nil ].
- self should: [ (matcher search: '1') = false ].
- self should: [ (matcher search: '12') = true ].
- self should: [ (matcher search: '123') = true ].
- self should: [ (matcher search: '1234') = true ].
- self should: [ (matcher search: '12356') = true ].
- self should: [ (matcher search: '123456') = true ].
- self should: [ (matcher subexpression: 1) = '12345' ].
+ | matcher |
+
+ self should: [ (matcher := self compileRegex: '[0-9]{2,5}' into:Regex::RxMatcher) ~= nil ].
+ self should: [ (matcher search: '1') = false ].
+ self should: [ (matcher search: '12') = true ].
+ self should: [ (matcher search: '123') = true ].
+ self should: [ (matcher search: '1234') = true ].
+ self should: [ (matcher search: '12356') = true ].
+ self should: [ (matcher search: '123456') = true ].
+ self should: [ (matcher subexpression: 1) = '12345' ].
!
test202
- | matcher |
-
- self assert: ( (matcher := self compileRegex: '([0-9]{2,4}\s){2}' into: RxMatcher) ~= nil ).
- self deny: ( matcher matches: '1 1 ').
- self assert: ( matcher matches: '12 12 ' ).
- self assert: ( matcher matches: '12 123 ' ).
- self assert: ( matcher matches: '123 12 ' ).
- self assert: ( matcher matches: '123 123 ' ).
- self assert: ( matcher matches: '1234 12 ' ).
- self deny: ( matcher matches: '123456 12 ' ).
- self deny: ( matcher matches: '12356 12 ' ).
+ | matcher |
+
+ self assert: ( (matcher := self compileRegex: '([0-9]{2,4}\s){2}' into:Regex::RxMatcher) ~= nil ).
+ self deny: ( matcher matches: '1 1 ').
+ self assert: ( matcher matches: '12 12 ' ).
+ self assert: ( matcher matches: '12 123 ' ).
+ self assert: ( matcher matches: '123 12 ' ).
+ self assert: ( matcher matches: '123 123 ' ).
+ self assert: ( matcher matches: '1234 12 ' ).
+ self deny: ( matcher matches: '123456 12 ' ).
+ self deny: ( matcher matches: '12356 12 ' ).
!
testProtocol
| matcher |
- self should: [ (matcher := RxMatcher forString: '\w+') ~= nil ].
+ self should: [ (matcher := Regex::RxMatcherMatcher forString: '\w+') ~= nil ].
self should: [ (matcher matchesIn: 'now is the time') asArray = #('now' 'is' 'the' 'time') ].
self should: [ (matcher copy: 'now is the time ' translatingMatchesUsing: [:s | s reverse]) = 'won si eht emit ' ].
"See that the match context is preserved while copying stuff between matches:"
- self should: [ ((RxMatcher forString: '\<\d\D+')
+ self should: [ ((RxMatcher forString: '\<\d\D+')
copy: '9aaa1bbb 8ccc'
replacingMatchesWith: 'foo') = 'foo1bbb foo' ].
!
@@ -1611,12 +1611,12 @@
!RxTests methodsFor:'test suite - old'!
compileRegex: regexSource into: matcherClass
- "Compile the regex and answer the matcher, or answer nil if compilation fails."
-
- | syntaxTree |
- syntaxTree := RxParser safelyParse: regexSource.
- syntaxTree == nil ifTrue: [^nil].
- ^matcherClass for: syntaxTree
+ "Compile the regex and answer the matcher, or answer nil if compilation fails."
+
+ | syntaxTree |
+ syntaxTree := Regex::RxParser safelyParse: regexSource.
+ syntaxTree == nil ifTrue: [^nil].
+ ^matcherClass for: syntaxTree
!
runProtocolTestsForMatcher: matcherClass
@@ -1630,7 +1630,7 @@
= 'won si eht emit '
ifFalse: [self error: 'copy:translatingMatchesWith: test failed'].
"See that the match context is preserved while copying stuff between matches:"
- ((matcherClass forString: '\<\d\D+')
+ ((matcherClass forString: '\<\d\D+')
copy: '9aaa1bbb 8ccc'
replacingMatchesWith: 'foo') = 'foo1bbb foo'
ifFalse: [self error: 'test failed'].
@@ -1638,57 +1638,57 @@
!
runRegexTestsForMatcher: matcherClass
- "Run the whole suite of tests for the given matcher class. May blow up
- if anything goes wrong with the matcher or parser. Since this is a
- developer's tool, who cares?"
- "self runRegexTestsForMatcher: RxMatcher"
-
- | failures |
- failures := 0.
- Transcript cr.
- self xtestSuite do: [:clause |
- | rxSource matcher isOK |
- rxSource := clause first.
- Transcript show: 'Testing regex: '; show: rxSource printString; cr.
- matcher := self compileRegex: rxSource into: matcherClass.
- matcher == nil
- ifTrue:
- [(clause at: 2) isNil
- ifTrue:
- [Transcript tab; show: 'Compilation error as expected (ok)'; cr]
- ifFalse:
- [Transcript tab;
- show: 'Compilation error, UNEXPECTED -- FAILED'; cr.
- failures := failures + 1]]
- ifFalse:
- [(clause at: 2) == nil
- ifTrue:
- [Transcript tab;
- show: 'Compilation succeeded, should have failed -- FAILED!!';
- cr.
- failures := failures + 1]
- ifFalse:
- [2 to: clause size by: 3 do:
- [:i |
- isOK := self
- xtest: matcher
- with: (clause at: i)
- expect: (clause at: i + 1)
- withSubexpressions: (clause at: i + 2).
- isOK ifFalse: [failures := failures + 1].
- Transcript
- show: (isOK ifTrue: [' (ok).'] ifFalse: [' -- FAILED!!']);
- cr]]]].
- failures = 0
- ifTrue: [Transcript show: 'PASSED ALL TESTS.'; cr]
- ifFalse: [Transcript show: failures printString, ' TESTS FAILED!!'; cr]
+ "Run the whole suite of tests for the given matcher class. May blow up
+ if anything goes wrong with the matcher or parser. Since this is a
+ developer's tool, who cares?"
+ "self runRegexTestsForMatcher: Regex::RxMatcher"
+
+ | failures |
+ failures := 0.
+ Transcript cr.
+ self xtestSuite do: [:clause |
+ | rxSource matcher isOK |
+ rxSource := clause first.
+ Transcript show: 'Testing regex: '; show: rxSource printString; cr.
+ matcher := self compileRegex: rxSource into: matcherClass.
+ matcher == nil
+ ifTrue:
+ [(clause at: 2) isNil
+ ifTrue:
+ [Transcript tab; show: 'Compilation error as expected (ok)'; cr]
+ ifFalse:
+ [Transcript tab;
+ show: 'Compilation error, UNEXPECTED -- FAILED'; cr.
+ failures := failures + 1]]
+ ifFalse:
+ [(clause at: 2) == nil
+ ifTrue:
+ [Transcript tab;
+ show: 'Compilation succeeded, should have failed -- FAILED!!';
+ cr.
+ failures := failures + 1]
+ ifFalse:
+ [2 to: clause size by: 3 do:
+ [:i |
+ isOK := self
+ xtest: matcher
+ with: (clause at: i)
+ expect: (clause at: i + 1)
+ withSubexpressions: (clause at: i + 2).
+ isOK ifFalse: [failures := failures + 1].
+ Transcript
+ show: (isOK ifTrue: [' (ok).'] ifFalse: [' -- FAILED!!']);
+ cr]]]].
+ failures = 0
+ ifTrue: [Transcript show: 'PASSED ALL TESTS.'; cr]
+ ifFalse: [Transcript show: failures printString, ' TESTS FAILED!!'; cr]
!
runTestsForMatcher: matcherClass
"Run the whole suite of tests for the given matcher class. May blow up
- if something goes wrong with the matcher or the parser. Since this is a
+ if something goes wrong with the matcher or the parser. Since this is a
developer's tool, who cares?"
- "self runTestsForMatcher: RxMatcher"
+ "self runTestsForMatcher: Regex::RxMatcher"
self
runRegexTestsForMatcher: matcherClass;
@@ -1711,72 +1711,72 @@
testCharacterSet
"self debug: #testCharacterSet"
-
+
"So far, we have used only characters as the 'smallest' components of
regular expressions. There are other, more `interesting', components.
A character set is a string of characters enclosed in square
brackets. It matches any single character if it appears between the
brackets. For example, `[01]' matches either `0' or `1':"
- self assert: ('0' matchesRegex: '[01]').
- self deny: ('3' matchesRegex: '[01]').
+ self assert: ('0' matchesRegex: '[01]').
+ self deny: ('3' matchesRegex: '[01]').
self deny: ('11' matchesRegex: '[01]'). "-- false: a set matches only one character"
self deny: ('01' matchesRegex: '[01]').
!
testCharacterSetBinaryNumber
"self debug: #testCharacterSetBinaryNumber"
-
+
"Using plus operator, we can build the following binary number
recognizer:"
- self assert: ('10010100' matchesRegex: '[01]+').
- self deny: ('10001210' matchesRegex: '[01]+')
+ self assert: ('10010100' matchesRegex: '[01]+').
+ self deny: ('10001210' matchesRegex: '[01]+')
!
testCharacterSetInversion
"self debug: #testCharacterSetInversion"
-
+
"If the first character after the opening bracket is `^', the set is
inverted: it matches any single character *not* appearing between the
brackets:"
-
- self deny: ('0' matchesRegex: '[^01]').
+
+ self deny: ('0' matchesRegex: '[^01]').
"0 appears in 01 so there is no match"
-
+
self assert: ('3' matchesRegex: '[^01]').
"3 is not in 01 so it matches"
-
-
- self deny: ('30' matchesRegex: '[^01]').
- self deny: ('33333333333333333333333330' matchesRegex: '[^01]').
+
+
+ self deny: ('30' matchesRegex: '[^01]').
+ self deny: ('33333333333333333333333330' matchesRegex: '[^01]').
"there is one zero so it does not match"
!
testCharacterSetRange
"self debug: #testCharacterSetRange"
-
+
"For convenience, a set may include ranges: pairs of characters
separated with `-'. This is equivalent to listing all characters
-between them: `[0-9]' is the same as `[0123456789]'. "
-
- self assert: ('0' matchesRegex: '[0-9]').
- self assert: ('9' matchesRegex: '[0-9]').
+between them: `[0-9]' is the same as `[0123456789]'. "
+
+ self assert: ('0' matchesRegex: '[0-9]').
+ self assert: ('9' matchesRegex: '[0-9]').
self deny: ('a' matchesRegex: '[0-9]').
- self deny: ('01' matchesRegex: '[0-9]').
- self assert: ('01442128629839374565' matchesRegex: '[0-9]+').
+ self deny: ('01' matchesRegex: '[0-9]').
+ self assert: ('01442128629839374565' matchesRegex: '[0-9]+').
!
testMatchesInwW
"self debug: #testMatchesInwW"
-
+
"1. Backslash escapes similar to those in Perl are allowed in patterns:
\w any word constituent character (equivalent to [a-zA-Z0-9_])
\W any character but a word constituent (equivalent to [^a-xA-Z0-9_]"
self assert: ('\w+' asRegex matchesIn: 'now is the time') asArray = #('now' 'is' 'the' 'time').
self assert: ('\W+' asRegex matchesIn: 'now is the time') asArray = #(' ' ' ' ' ').
-
-
+
+
"/ self halt.
"why do we get that"
self assert: ('\w' asRegex matchesIn: 'now') asArray = #('n' 'o' 'w').
@@ -1784,17 +1784,17 @@
testOrOperator
"self debug: #testOrOperator"
-
+
"The last operator is `|' meaning `or'. It is placed between two
regular expressions, and the resulting expression matches if one of
the expressions matches. It has the lowest possible precedence (lower
than sequencing). For example, `ab*|ba*' means `a followed by any
number of b's, or b followed by any number of a's':"
- self assert: ('abb' matchesRegex: 'ab*|ba*').
- self assert: ('baa' matchesRegex: 'ab*|ba*').
+ self assert: ('abb' matchesRegex: 'ab*|ba*').
+ self assert: ('baa' matchesRegex: 'ab*|ba*').
self deny: ('baab' matchesRegex: 'ab*|ba*').
-
+
"It is possible to write an expression matching an empty string, for
example: `a|'. However, it is an error to apply `*', `+', or `?' to
@@ -1805,7 +1805,7 @@
testQuotingOperators
"self debug: #testQuotingOperators"
-
+
"As we have seen, characters `*', `+', `?', `(', and `)' have special
meaning in regular expressions. If one of them is to be used
literally, it should be quoted: preceded with a backslash. (Thus,
@@ -1814,13 +1814,13 @@
further)."
self deny: ('ab*' matchesRegex: 'ab*'). " -- false: star in the right string is special"
- self assert: ('ab*' matchesRegex: 'ab\*').
- self assert: ('a\c' matchesRegex: 'a\\c').
+ self assert: ('ab*' matchesRegex: 'ab\*').
+ self assert: ('a\c' matchesRegex: 'a\\c').
!
testSimpleMatchesRegex
"self debug: #testSimpleMatchesRegex"
-
+
"The simplest regular expression is a single character. It matches
exactly that character. A sequence of characters matches a string with
exactly the same sequence of characters:"
@@ -1832,7 +1832,7 @@
testSimpleMatchesRegexWithStar
"self debug: #testSimpleMatchesRegexWithStar"
-
+
"The above paragraph in testSimpleMatchesRegex introduced a primitive regular expression (a
character), and an operator (sequencing). Operators are applied to
regular expressions to produce more complex regular expressions.
@@ -1843,439 +1843,439 @@
matches any number (including 0) of matches of the original
expression. For example:"
- self assert: ('ab' matchesRegex: 'a*b').
- self assert: ('aaaaab' matchesRegex: 'a*b').
- self assert: ('b' matchesRegex: 'a*b').
- self deny: ('aac' matchesRegex: 'a*b').
+ self assert: ('ab' matchesRegex: 'a*b').
+ self assert: ('aaaaab' matchesRegex: 'a*b').
+ self assert: ('b' matchesRegex: 'a*b').
+ self deny: ('aac' matchesRegex: 'a*b').
!
testSpecialCharacterInSetRange
"self debug: #testSpecialCharacterInSetRange"
-
+
"Special characters within a set are `^', `-', and `]' that closes the
set. Below are the examples of how to literally use them in a set:
[01^] -- put the caret anywhere except the beginning
[01-] -- put the dash as the last character
- []01] -- put the closing bracket as the first character
+ []01] -- put the closing bracket as the first character
[^]01] (thus, empty and universal sets cannot be specified)"
self assert: ('0' matchesRegex: '[01^]').
self assert: ('1' matchesRegex: '[01^]').
self assert: ('^' matchesRegex: '[01^]').
-
+
self deny: ('0' matchesRegex: '[^01]').
self deny: ('1' matchesRegex: '[^01]').
-
+
"[^abc] means that everything except abc is matche"
self assert: ('^' matchesRegex: '[^01]').
!
testStarPlusQuestionMark
"self debug: #testStarPlusQuestionMark"
-
+
"Two other operators similar to `*' are `+' and `?'. `+' (positive
closure, or simply `plus') matches one or more occurrences of the
original expression. `?' (`optional') matches zero or one, but never
more, occurrences."
- self assert: ('ac' matchesRegex: 'ab*c').
+ self assert: ('ac' matchesRegex: 'ab*c').
self deny: ('ac' matchesRegex: 'ab+c'). "-- false: need at least one b"
- self assert: ('abbc' matchesRegex: 'ab+c').
- self assert: ('abbbbbbc' matchesRegex: 'ab+c').
+ self assert: ('abbc' matchesRegex: 'ab+c').
+ self assert: ('abbbbbbc' matchesRegex: 'ab+c').
self deny: ('abbc' matchesRegex: 'ab?c') "-- false: too many b's"
!
testStarPrecedence
"self debug: #testStarPrecedence"
-
+
"A star's precedence is higher than that of sequencing. A star applies
to the shortest possible subexpression that precedes it. For example,
'ab*' means `a followed by zero or more occurrences of b', not `zero
or more occurrences of ab':"
- self assert: ('abbb' matchesRegex: 'ab*').
- self deny: ('abab' matchesRegex: 'ab*').
-
+ self assert: ('abbb' matchesRegex: 'ab*').
+ self deny: ('abab' matchesRegex: 'ab*').
+
"To actually make a regex matching `zero or more occurrences of ab',
`ab' is enclosed in parentheses:"
- self assert: ('abab' matchesRegex: '(ab)*').
+ self assert: ('abab' matchesRegex: '(ab)*').
self deny: ('abcab' matchesRegex: '(ab)*')
!
testTranslatingMatchesUsing
"self debug: #testTranslatingMatchesUsing"
-
+
self assert: ('\<t\w+' asRegexIgnoringCase
- copy: 'now is the Time'
- translatingMatchesUsing: [:match | match asUppercase]) = 'now is THE TIME'.
+ copy: 'now is the Time'
+ translatingMatchesUsing: [:match | match asUppercase]) = 'now is THE TIME'.
"the regular expression matches words beginning with either an uppercase or a lowercase T"
!
xtest1
- self runTestsForMatcher: RxMatcher
+ self runTestsForMatcher: Regex::RxMatcher
!
xtest: aMatcher with: testString expect: expected withSubexpressions: subexpr
- | got |
- Transcript tab;
- show: 'Matching: ';
- show: testString printString;
- show: ' expected: ';
- show: expected printString;
- show: ' got: '.
- got := aMatcher search: testString.
- Transcript show: got printString.
- got ~= expected
- ifTrue: [^false].
- (subexpr notNil and: [aMatcher supportsSubexpressions])
- ifFalse:
- [^true]
- ifTrue:
- [ | isOK |
- isOK := true.
- 1 to: subexpr size by: 2 do: [: i |
- | sub subExpect subGot |
- sub := subexpr at: i.
- subExpect := subexpr at: i + 1.
- subGot := aMatcher subexpression: sub.
- Transcript cr; tab; tab;
- show: 'Subexpression: ', sub printString;
- show: ' expected: ';
- show: subExpect printString;
- show: ' got: ';
- show: subGot printString.
- subExpect ~= subGot
- ifTrue:
- [Transcript show: ' -- MISMATCH'.
- isOK := false]].
- ^isOK]
+ | got |
+ Transcript tab;
+ show: 'Matching: ';
+ show: testString printString;
+ show: ' expected: ';
+ show: expected printString;
+ show: ' got: '.
+ got := aMatcher search: testString.
+ Transcript show: got printString.
+ got ~= expected
+ ifTrue: [^false].
+ (subexpr notNil and: [aMatcher supportsSubexpressions])
+ ifFalse:
+ [^true]
+ ifTrue:
+ [ | isOK |
+ isOK := true.
+ 1 to: subexpr size by: 2 do: [: i |
+ | sub subExpect subGot |
+ sub := subexpr at: i.
+ subExpect := subexpr at: i + 1.
+ subGot := aMatcher subexpression: sub.
+ Transcript cr; tab; tab;
+ show: 'Subexpression: ', sub printString;
+ show: ' expected: ';
+ show: subExpect printString;
+ show: ' got: ';
+ show: subGot printString.
+ subExpect ~= subGot
+ ifTrue:
+ [Transcript show: ' -- MISMATCH'.
+ isOK := false]].
+ ^isOK]
!
xtestSuite
"Answer an array of test clauses. Each clause is an array with a regex source
string followed by sequence of 3-tuples. Each three-element
- group is one test to try against the regex, and includes:
- 1) test string;
- 2) expected result;
- 3) expected subexpression as an array of (index, substring), or nil.
+ group is one test to try against the regex, and includes:
+ 1) test string;
+ 2) expected result;
+ 3) expected subexpression as an array of (index, substring), or nil.
The test suite is based on the one in Henry Spencer's regexp.c package."
- ^#(
- ('abc'
- 'abc' true (1 'abc')
- 'xbc' false nil
- 'axc' false nil
- 'abx' false nil
- 'xabcy' true (1 'abc')
- 'ababc' true (1 'abc'))
- ('ab*c'
- 'abc' true (1 'abc'))
- ('ab*bc'
- 'abc' true (1 'abc')
- 'abbc' true (1 'abbc')
- 'abbbbc' true (1 'abbbbc'))
- ('ab+bc'
- 'abbc' true (1 'abbc')
- 'abc' false nil
- 'abq' false nil
- 'abbbbc' true (1 'abbbbc'))
- ('ab?bc'
- 'abbc' true (1 'abbc')
- 'abc' true (1 'abc')
- 'abbbbc' false nil
- 'abc' true (1 'abc'))
- ('ab?c' "added 08-Jan-2004 by cg "
- 'abc' true (1 'abc'))
- ('^abc$'
- 'abc' true (1 'abc')
- 'abcc' false nil
- 'aabc' false nil)
- ('^abc'
- 'abcc' true (1 'abc'))
- ('abc$'
- 'aabc' true (1 'abc'))
- ('^'
- 'abc' true nil)
- ('$'
- 'abc' true nil)
- ('a.c'
- 'abc' true (1 'abc')
- 'axc' true (1 'axc'))
- ('a.*c'
- 'axyzc' true (1 'axyzc')
- 'axy zc' true (1 'axy zc') "testing that a dot matches a space"
- 'axy
- zc' false nil "testing that a dot does not match a newline"
- 'axyzd' false nil)
- ('.a.*'
- '1234abc' true (1 '4abc')
- 'abcd' false nil)
- ('a\w+c'
- ' abbbbc ' true (1 'abbbbc')
- 'abb bc' false nil)
- ('\w+'
- ' foobar quux' true (1 'foobar')
- ' ~!!@#$%^&*()-+=\|/?.>,<' false nil)
- ('a\W+c'
- 'a c' true (1 'a c')
- 'a bc' false nil)
- ('\W+'
- 'foo!!@#$bar' true (1 '!!@#$')
- 'foobar' false nil)
- ('a\s*c'
- 'a c' true (1 'a c')
- 'a bc' false nil)
- ('\s+'
- 'abc3457 sd' true (1 ' ')
- '1234$^*^&asdfb' false nil)
- ('a\S*c'
- 'aqwertyc' true (1 'aqwertyc')
- 'ab c' false nil)
- ('\S+'
- ' asdf ' true (1 'asdf')
- '
- ' false nil)
- ('a\d+c'
- 'a0123456789c' true (1 'a0123456789c')
- 'a12b34c' false nil)
- ('\d+'
- 'foo@#$%123ASD #$$%^&' true (1 '123')
- 'foo!!@#$asdfl;' false nil)
- ('a\D+c'
- 'aqwertyc' true (1 'aqwertyc')
- 'aqw6ertc' false nil)
- ('\D+'
- '1234 abc 456' true (1 ' abc ')
- '1234567890' false nil)
- ('(f|o)+\b'
- 'foo' true (1 'foo')
- ' foo ' true (1 'foo'))
- ('\ba\w+' "a word beginning with an A"
- 'land ancient' true (1 'ancient')
- 'antique vase' true (1 'antique')
- 'goofy foobar' false nil)
- ('(f|o)+\B'
- 'quuxfoobar' true (1 'foo')
- 'quuxfoo ' true (1 'fo'))
- ('\Ba\w+' "a word with an A in the middle, match at A and further"
- 'land ancient' true (1 'and')
- 'antique vase' true (1 'ase')
- 'smalltalk shall overcome' true (1 'alltalk')
- 'foonix is better' false nil)
- ('fooa\>.*'
- 'fooa ' true nil
- 'fooa123' false nil
- 'fooa bar' true nil
- 'fooa' true nil
- 'fooargh' false nil)
- ('\>.+abc'
- ' abcde fg' false nil
- 'foo abcde' true (1 ' abc')
- 'abcde' false nil)
- ('\<foo.*'
- 'foo' true nil
- 'foobar' true nil
- 'qfoobarq foonix' true (1 'foonix')
- ' foo' true nil
- ' 12foo' false nil
- 'barfoo' false nil)
- ('.+\<foo'
- 'foo' false nil
- 'ab foo' true (1 'ab foo')
- 'abfoo' false nil)
- ('a[bc]d'
- 'abc' false nil
- 'abd' true (1 'abd'))
- ('a[b-d]e'
- 'abd' false nil
- 'ace' true (1 'ace'))
- ('a[b-d]'
- 'aac' true (1 'ac'))
- ('a[-b]'
- 'a-' true (1 'a-'))
- ('a[b-]'
- 'a-' true (1 'a-'))
- ('a[a-b-c]' nil)
- ('[k]'
- 'ab' false nil)
- ('a[b-a]' nil)
- ('a[]b' nil)
- ('a[' nil)
- ('a]'
- 'a]' true (1 'a]'))
- ('a[]]b'
- 'a]b' true (1 'a]b'))
- ('a[^bc]d'
- 'aed' true (1 'aed')
- 'abd' false nil)
- ('a[^-b]c'
- 'adc' true (1 'adc')
- 'a-c' false nil)
- ('a[^]b]c'
- 'a]c' false nil
- 'adc' true (1 'adc'))
- ('[\de]+'
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))
- ('[e\d]+' "reversal of the above, should be the same"
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))
- ('[\D]+'
- '123abc45def78' true (1 'abc'))
- ('[[:digit:]e]+'
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))
- ('[\s]+'
- '2 spaces' true (1 ' '))
- ('[\S]+'
- ' word12!!@#$ ' true (1 'word12!!@#$'))
- ('[\w]+'
- ' foo123bar 45' true (1 'foo123bar'))
- ('[\W]+'
- 'fii234!!@#$34f' true (1 '!!@#$'))
- ('[^[:alnum:]]+'
- 'fii234!!@#$34f' true (1 '!!@#$'))
- ('[%&[:alnum:]]+'
- 'foo%3' true (1 'foo%3')
- 'foo34&rt4$57a' true (1 'foo34&rt4')
- '!!@#$' false nil)
- ('[[:alpha:]]+'
- ' 123foo3 ' true (1 'foo')
- '123foo' true (1 'foo')
- 'foo1b' true (1 'foo'))
- ('[[:blank:]]+'
- '2 blanks' true (1 ' '))
- ('[^[:blank:]]+'
- ' word12!!@#$ ' true (1 'word12!!@#$'))
- ('[[:cntrl:]]+'
- ' a 1234asdf' false nil)
- ('[[:lower:]]+'
- 'UPPERlower1234' true (1 'lower')
- 'lowerUPPER' true (1 'lower'))
- ('[[:upper:]]+'
- 'UPPERlower1234' true (1 'UPPER')
- 'lowerUPPER ' true (1 'UPPER'))
- ('[[:space:]]+'
- '2 spaces' true (1 ' '))
- ('[^[:space:]]+'
- ' word12!!@#$ ' true (1 'word12!!@#$'))
- ('[[:graph:]]+'
- 'abc' true (1 'abc'))
- ('[[:print:]]+'
- 'abc' true (1 'abc'))
- ('[^[:punct:]]+'
- '!!hello,world!!' true (1 'hello'))
- ('[[:xdigit:]]+'
- ' x10FCD ' true (1 '10FCD')
- ' hgfedcba0123456789ABCDEFGH '
- true (1 'fedcba0123456789ABCDEF'))
- ('ab|cd'
- 'abc' true (1 'ab')
- 'abcd' true (1 'ab'))
- ('()ef'
- 'def' true (1 'ef' 2 ''))
- ('()*' nil)
- ('*a' nil)
- ('^*' nil)
- ('$*' nil)
- ('(*)b' nil)
- ('$b' 'b' false nil)
- ('a\' nil)
- ('a\(b'
- 'a(b' true (1 'a(b'))
- ('a\(*b'
- 'ab' true (1 'ab')
- 'a((b' true (1 'a((b'))
- ('a\\b'
- 'a\b' true (1 'a\b'))
- ('abc)' nil)
- ('(abc' nil)
- ('((a))'
- 'abc' true (1 'a' 2 'a' 3 'a'))
- ('(a)b(c)'
- 'abc' true (1 'abc' 2 'a' 3 'c'))
- ('a+b+c'
- 'aabbabc' true (1 'abc'))
- ('a**' nil)
- ('a*?' nil)
- ('(a*)*' nil)
- ('(a*)+' nil)
- ('(a|)*' nil)
- ('(a*|b)*' nil)
- ('(a+|b)*'
- 'ab' true (1 'ab' 2 'b'))
- ('(a+|b)+'
- 'ab' true (1 'ab' 2 'b'))
- ('(a+|b)?'
- 'ab' true (1 'a' 2 'a'))
- ('[^ab]*'
- 'cde' true (1 'cde'))
-
- ('(^)*' nil)
- ('(ab|)*' nil)
- (')(' nil)
- ('' 'abc' true (1 ''))
- ('abc' '' false nil)
- ('a*'
- '' true '')
- ('abcd'
- 'abcd' true (1 'abcd'))
- ('a(bc)d'
- 'abcd' true (1 'abcd' 2 'bc'))
- ('([abc])*d'
- 'abbbcd' true (1 'abbbcd' 2 'c'))
- ('([abc])*bcd'
- 'abcd' true (1 'abcd' 2 'a'))
- ('a|b|c|d|e' 'e' true (1 'e'))
- ('(a|b|c|d|e)f' 'ef' true (1 'ef' 2 'e'))
- " ((a*|b))* - c - -"
- ('abcd*efg' 'abcdefg' true (1 'abcdefg'))
- ('ab*'
- 'xabyabbbz' true (1 'ab')
- 'xayabbbz' true (1 'a'))
- ('(ab|cd)e' 'abcde' true (1 'cde' 2 'cd'))
- ('[abhgefdc]ij' 'hij' true (1 'hij'))
- ('^(ab|cd)e' 'abcde' false nil)
- ('(abc|)def' 'abcdef' true nil)
- ('(a|b)c*d' 'abcd' true (1 'bcd' 2 'b'))
- ('(ab|ab*)bc' 'abc' true (1 'abc' 2 'a'))
- ('a([bc]*)c*' 'abc' true (1 'abc' 2 'bc'))
- ('a([bc]*)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
- ('a([bc]+)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
- ('a([bc]*)(c+d)' 'abcd' true (1 'abcd' 2 'b' 3 'cd'))
- ('a[bcd]*dcdcde' 'adcdcde' true (1 'adcdcde'))
- ('a[bcd]+dcdcde' 'adcdcde' false nil)
- ('(ab|a)b*c' 'abc' true (1 'abc'))
- ('((a)(b)c)(d)' 'abcd' true (1 'abcd' 3 'a' 4 'b' 5 'd'))
- ('[ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- ('[ -~ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- ('[a-zA-Z_][a-zA-Z0-9_]*' 'alpha' true (1 'alpha'))
- ('^a(bc+|b[eh])g|.h$' 'abh' true (1 'bh' 2 ''))
- ('(bc+d$|ef*g.|h?i(j|k))'
- 'effgz' true (1 'effgz' 2 'effgz' 3 '')
- 'ij' true (1 'ij' 2 'ij' 3 'j')
- 'effg' false nil
- 'bcdd' false nil
- 'reffgz' true (1 'effgz' 2 'effgz' 3 ''))
- ('(((((((((a)))))))))' 'a' true (1 'a'))
- ('multiple words of text'
- 'uh-uh' false nil
- 'multiple words of text, yeah' true (1 'multiple words of text'))
- ('(.*)c(.*)' 'abcde' true (1 'abcde' 2 'ab' 3 'de'))
- ('\((.*), (.*)\)' '(a, b)' true (2 'a' 3 'b'))
-
- )
+ ^#(
+ ('abc'
+ 'abc' true (1 'abc')
+ 'xbc' false nil
+ 'axc' false nil
+ 'abx' false nil
+ 'xabcy' true (1 'abc')
+ 'ababc' true (1 'abc'))
+ ('ab*c'
+ 'abc' true (1 'abc'))
+ ('ab*bc'
+ 'abc' true (1 'abc')
+ 'abbc' true (1 'abbc')
+ 'abbbbc' true (1 'abbbbc'))
+ ('ab+bc'
+ 'abbc' true (1 'abbc')
+ 'abc' false nil
+ 'abq' false nil
+ 'abbbbc' true (1 'abbbbc'))
+ ('ab?bc'
+ 'abbc' true (1 'abbc')
+ 'abc' true (1 'abc')
+ 'abbbbc' false nil
+ 'abc' true (1 'abc'))
+ ('ab?c' "added 08-Jan-2004 by cg "
+ 'abc' true (1 'abc'))
+ ('^abc$'
+ 'abc' true (1 'abc')
+ 'abcc' false nil
+ 'aabc' false nil)
+ ('^abc'
+ 'abcc' true (1 'abc'))
+ ('abc$'
+ 'aabc' true (1 'abc'))
+ ('^'
+ 'abc' true nil)
+ ('$'
+ 'abc' true nil)
+ ('a.c'
+ 'abc' true (1 'abc')
+ 'axc' true (1 'axc'))
+ ('a.*c'
+ 'axyzc' true (1 'axyzc')
+ 'axy zc' true (1 'axy zc') "testing that a dot matches a space"
+ 'axy
+ zc' false nil "testing that a dot does not match a newline"
+ 'axyzd' false nil)
+ ('.a.*'
+ '1234abc' true (1 '4abc')
+ 'abcd' false nil)
+ ('a\w+c'
+ ' abbbbc ' true (1 'abbbbc')
+ 'abb bc' false nil)
+ ('\w+'
+ ' foobar quux' true (1 'foobar')
+ ' ~!!@#$%^&*()-+=\|/?.>,<' false nil)
+ ('a\W+c'
+ 'a c' true (1 'a c')
+ 'a bc' false nil)
+ ('\W+'
+ 'foo!!@#$bar' true (1 '!!@#$')
+ 'foobar' false nil)
+ ('a\s*c'
+ 'a c' true (1 'a c')
+ 'a bc' false nil)
+ ('\s+'
+ 'abc3457 sd' true (1 ' ')
+ '1234$^*^&asdfb' false nil)
+ ('a\S*c'
+ 'aqwertyc' true (1 'aqwertyc')
+ 'ab c' false nil)
+ ('\S+'
+ ' asdf ' true (1 'asdf')
+ '
+ ' false nil)
+ ('a\d+c'
+ 'a0123456789c' true (1 'a0123456789c')
+ 'a12b34c' false nil)
+ ('\d+'
+ 'foo@#$%123ASD #$$%^&' true (1 '123')
+ 'foo!!@#$asdfl;' false nil)
+ ('a\D+c'
+ 'aqwertyc' true (1 'aqwertyc')
+ 'aqw6ertc' false nil)
+ ('\D+'
+ '1234 abc 456' true (1 ' abc ')
+ '1234567890' false nil)
+ ('(f|o)+\b'
+ 'foo' true (1 'foo')
+ ' foo ' true (1 'foo'))
+ ('\ba\w+' "a word beginning with an A"
+ 'land ancient' true (1 'ancient')
+ 'antique vase' true (1 'antique')
+ 'goofy foobar' false nil)
+ ('(f|o)+\B'
+ 'quuxfoobar' true (1 'foo')
+ 'quuxfoo ' true (1 'fo'))
+ ('\Ba\w+' "a word with an A in the middle, match at A and further"
+ 'land ancient' true (1 'and')
+ 'antique vase' true (1 'ase')
+ 'smalltalk shall overcome' true (1 'alltalk')
+ 'foonix is better' false nil)
+ ('fooa\>.*'
+ 'fooa ' true nil
+ 'fooa123' false nil
+ 'fooa bar' true nil
+ 'fooa' true nil
+ 'fooargh' false nil)
+ ('\>.+abc'
+ ' abcde fg' false nil
+ 'foo abcde' true (1 ' abc')
+ 'abcde' false nil)
+ ('\<foo.*'
+ 'foo' true nil
+ 'foobar' true nil
+ 'qfoobarq foonix' true (1 'foonix')
+ ' foo' true nil
+ ' 12foo' false nil
+ 'barfoo' false nil)
+ ('.+\<foo'
+ 'foo' false nil
+ 'ab foo' true (1 'ab foo')
+ 'abfoo' false nil)
+ ('a[bc]d'
+ 'abc' false nil
+ 'abd' true (1 'abd'))
+ ('a[b-d]e'
+ 'abd' false nil
+ 'ace' true (1 'ace'))
+ ('a[b-d]'
+ 'aac' true (1 'ac'))
+ ('a[-b]'
+ 'a-' true (1 'a-'))
+ ('a[b-]'
+ 'a-' true (1 'a-'))
+ ('a[a-b-c]' nil)
+ ('[k]'
+ 'ab' false nil)
+ ('a[b-a]' nil)
+ ('a[]b' nil)
+ ('a[' nil)
+ ('a]'
+ 'a]' true (1 'a]'))
+ ('a[]]b'
+ 'a]b' true (1 'a]b'))
+ ('a[^bc]d'
+ 'aed' true (1 'aed')
+ 'abd' false nil)
+ ('a[^-b]c'
+ 'adc' true (1 'adc')
+ 'a-c' false nil)
+ ('a[^]b]c'
+ 'a]c' false nil
+ 'adc' true (1 'adc'))
+ ('[\de]+'
+ '01234' true (1 '01234')
+ '0123e456' true (1 '0123e456')
+ '0123e45g78' true (1 '0123e45'))
+ ('[e\d]+' "reversal of the above, should be the same"
+ '01234' true (1 '01234')
+ '0123e456' true (1 '0123e456')
+ '0123e45g78' true (1 '0123e45'))
+ ('[\D]+'
+ '123abc45def78' true (1 'abc'))
+ ('[[:digit:]e]+'
+ '01234' true (1 '01234')
+ '0123e456' true (1 '0123e456')
+ '0123e45g78' true (1 '0123e45'))
+ ('[\s]+'
+ '2 spaces' true (1 ' '))
+ ('[\S]+'
+ ' word12!!@#$ ' true (1 'word12!!@#$'))
+ ('[\w]+'
+ ' foo123bar 45' true (1 'foo123bar'))
+ ('[\W]+'
+ 'fii234!!@#$34f' true (1 '!!@#$'))
+ ('[^[:alnum:]]+'
+ 'fii234!!@#$34f' true (1 '!!@#$'))
+ ('[%&[:alnum:]]+'
+ 'foo%3' true (1 'foo%3')
+ 'foo34&rt4$57a' true (1 'foo34&rt4')
+ '!!@#$' false nil)
+ ('[[:alpha:]]+'
+ ' 123foo3 ' true (1 'foo')
+ '123foo' true (1 'foo')
+ 'foo1b' true (1 'foo'))
+ ('[[:blank:]]+'
+ '2 blanks' true (1 ' '))
+ ('[^[:blank:]]+'
+ ' word12!!@#$ ' true (1 'word12!!@#$'))
+ ('[[:cntrl:]]+'
+ ' a 1234asdf' false nil)
+ ('[[:lower:]]+'
+ 'UPPERlower1234' true (1 'lower')
+ 'lowerUPPER' true (1 'lower'))
+ ('[[:upper:]]+'
+ 'UPPERlower1234' true (1 'UPPER')
+ 'lowerUPPER ' true (1 'UPPER'))
+ ('[[:space:]]+'
+ '2 spaces' true (1 ' '))
+ ('[^[:space:]]+'
+ ' word12!!@#$ ' true (1 'word12!!@#$'))
+ ('[[:graph:]]+'
+ 'abc' true (1 'abc'))
+ ('[[:print:]]+'
+ 'abc' true (1 'abc'))
+ ('[^[:punct:]]+'
+ '!!hello,world!!' true (1 'hello'))
+ ('[[:xdigit:]]+'
+ ' x10FCD ' true (1 '10FCD')
+ ' hgfedcba0123456789ABCDEFGH '
+ true (1 'fedcba0123456789ABCDEF'))
+ ('ab|cd'
+ 'abc' true (1 'ab')
+ 'abcd' true (1 'ab'))
+ ('()ef'
+ 'def' true (1 'ef' 2 ''))
+ ('()*' nil)
+ ('*a' nil)
+ ('^*' nil)
+ ('$*' nil)
+ ('(*)b' nil)
+ ('$b' 'b' false nil)
+ ('a\' nil)
+ ('a\(b'
+ 'a(b' true (1 'a(b'))
+ ('a\(*b'
+ 'ab' true (1 'ab')
+ 'a((b' true (1 'a((b'))
+ ('a\\b'
+ 'a\b' true (1 'a\b'))
+ ('abc)' nil)
+ ('(abc' nil)
+ ('((a))'
+ 'abc' true (1 'a' 2 'a' 3 'a'))
+ ('(a)b(c)'
+ 'abc' true (1 'abc' 2 'a' 3 'c'))
+ ('a+b+c'
+ 'aabbabc' true (1 'abc'))
+ ('a**' nil)
+ ('a*?' nil)
+ ('(a*)*' nil)
+ ('(a*)+' nil)
+ ('(a|)*' nil)
+ ('(a*|b)*' nil)
+ ('(a+|b)*'
+ 'ab' true (1 'ab' 2 'b'))
+ ('(a+|b)+'
+ 'ab' true (1 'ab' 2 'b'))
+ ('(a+|b)?'
+ 'ab' true (1 'a' 2 'a'))
+ ('[^ab]*'
+ 'cde' true (1 'cde'))
+
+ ('(^)*' nil)
+ ('(ab|)*' nil)
+ (')(' nil)
+ ('' 'abc' true (1 ''))
+ ('abc' '' false nil)
+ ('a*'
+ '' true '')
+ ('abcd'
+ 'abcd' true (1 'abcd'))
+ ('a(bc)d'
+ 'abcd' true (1 'abcd' 2 'bc'))
+ ('([abc])*d'
+ 'abbbcd' true (1 'abbbcd' 2 'c'))
+ ('([abc])*bcd'
+ 'abcd' true (1 'abcd' 2 'a'))
+ ('a|b|c|d|e' 'e' true (1 'e'))
+ ('(a|b|c|d|e)f' 'ef' true (1 'ef' 2 'e'))
+ " ((a*|b))* - c - -"
+ ('abcd*efg' 'abcdefg' true (1 'abcdefg'))
+ ('ab*'
+ 'xabyabbbz' true (1 'ab')
+ 'xayabbbz' true (1 'a'))
+ ('(ab|cd)e' 'abcde' true (1 'cde' 2 'cd'))
+ ('[abhgefdc]ij' 'hij' true (1 'hij'))
+ ('^(ab|cd)e' 'abcde' false nil)
+ ('(abc|)def' 'abcdef' true nil)
+ ('(a|b)c*d' 'abcd' true (1 'bcd' 2 'b'))
+ ('(ab|ab*)bc' 'abc' true (1 'abc' 2 'a'))
+ ('a([bc]*)c*' 'abc' true (1 'abc' 2 'bc'))
+ ('a([bc]*)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
+ ('a([bc]+)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
+ ('a([bc]*)(c+d)' 'abcd' true (1 'abcd' 2 'b' 3 'cd'))
+ ('a[bcd]*dcdcde' 'adcdcde' true (1 'adcdcde'))
+ ('a[bcd]+dcdcde' 'adcdcde' false nil)
+ ('(ab|a)b*c' 'abc' true (1 'abc'))
+ ('((a)(b)c)(d)' 'abcd' true (1 'abcd' 3 'a' 4 'b' 5 'd'))
+ ('[ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
+ ('[ -~ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
+ ('[a-zA-Z_][a-zA-Z0-9_]*' 'alpha' true (1 'alpha'))
+ ('^a(bc+|b[eh])g|.h$' 'abh' true (1 'bh' 2 ''))
+ ('(bc+d$|ef*g.|h?i(j|k))'
+ 'effgz' true (1 'effgz' 2 'effgz' 3 '')
+ 'ij' true (1 'ij' 2 'ij' 3 'j')
+ 'effg' false nil
+ 'bcdd' false nil
+ 'reffgz' true (1 'effgz' 2 'effgz' 3 ''))
+ ('(((((((((a)))))))))' 'a' true (1 'a'))
+ ('multiple words of text'
+ 'uh-uh' false nil
+ 'multiple words of text, yeah' true (1 'multiple words of text'))
+ ('(.*)c(.*)' 'abcde' true (1 'abcde' 2 'ab' 3 'de'))
+ ('\((.*), (.*)\)' '(a, b)' true (2 'a' 3 'b'))
+
+ )
! !
!RxTests methodsFor:'test suite - string interface'!
@@ -2352,32 +2352,32 @@
!RxTests methodsFor:'test suite conversion'!
writeAllTests
- "Build individual tests from the test suite."
-
- | aTest matcherClass rxSource matcher isOK subexpr |
-
- matcherClass := RxMatcher.
-
- 1 to: self xtestSuite size do: [ :n |
- aTest := self xtestSuite at: n.
- Transcript
- show: 'test', n printString; cr;
- tab; show: '| matcher |'; cr; cr;
- tab; show: 'self should: [ (matcher := RxParser compileRegex: ''', aTest first, ''' into: RxMatcher)'.
- (aTest at: 2) isNil
- ifTrue: [ Transcript show: ' = nil ].'; cr ]
- ifFalse: [
- Transcript show: ' ~= nil ].'; cr.
- 2 to: aTest size by: 3 do:
- [:i |
- Transcript tab; show: 'self should: [ (matcher search: ', (aTest at: i) printString, ') = ',
- (aTest at: i+1) printString, ' ].'; cr.
- (aTest at: i+1) ~= nil ifTrue: [
- subexpr := aTest at: i+2.
- 1 to: subexpr size by: 2 do: [ :j |
- Transcript tab; show: 'self should: [ (matcher subexpression: ',
- (subexpr at: j) printString, ') = ', (subexpr at: j+1) printString,
- ' ].'; cr ]]]]]
+ "Build individual tests from the test suite."
+
+ | aTest matcherClass rxSource matcher isOK subexpr |
+
+ matcherClass := Regex::RxMatcher.
+
+ 1 to: self xtestSuite size do: [ :n |
+ aTest := self xtestSuite at: n.
+ Transcript
+ show: 'test', n printString; cr;
+ tab; show: '| matcher |'; cr; cr;
+ tab; show: 'self should: [ (matcher := Regex::RxParser compileRegex: ''', aTest first, ''' into:Regex::RxMatcher)'.
+ (aTest at: 2) isNil
+ ifTrue: [ Transcript show: ' = nil ].'; cr ]
+ ifFalse: [
+ Transcript show: ' ~= nil ].'; cr.
+ 2 to: aTest size by: 3 do:
+ [:i |
+ Transcript tab; show: 'self should: [ (matcher search: ', (aTest at: i) printString, ') = ',
+ (aTest at: i+1) printString, ' ].'; cr.
+ (aTest at: i+1) ~= nil ifTrue: [
+ subexpr := aTest at: i+2.
+ 1 to: subexpr size by: 2 do: [ :j |
+ Transcript tab; show: 'self should: [ (matcher subexpression: ',
+ (subexpr at: j) printString, ') = ', (subexpr at: j+1) printString,
+ ' ].'; cr ]]]]]
! !
!RxTests class methodsFor:'documentation'!
@@ -2389,4 +2389,3 @@
version_CVS
^ '$Header$'
! !
-