[squeak-dev] The Trunk: Regex-Tests-Core-mt.17.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Oct 5 18:13:01 UTC 2022
Christoph Thiede uploaded a new version of Regex-Tests-Core to project The Trunk:
http://source.squeak.org/trunk/Regex-Tests-Core-mt.17.mcz
==================== Summary ====================
Name: Regex-Tests-Core-mt.17
Author: mt
Time: 8 June 2022, 3:03:39.152335 pm
UUID: ef50d700-95f4-8f4b-9779-b64ab4635f9e
Ancestors: Regex-Tests-Core-mt.16
Let the test #testOptionalLookbehind2 be an expected failure for the next release.
=============== Diff against Regex-Tests-Core-mt.16 ===============
Item was removed:
- SystemOrganization addCategory: #'Regex-Tests-Core'!
Item was removed:
- TestCase subclass: #RxMatcherTest
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Regex-Tests-Core'!
-
- !RxMatcherTest commentStamp: 'Tbn 11/12/2010 22:31' prior: 0!
- This class provides tests for the regular expression matcher.!
Item was removed:
- ----- Method: RxMatcherTest>>compileRegex: (in category 'utilties') -----
- compileRegex: aString
- "Compile the regex and answer the matcher, or answer nil if compilation fails."
-
- | syntaxTree |
- syntaxTree := RxParser safelyParse: aString.
- ^ syntaxTree isNil ifFalse: [ self matcherClass for: syntaxTree ]!
Item was removed:
- ----- Method: RxMatcherTest>>henryReadme (in category 'testing-henry') -----
- henryReadme
- self error: 'The tests in this category are based on the ones in Henry Spencer''s regexp.c package.'!
Item was removed:
- ----- Method: RxMatcherTest>>matcherClass (in category 'accessing') -----
- matcherClass
- ^ RxMatcher!
Item was removed:
- ----- Method: RxMatcherTest>>runMatcher:with:expect:withSubexpressions: (in category 'utilties') -----
- runMatcher: aMatcher with: aString expect: aBoolean withSubexpressions: anArray
- | copy got |
- copy := aMatcher
- copy: aString
- translatingMatchesUsing: [ :each | each ].
- self
- assert: copy = aString
- description: 'Copying: expected ' , aString printString , ', but got ' , copy printString.
- got := aMatcher search: aString.
- self
- assert: got = aBoolean
- description: 'Searching: expected ' , aBoolean printString , ', but got ' , got printString.
- (anArray isNil or: [ aMatcher supportsSubexpressions not ])
- ifTrue: [ ^ self ].
- 1 to: anArray size by: 2 do: [ :index |
- | sub subExpect subGot |
- sub := anArray at: index.
- subExpect := anArray at: index + 1.
- subGot := aMatcher subexpression: sub.
- self
- assert: subExpect = subGot
- description: 'Subexpression ' , sub printString , ': expected ' , subExpect printString , ', but got ' , subGot printString ]!
Item was removed:
- ----- Method: RxMatcherTest>>runRegex: (in category 'utilties') -----
- runRegex: anArray
- "Run a clause anArray against a set of tests. 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."
-
- | source matcher |
- source := anArray first.
- matcher := self compileRegex: source.
- matcher isNil
- ifTrue: [
- (anArray at: 2) isNil
- ifFalse: [ self signalFailure: 'Compilation failed, should have succeeded: ' , source printString ] ]
- ifFalse: [
- (anArray at: 2) isNil
- ifTrue: [ self signalFailure: 'Compilation succeeded, should have failed: ' , source printString ]
- ifFalse: [
- anArray allButFirst groupsDo: [ :input :shouldMatch :expectedOutput |
- self
- runMatcher: matcher
- with: input
- expect: shouldMatch
- withSubexpressions: expectedOutput ] ] ]!
Item was removed:
- ----- Method: RxMatcherTest>>testCaseInsensitive (in category 'testing-protocol') -----
- testCaseInsensitive
- | matcher |
- matcher := self matcherClass forString: 'the quick brown fox' ignoreCase: true.
- self assert: (matcher search: 'the quick brown fox').
- self assert: (matcher search: 'The quick brown FOX').
- self assert: (matcher search: 'What do you know about the quick brown fox?').
- self assert: (matcher search: 'What do you know about THE QUICK BROWN FOX?')!
Item was removed:
- ----- Method: RxMatcherTest>>testCaseSensitive (in category 'testing-protocol') -----
- testCaseSensitive
- | matcher |
- matcher := self matcherClass forString: 'the quick brown fox' ignoreCase: false.
- self assert: (matcher search: 'the quick brown fox').
- self deny: (matcher search: 'The quick brown FOX').
- self assert: (matcher search: 'What do you know about the quick brown fox?').
- self deny: (matcher search: 'What do you know about THE QUICK BROWN FOX?')!
Item was removed:
- ----- Method: RxMatcherTest>>testCopyReplacingMatches (in category 'testing-protocol') -----
- testCopyReplacingMatches
- "See that the match context is preserved while copying stuff between matches:"
-
- | matcher |
- matcher := self matcherClass forString: '\<\d\D+'.
- self assert: (matcher copy: '9aaa1bbb 8ccc' replacingMatchesWith: 'foo')
- = 'foo1bbb foo'!
Item was removed:
- ----- Method: RxMatcherTest>>testCopyTranslatingMatches (in category 'testing-protocol') -----
- testCopyTranslatingMatches
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher copy: 'now is the time ' translatingMatchesUsing: [ :each | each reversed ])
- = 'won si eht emit '!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringAtBeginningOfLine (in category 'testing-empty') -----
- testEmptyStringAtBeginningOfLine
- | matcher |
- matcher := self matcherClass forString: '^'.
- self
- assert: (matcher copy: 'foo1 bar1' , String cr , 'foo2 bar2' replacingMatchesWith: '*')
- = ('*foo1 bar1' , String cr , '*foo2 bar2')
- description: 'An empty string at the beginning of a line'!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringAtBeginningOfWord (in category 'testing-empty') -----
- testEmptyStringAtBeginningOfWord
- | matcher |
- matcher := self matcherClass forString: '\<'.
- self
- assert: (matcher copy: 'foo bar' replacingMatchesWith: '*')
- = '*foo *bar'
- description: 'An empty string at the beginning of a word'!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringAtEndOfLine (in category 'testing-empty') -----
- testEmptyStringAtEndOfLine
- | matcher |
- matcher := self matcherClass forString: '$'.
- self
- assert: (matcher copy: 'foo1 bar1' , String cr , 'foo2 bar2' replacingMatchesWith: '*')
- = ('foo1 bar1*', String cr , 'foo2 bar2*')
- description: 'An empty string at the end of a line'!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringAtEndOfWord (in category 'testing-empty') -----
- testEmptyStringAtEndOfWord
- | matcher |
- matcher := self matcherClass forString: '\>'.
- self
- assert: (matcher copy: 'foo bar' replacingMatchesWith: '*')
- = 'foo* bar*'
- description: 'An empty string at the end of a word'!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringAtWordBoundary (in category 'testing-empty') -----
- testEmptyStringAtWordBoundary
- | matcher |
- matcher := self matcherClass forString: '\b'.
- self
- assert: (matcher copy: 'foo bar' replacingMatchesWith: '*')
- = '*foo* *bar*'
- description: 'An empty string at a word boundary'!
Item was removed:
- ----- Method: RxMatcherTest>>testEmptyStringNotAtWordBoundary (in category 'testing-empty') -----
- testEmptyStringNotAtWordBoundary
- | matcher |
- matcher := self matcherClass forString: '\B'.
- self
- assert: (matcher copy: 'foo bar' replacingMatchesWith: '*')
- = 'f*o*o b*a*r'
- description: 'An empty string not at a word boundary'!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry001 (in category 'testing-henry') -----
- testHenry001
- self runRegex: #('abc'
- 'abc' true (1 'abc')
- 'xbc' false nil
- 'axc' false nil
- 'abx' false nil
- 'xabcy' true (1 'abc')
- 'ababc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry002 (in category 'testing-henry') -----
- testHenry002
- self runRegex: #('ab*c'
- 'abc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry003 (in category 'testing-henry') -----
- testHenry003
- self runRegex: #('ab*bc'
- 'abc' true (1 'abc')
- 'abbc' true (1 'abbc')
- 'abbbbc' true (1 'abbbbc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry004 (in category 'testing-henry') -----
- testHenry004
- self runRegex: #('ab+bc'
- 'abbc' true (1 'abbc')
- 'abc' false nil
- 'abq' false nil
- 'abbbbc' true (1 'abbbbc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry005 (in category 'testing-henry') -----
- testHenry005
- self runRegex: #('ab?bc'
- 'abbc' true (1 'abbc')
- 'abc' true (1 'abc')
- 'abbbbc' false nil
- 'abc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry006 (in category 'testing-henry') -----
- testHenry006
- self runRegex: #('^abc$'
- 'abc' true (1 'abc')
- 'abcc' false nil
- 'aabc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry007 (in category 'testing-henry') -----
- testHenry007
- self runRegex: #('^abc'
- 'abcc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry008 (in category 'testing-henry') -----
- testHenry008
- self runRegex: #('abc$'
- 'aabc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry009 (in category 'testing-henry') -----
- testHenry009
- self runRegex: #('^'
- 'abc' true nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry010 (in category 'testing-henry') -----
- testHenry010
- self runRegex: #('$'
- 'abc' true nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry011 (in category 'testing-henry') -----
- testHenry011
- self runRegex: #('a.c'
- 'abc' true (1 'abc')
- 'axc' true (1 'axc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry012 (in category 'testing-henry') -----
- testHenry012
- "Need to get creative to include the null character..."
- self runRegex: #('a.*c'
- 'axyzc' true (1 'axyzc')
- 'axy zc' true (1 'axy zc') "testing that a dot matches a space"
- ), (Array with: 'axy', (String with: 0 asCharacter), 'zc'), #(false nil "testing that a dot does not match a null"
- 'axyzd' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry013 (in category 'testing-henry') -----
- testHenry013
- self runRegex: #('.a.*'
- '1234abc' true (1 '4abc')
- 'abcd' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry014 (in category 'testing-henry') -----
- testHenry014
- self runRegex: #('a\w+c'
- ' abbbbc ' true (1 'abbbbc')
- 'abb bc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry015 (in category 'testing-henry') -----
- testHenry015
- self runRegex: #('\w+'
- ' foobar quux' true (1 'foobar')
- ' ~!!@#$%^&*()-+=\|/?.>,<' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry016 (in category 'testing-henry') -----
- testHenry016
- self runRegex: #('a\W+c'
- 'a c' true (1 'a c')
- 'a bc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry017 (in category 'testing-henry') -----
- testHenry017
- self runRegex: #('\W+'
- 'foo!!@#$bar' true (1 '!!@#$')
- 'foobar' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry018 (in category 'testing-henry') -----
- testHenry018
- self runRegex: #('a\s*c'
- 'a c' true (1 'a c')
- 'a bc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry019 (in category 'testing-henry') -----
- testHenry019
- self runRegex: #('\s+'
- 'abc3457 sd' true (1 ' ')
- '1234$^*^&asdfb' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry020 (in category 'testing-henry') -----
- testHenry020
- self runRegex: #('a\S*c'
- 'aqwertyc' true (1 'aqwertyc')
- 'ab c' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry021 (in category 'testing-henry') -----
- testHenry021
- self runRegex: #('\S+'
- ' asdf ' true (1 'asdf')
- '
- ' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry022 (in category 'testing-henry') -----
- testHenry022
- self runRegex: #('a\d+c'
- 'a0123456789c' true (1 'a0123456789c')
- 'a12b34c' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry023 (in category 'testing-henry') -----
- testHenry023
- self runRegex: #('\d+'
- 'foo@#$%123ASD #$$%^&' true (1 '123')
- 'foo!!@#$asdfl;' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry024 (in category 'testing-henry') -----
- testHenry024
- self runRegex: #('a\D+c'
- 'aqwertyc' true (1 'aqwertyc')
- 'aqw6ertc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry025 (in category 'testing-henry') -----
- testHenry025
- self runRegex: #('\D+'
- '1234 abc 456' true (1 ' abc ')
- '1234567890' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry026 (in category 'testing-henry') -----
- testHenry026
- self runRegex: #('(f|o)+\b'
- 'foo' true (1 'foo')
- ' foo ' true (1 'foo'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry027 (in category 'testing-henry') -----
- testHenry027
- self runRegex: #('\ba\w+' "a word beginning with an A"
- 'land ancient' true (1 'ancient')
- 'antique vase' true (1 'antique')
- 'goofy foobar' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry028 (in category 'testing-henry') -----
- testHenry028
- self runRegex: #('(f|o)+\B'
- 'quuxfoobar' true (1 'foo')
- 'quuxfoo ' true (1 'fo'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry029 (in category 'testing-henry') -----
- testHenry029
- self runRegex: #('\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)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry030 (in category 'testing-henry') -----
- testHenry030
- self runRegex: #('fooa\>.*'
- 'fooa ' true nil
- 'fooa123' false nil
- 'fooa bar' true nil
- 'fooa' true nil
- 'fooargh' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry031 (in category 'testing-henry') -----
- testHenry031
- self runRegex: #('\>.+abc'
- ' abcde fg' false nil
- 'foo abcde' true (1 ' abc')
- 'abcde' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry032 (in category 'testing-henry') -----
- testHenry032
- self runRegex: #('\<foo.*'
- 'foo' true nil
- 'foobar' true nil
- 'qfoobarq foonix' true (1 'foonix')
- ' foo' true nil
- ' 12foo' false nil
- 'barfoo' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry033 (in category 'testing-henry') -----
- testHenry033
- self runRegex: #('.+\<foo'
- 'foo' false nil
- 'ab foo' true (1 'ab foo')
- 'abfoo' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry034 (in category 'testing-henry') -----
- testHenry034
- self runRegex: #('a[bc]d'
- 'abc' false nil
- 'abd' true (1 'abd'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry035 (in category 'testing-henry') -----
- testHenry035
- self runRegex: #('a[b-d]e'
- 'abd' false nil
- 'ace' true (1 'ace'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry036 (in category 'testing-henry') -----
- testHenry036
- self runRegex: #('a[b-d]'
- 'aac' true (1 'ac'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry037 (in category 'testing-henry') -----
- testHenry037
- self runRegex: #('a[-b]'
- 'a-' true (1 'a-'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry038 (in category 'testing-henry') -----
- testHenry038
- self runRegex: #('a[b-]'
- 'a-' true (1 'a-'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry039 (in category 'testing-henry') -----
- testHenry039
- self runRegex: #('a[a-b-c]' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry040 (in category 'testing-henry') -----
- testHenry040
- self runRegex: #('[k]'
- 'ab' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry041 (in category 'testing-henry') -----
- testHenry041
- self runRegex: #('a[b-a]' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry042 (in category 'testing-henry') -----
- testHenry042
- self runRegex: #('a[]b' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry043 (in category 'testing-henry') -----
- testHenry043
- self runRegex: #('a[' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry044 (in category 'testing-henry') -----
- testHenry044
- self runRegex: #('a]'
- 'a]' true (1 'a]'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry045 (in category 'testing-henry') -----
- testHenry045
- self runRegex: #('a[]]b'
- 'a]b' true (1 'a]b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry046 (in category 'testing-henry') -----
- testHenry046
- self runRegex: #('a[^bc]d'
- 'aed' true (1 'aed')
- 'abd' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry047 (in category 'testing-henry') -----
- testHenry047
- self runRegex: #('a[^-b]c'
- 'adc' true (1 'adc')
- 'a-c' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry048 (in category 'testing-henry') -----
- testHenry048
- self runRegex: #('a[^]b]c'
- 'a]c' false nil
- 'adc' true (1 'adc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry049 (in category 'testing-henry') -----
- testHenry049
- self runRegex: #('[\de]+'
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry050 (in category 'testing-henry') -----
- testHenry050
- self runRegex: #('[e\d]+' "reversal of the above, should be the same"
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry051 (in category 'testing-henry') -----
- testHenry051
- self runRegex: #('[\D]+'
- '123abc45def78' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry052 (in category 'testing-henry') -----
- testHenry052
- self runRegex: #('[[:digit:]e]+'
- '01234' true (1 '01234')
- '0123e456' true (1 '0123e456')
- '0123e45g78' true (1 '0123e45'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry053 (in category 'testing-henry') -----
- testHenry053
- self runRegex: #('[\s]+'
- '2 spaces' true (1 ' '))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry054 (in category 'testing-henry') -----
- testHenry054
- self runRegex: #('[\S]+'
- ' word12!!@#$ ' true (1 'word12!!@#$'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry055 (in category 'testing-henry') -----
- testHenry055
- self runRegex: #('[\w]+'
- ' foo123bar 45' true (1 'foo123bar'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry056 (in category 'testing-henry') -----
- testHenry056
- self runRegex: #('[\W]+'
- 'fii234!!@#$34f' true (1 '!!@#$'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry057 (in category 'testing-henry') -----
- testHenry057
- self runRegex: #('[^[:alnum:]]+'
- 'fii234!!@#$34f' true (1 '!!@#$'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry058 (in category 'testing-henry') -----
- testHenry058
- self runRegex: #('[%&[:alnum:]]+'
- 'foo%3' true (1 'foo%3')
- 'foo34&rt4$57a' true (1 'foo34&rt4')
- '!!@#$' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry059 (in category 'testing-henry') -----
- testHenry059
- self runRegex: #('[[:alpha:]]+'
- ' 123foo3 ' true (1 'foo')
- '123foo' true (1 'foo')
- 'foo1b' true (1 'foo'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry060 (in category 'testing-henry') -----
- testHenry060
- self runRegex: #('[[:cntrl:]]+'
- ' a 1234asdf' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry061 (in category 'testing-henry') -----
- testHenry061
- self runRegex: #('[[:lower:]]+'
- 'UPPERlower1234' true (1 'lower')
- 'lowerUPPER' true (1 'lower'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry062 (in category 'testing-henry') -----
- testHenry062
- self runRegex: #('[[:upper:]]+'
- 'UPPERlower1234' true (1 'UPPER')
- 'lowerUPPER ' true (1 'UPPER'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry063 (in category 'testing-henry') -----
- testHenry063
- self runRegex: #('[[:space:]]+'
- '2 spaces' true (1 ' '))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry064 (in category 'testing-henry') -----
- testHenry064
- self runRegex: #('[^[:space:]]+'
- ' word12!!@#$ ' true (1 'word12!!@#$'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry065 (in category 'testing-henry') -----
- testHenry065
- self runRegex: #('[[:graph:]]+'
- 'abc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry066 (in category 'testing-henry') -----
- testHenry066
- self runRegex: #('[[:print:]]+'
- 'abc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry067 (in category 'testing-henry') -----
- testHenry067
- self runRegex: #('[^[:punct:]]+'
- '!!hello,world!!' true (1 'hello'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry068 (in category 'testing-henry') -----
- testHenry068
- self runRegex: #('[[:xdigit:]]+'
- ' x10FCD ' true (1 '10FCD')
- ' hgfedcba0123456789ABCDEFGH '
- true (1 'fedcba0123456789ABCDEF'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry069 (in category 'testing-henry') -----
- testHenry069
- self runRegex: #('ab|cd'
- 'abc' true (1 'ab')
- 'abcd' true (1 'ab'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry070 (in category 'testing-henry') -----
- testHenry070
- self runRegex: #('()ef'
- 'def' true (1 'ef' 2 ''))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry071 (in category 'testing-henry') -----
- testHenry071
- self runRegex: #('()*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry072 (in category 'testing-henry') -----
- testHenry072
- self runRegex: #('*a' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry073 (in category 'testing-henry') -----
- testHenry073
- self runRegex: #('^*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry074 (in category 'testing-henry') -----
- testHenry074
- self runRegex: #('$*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry075 (in category 'testing-henry') -----
- testHenry075
- self runRegex: #('(*)b' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry076 (in category 'testing-henry') -----
- testHenry076
- self runRegex: #('$b' 'b' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry077 (in category 'testing-henry') -----
- testHenry077
- self runRegex: #('a\' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry078 (in category 'testing-henry') -----
- testHenry078
- self runRegex: #('a\(b'
- 'a(b' true (1 'a(b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry079 (in category 'testing-henry') -----
- testHenry079
- self runRegex: #('a\(*b'
- 'ab' true (1 'ab')
- 'a((b' true (1 'a((b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry080 (in category 'testing-henry') -----
- testHenry080
- self runRegex: #('a\\b'
- 'a\b' true (1 'a\b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry081 (in category 'testing-henry') -----
- testHenry081
- self runRegex: #('abc)' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry082 (in category 'testing-henry') -----
- testHenry082
- self runRegex: #('(abc' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry083 (in category 'testing-henry') -----
- testHenry083
- self runRegex: #('((a))'
- 'abc' true (1 'a' 2 'a' 3 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry084 (in category 'testing-henry') -----
- testHenry084
- self runRegex: #('(a)b(c)'
- 'abc' true (1 'abc' 2 'a' 3 'c'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry085 (in category 'testing-henry') -----
- testHenry085
- self runRegex: #('a+b+c'
- 'aabbabc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry086 (in category 'testing-henry') -----
- testHenry086
- self runRegex: #('a**' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry087 (in category 'testing-henry') -----
- testHenry087
- self runRegex: #('a*?' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry088 (in category 'testing-henry') -----
- testHenry088
- self runRegex: #('(a*)*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry089 (in category 'testing-henry') -----
- testHenry089
- self runRegex: #('(a*)+' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry090 (in category 'testing-henry') -----
- testHenry090
- self runRegex: #('(a|)*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry091 (in category 'testing-henry') -----
- testHenry091
- self runRegex: #('(a*|b)*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry092 (in category 'testing-henry') -----
- testHenry092
- self runRegex: #('(a+|b)*'
- 'ab' true (1 'ab' 2 'b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry093 (in category 'testing-henry') -----
- testHenry093
- self runRegex: #('(a+|b)+'
- 'ab' true (1 'ab' 2 'b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry094 (in category 'testing-henry') -----
- testHenry094
- self runRegex: #('(a+|b)?'
- 'ab' true (1 'a' 2 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry095 (in category 'testing-henry') -----
- testHenry095
- self runRegex: #('[^ab]*'
- 'cde' true (1 'cde'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry096 (in category 'testing-henry') -----
- testHenry096
- self runRegex: #('(^)*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry097 (in category 'testing-henry') -----
- testHenry097
- self runRegex: #('(ab|)*' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry098 (in category 'testing-henry') -----
- testHenry098
- self runRegex: #(')(' nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry099 (in category 'testing-henry') -----
- testHenry099
- self runRegex: #('' 'abc' true (1 ''))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry100 (in category 'testing-henry') -----
- testHenry100
- self runRegex: #('abc' '' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry101 (in category 'testing-henry') -----
- testHenry101
- self runRegex: #('a*'
- '' true '')!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry102 (in category 'testing-henry') -----
- testHenry102
- self runRegex: #('abcd'
- 'abcd' true (1 'abcd'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry103 (in category 'testing-henry') -----
- testHenry103
- self runRegex: #('a(bc)d'
- 'abcd' true (1 'abcd' 2 'bc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry104 (in category 'testing-henry') -----
- testHenry104
- self runRegex: #('([abc])*d'
- 'abbbcd' true (1 'abbbcd' 2 'c'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry105 (in category 'testing-henry') -----
- testHenry105
- self runRegex: #('([abc])*bcd'
- 'abcd' true (1 'abcd' 2 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry106 (in category 'testing-henry') -----
- testHenry106
- self runRegex: #('a|b|c|d|e' 'e' true (1 'e'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry107 (in category 'testing-henry') -----
- testHenry107
- self runRegex: #('(a|b|c|d|e)f'
- 'ef' true (1 'ef' 2 'e'))
- " ((a*|b))* - c - -"!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry108 (in category 'testing-henry') -----
- testHenry108
- self runRegex: #('abcd*efg'
- 'abcdefg' true (1 'abcdefg'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry109 (in category 'testing-henry') -----
- testHenry109
- self runRegex: #('ab*'
- 'xabyabbbz' true (1 'ab')
- 'xayabbbz' true (1 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry110 (in category 'testing-henry') -----
- testHenry110
- self runRegex: #('(ab|cd)e' 'abcde' true (1 'cde' 2 'cd'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry111 (in category 'testing-henry') -----
- testHenry111
- self runRegex: #('[abhgefdc]ij' 'hij' true (1 'hij'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry112 (in category 'testing-henry') -----
- testHenry112
- self runRegex: #('^(ab|cd)e' 'abcde' false nil)
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry113 (in category 'testing-henry') -----
- testHenry113
- self runRegex: #('(abc|)def' 'abcdef' true nil)
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry114 (in category 'testing-henry') -----
- testHenry114
- self runRegex: #('(a|b)c*d' 'abcd' true (1 'bcd' 2 'b'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry115 (in category 'testing-henry') -----
- testHenry115
- self runRegex: #('(ab|ab*)bc' 'abc' true (1 'abc' 2 'a'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry116 (in category 'testing-henry') -----
- testHenry116
- self runRegex: #('a([bc]*)c*' 'abc' true (1 'abc' 2 'bc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry117 (in category 'testing-henry') -----
- testHenry117
- self runRegex: #('a([bc]*)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry118 (in category 'testing-henry') -----
- testHenry118
- self runRegex: #('a([bc]+)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry119 (in category 'testing-henry') -----
- testHenry119
- self runRegex: #('a([bc]*)(c+d)' 'abcd' true (1 'abcd' 2 'b' 3 'cd'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry120 (in category 'testing-henry') -----
- testHenry120
- self runRegex: #('a[bcd]*dcdcde' 'adcdcde' true (1 'adcdcde'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry121 (in category 'testing-henry') -----
- testHenry121
- self runRegex: #('a[bcd]+dcdcde' 'adcdcde' false nil)
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry122 (in category 'testing-henry') -----
- testHenry122
- self runRegex: #('(ab|a)b*c' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry123 (in category 'testing-henry') -----
- testHenry123
- self runRegex: #('((a)(b)c)(d)' 'abcd' true (1 'abcd' 3 'a' 4 'b' 5 'd'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry124 (in category 'testing-henry') -----
- testHenry124
- self runRegex: #('[ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry125 (in category 'testing-henry') -----
- testHenry125
- self runRegex: #('[ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry126 (in category 'testing-henry') -----
- testHenry126
- self runRegex: #('[ -~ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry127 (in category 'testing-henry') -----
- testHenry127
- self runRegex: #('[ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry128 (in category 'testing-henry') -----
- testHenry128
- self runRegex: #('[ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry129 (in category 'testing-henry') -----
- testHenry129
- self runRegex: #('[ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry130 (in category 'testing-henry') -----
- testHenry130
- self runRegex: #('[ -~ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry131 (in category 'testing-henry') -----
- testHenry131
- self runRegex: #('[a-zA-Z_][a-zA-Z0-9_]*' 'alpha' true (1 'alpha'))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry132 (in category 'testing-henry') -----
- testHenry132
- self runRegex: #('^a(bc+|b[eh])g|.h$' 'abh' true (1 'bh' 2 nil))
- !
Item was removed:
- ----- Method: RxMatcherTest>>testHenry133 (in category 'testing-henry') -----
- testHenry133
- self runRegex: #('(bc+d$|ef*g.|h?i(j|k))'
- 'effgz' true (1 'effgz' 2 'effgz' 3 nil)
- 'ij' true (1 'ij' 2 'ij' 3 'j')
- 'effg' false nil
- 'bcdd' false nil
- 'reffgz' true (1 'effgz' 2 'effgz' 3 nil))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry134 (in category 'testing-henry') -----
- testHenry134
- self runRegex: #('(((((((((a)))))))))' 'a' true (1 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry135 (in category 'testing-henry') -----
- testHenry135
- self runRegex: #('multiple words of text'
- 'uh-uh' false nil
- 'multiple words of text, yeah' true (1 'multiple words of text'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry136 (in category 'testing-henry') -----
- testHenry136
- self runRegex: #('(.*)c(.*)' 'abcde' true (1 'abcde' 2 'ab' 3 'de'))!
Item was removed:
- ----- Method: RxMatcherTest>>testHenry137 (in category 'testing-henry') -----
- testHenry137
- self runRegex: #('\((.*), (.*)\)' '(a, b)' true (2 'a' 3 'b'))!
Item was removed:
- ----- Method: RxMatcherTest>>testMatches (in category 'testing-protocol') -----
- testMatches
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher matches: 'now').
- self deny: (matcher matches: 'now is')!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesIn (in category 'testing-protocol') -----
- testMatchesIn
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher matchesIn: 'now is the time') asArray
- = #('now' 'is' 'the' 'time')!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesInCollect (in category 'testing-protocol') -----
- testMatchesInCollect
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher
- matchesIn: 'now is the time'
- collect: [ :each | each reversed ]) asArray
- = #('won' 'si' 'eht' 'emit')!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesInDo (in category 'testing-protocol') -----
- testMatchesInDo
- | matcher expected |
- matcher := self matcherClass forString: '\w+'.
- expected := #('now' 'is' 'the' 'time') asOrderedCollection.
- matcher
- matchesIn: 'now is the time'
- do: [ :each | self assert: each = expected removeFirst ].
- self assert: expected isEmpty!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesOnStream (in category 'testing-protocol') -----
- testMatchesOnStream
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher matchesOnStream: 'now is the time' readStream) asArray
- = #('now' 'is' 'the' 'time')!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesOnStreamCollect (in category 'testing-protocol') -----
- testMatchesOnStreamCollect
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher
- matchesOnStream: 'now is the time' readStream
- collect: [ :each | each reversed ]) asArray
- = #('won' 'si' 'eht' 'emit')!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesOnStreamDo (in category 'testing-protocol') -----
- testMatchesOnStreamDo
- | matcher expected |
- matcher := self matcherClass forString: '\w+'.
- expected := #('now' 'is' 'the' 'time') asOrderedCollection.
- matcher
- matchesOnStream: 'now is the time' readStream
- do: [ :each | self assert: each = expected removeFirst ].
- self assert: expected isEmpty!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchesStream (in category 'testing-protocol') -----
- testMatchesStream
- | matcher |
- matcher := self matcherClass forString: '\w+'.
- self assert: (matcher matchesStream: 'now' readStream).
- self deny: (matcher matchesStream: 'now is' readStream)!
Item was removed:
- ----- Method: RxMatcherTest>>testMatchingRangesIn (in category 'testing-protocol') -----
- testMatchingRangesIn
- | matcher expected |
- matcher := self matcherClass forString: '\w+'.
- expected := #(1 3 5 6 8 10 12 15) asOrderedCollection.
- (matcher matchingRangesIn: 'now is the time') do: [ :range |
- self assert: range first = expected removeFirst.
- self assert: range last = expected removeFirst ].
- self assert: expected isEmpty!
Item was removed:
- ----- Method: RxMatcherTest>>testOptionalMultipleQuantifiedSubexpression (in category 'testing') -----
- testOptionalMultipleQuantifiedSubexpression
- <timeout: 0.1>
-
- self runRegex: #('((aa?){2})'
- '' false nil
- 'a' false nil
- 'aa' true (1 'aa')
- 'baaa' true (1 'aaa' 2 'aaa'))!
Item was removed:
- ----- Method: RxMatcherTest>>testOptionalNestedIntoMultipleQuantified (in category 'testing') -----
- testOptionalNestedIntoMultipleQuantified
- <timeout: 0.1>
-
- self runRegex: #('(aa?){2}'
- '' false nil
- 'a' false nil
- 'aa' true (1 'aa')
- 'baaa' true (1 'aaa' 2 'a'))!
Item was removed:
- ----- Method: RxMatcherTest>>testRegex001 (in category 'testing') -----
- testRegex001
- self runRegex: #('^.*$'
- '' true (1 '')
- 'a' true (1 'a')
- 'abc' true (1 'abc'))!
Item was removed:
- ----- Method: RxMatcherTest>>testRegex002 (in category 'testing') -----
- testRegex002
- self runRegex: #('a\w+c'
- ' abb_bbc ' true (1 'abb_bbc')
- 'abb-bc' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testRegex003 (in category 'testing') -----
- testRegex003
- self runRegex: #('a\W+c'
- ' abb_bbc ' false nil
- 'abb-bc' false nil
- 'a.,:;-&!!"#%/()={[]}+?\~*''c' true (1 'a.,:;-&!!"#%/()={[]}+?\~*''c'))!
Item was removed:
- ----- Method: RxMatcherTest>>testRegex004 (in category 'testing') -----
- testRegex004
- self runRegex: #(':isVowel:'
- 'aei' true nil
- 'xyz' false nil)!
Item was removed:
- ----- Method: RxMatcherTest>>testStringAllRangesOfRegexMatches (in category 'testing-extensions') -----
- testStringAllRangesOfRegexMatches
- | result |
- result := 'aabbcc' allRangesOfRegexMatches: 'b+'.
- self assert: result size = 1.
- self assert: result first first = 3.
- self assert: result first last = 4
- !
Item was removed:
- ----- Method: RxMatcherTest>>testStringAllRegexMatches (in category 'testing-extensions') -----
- testStringAllRegexMatches
- | result |
- result := 'aabbcc' allRegexMatches: 'b+'.
- self assert: result size = 1.
- self assert: result first = 'bb'!
Item was removed:
- ----- Method: RxMatcherTest>>testStringAsRegex (in category 'testing-extensions') -----
- testStringAsRegex
- self assert: 'b+' asRegex class = RxParser preferredMatcherClass!
Item was removed:
- ----- Method: RxMatcherTest>>testStringAsRegexIgnoringCase (in category 'testing-extensions') -----
- testStringAsRegexIgnoringCase
- self assert: 'b+' asRegexIgnoringCase class = RxParser preferredMatcherClass!
Item was removed:
- ----- Method: RxMatcherTest>>testStringCopyWithRegexMatchesReplacedWith (in category 'testing-extensions') -----
- testStringCopyWithRegexMatchesReplacedWith
- self assert: ('aabbcc' copyWithRegex: 'b+' matchesReplacedWith: 'X') = 'aaXcc'!
Item was removed:
- ----- Method: RxMatcherTest>>testStringCopyWithRegexMatchesTranslatedUsing (in category 'testing-extensions') -----
- testStringCopyWithRegexMatchesTranslatedUsing
- self assert: ('aabbcc'
- copyWithRegex: 'b+'
- matchesTranslatedUsing: [ :each |
- self assert: each = 'bb'.
- 'X' ]) = 'aaXcc'!
Item was removed:
- ----- Method: RxMatcherTest>>testStringMatchesRegex (in category 'testing-extensions') -----
- testStringMatchesRegex
- self deny: ('aabbcc' matchesRegex: 'a+').
- self deny: ('aabbcc' matchesRegex: 'b+c+').
- self assert: ('aabbcc' matchesRegex: 'a+b+c+')!
Item was removed:
- ----- Method: RxMatcherTest>>testStringMatchesRegexIgnoringCase (in category 'testing-extensions') -----
- testStringMatchesRegexIgnoringCase
- self deny: ('AABBCC' matchesRegexIgnoringCase: 'a+').
- self deny: ('AABBCC' matchesRegexIgnoringCase: 'b+c+').
- self assert: ('AABBCC' matchesRegexIgnoringCase: 'a+b+c+')!
Item was removed:
- ----- Method: RxMatcherTest>>testStringPrefixMatchesRegex (in category 'testing-extensions') -----
- testStringPrefixMatchesRegex
- self assert: ('aabbcc' prefixMatchesRegex: 'a+').
- self deny: ('aabbcc' prefixMatchesRegex: 'b+')!
Item was removed:
- ----- Method: RxMatcherTest>>testStringPrefixMatchesRegexIgnoringCase (in category 'testing-extensions') -----
- testStringPrefixMatchesRegexIgnoringCase
- self assert: ('AABBCC' prefixMatchesRegexIgnoringCase: 'a+').
- self deny: ('AABBCC' prefixMatchesRegexIgnoringCase: 'b+')!
Item was removed:
- ----- Method: RxMatcherTest>>testStringRegexMatchesCollect (in category 'testing-extensions') -----
- testStringRegexMatchesCollect
- | result |
- result := 'aabbcc' regex: 'b+' matchesCollect: [ :each | each asUppercase ].
- self assert: result size = 1.
- self assert: result first = 'BB'!
Item was removed:
- ----- Method: RxMatcherTest>>testStringRegexMatchesDo (in category 'testing-extensions') -----
- testStringRegexMatchesDo
- | result |
- result := OrderedCollection new.
- 'aabbcc' regex: 'b+' matchesDo: [ :each | result add: each ].
- self assert: result size = 1.
- self assert: result first = 'bb'!
Item was removed:
- ----- Method: RxMatcherTest>>testSubexpressionCount (in category 'testing-protocol') -----
- testSubexpressionCount
- | matcher |
- #(('a' 1) ('a(b)' 2) ('a(b(c))' 3) ('(a)(b)' 3) ('(a(b))*' 3)) do: [ :pair |
- matcher := self matcherClass forString: pair first.
- matcher supportsSubexpressions
- ifTrue: [ self assert: matcher subexpressionCount = pair last ] ]!
Item was removed:
- TestCase subclass: #RxParserTest
- instanceVariableNames: ''
- classVariableNames: ''
- poolDictionaries: ''
- category: 'Regex-Tests-Core'!
-
- !RxParserTest commentStamp: 'Tbn 11/12/2010 22:31' prior: 0!
- This class provides tests for the regular expression parser.!
Item was removed:
- ----- Method: RxParserTest>>DoesNotWorktestBackQuotesEscape (in category 'tests') -----
- DoesNotWorktestBackQuotesEscape
- "self debug: #testBackQuotesEscape"
-
- "Regular expressions can also include the following backquote escapes
- to refer to popular classes of characters:
- \w any word constituent character (same as [a-zA-Z0-9:=])
- \W any character but a word constituent
- \d a digit (same as [0-9])
- \D anything but a digit
- \s a whitespace character
- \S anything but a whitespace character
- These escapes are also allowed in character classes: '[\w+-]' means
- 'any character that is either a word constituent, or a plus, or a
- minus'."
-
- self assert: ('one word' matchesRegex: '\w').
-
- self assert: ('one' matchesRegex: '\w').
- !
Item was removed:
- ----- Method: RxParserTest>>test (in category 'tests') -----
- test
- "self debug: #test"
-
-
- self assert: ('\<t\w+' asRegexIgnoringCase
- 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"!
Item was removed:
- ----- Method: RxParserTest>>testCadrMatching (in category 'tests') -----
- testCadrMatching
- "self debug: #testCadrMatching"
-
- "A bit more complex example is the following expression, matching the
- name of any of the Lisp-style `car', `cdr', `caar', `cadr',
- ... functions:"
-
- self assert: ( 'car' matchesRegex: 'c(a|d)+r').
- self assert: ( 'cdr' matchesRegex: 'c(a|d)+r').
- self assert: ( 'caar' matchesRegex: 'c(a|d)+r').
- self assert: ( 'cadr' matchesRegex: 'c(a|d)+r').
- self assert: ( 'caddar' matchesRegex: 'c(a|d)+r').!
Item was removed:
- ----- Method: RxParserTest>>testCharacterSet (in category 'tests') -----
- 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 deny: ('11' matchesRegex: '[01]'). "-- false: a set matches only one character"
- self deny: ('01' matchesRegex: '[01]').
- !
Item was removed:
- ----- Method: RxParserTest>>testCharacterSetBinaryNumber (in category 'tests') -----
- 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]+') !
Item was removed:
- ----- Method: RxParserTest>>testCharacterSetInversion (in category 'tests') -----
- 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]').
- "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]').
- "there is one zero so it does not match"!
Item was removed:
- ----- Method: RxParserTest>>testCharacterSetRange (in category 'tests') -----
- 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]').
- self deny: ('a' matchesRegex: '[0-9]').
- self deny: ('01' matchesRegex: '[0-9]').
- self assert: ('01442128629839374565' matchesRegex: '[0-9]+').
- !
Item was removed:
- ----- Method: RxParserTest>>testCharacterSetWithEscapedAndRange (in category 'tests') -----
- testCharacterSetWithEscapedAndRange
-
- " two examples of where a - should not parse as a range "
- self assert: ('[\+-]' asRegex matches: '+').
- self assert: ('[\+\-]' asRegex matches: '-').
-
- " construct a range from an escaped + (43) to digit 4 (52) "
- self assert: ('[\+-4]' asRegex matches: '3')!
Item was removed:
- ----- Method: RxParserTest>>testCharacterSetWithEscapedCharacters (in category 'tests') -----
- testCharacterSetWithEscapedCharacters
- "self debug: #testCharacterSetRange"
-
- {
- '[\r]'. String cr. String space.
- '[\n]'. String lf. String space.
- '[\t]'. String tab. String space.
- '[\e]'. Character escape asString. String space.
- '[\f]'. Character newPage asString. String space.
- '[\]]+'. ']]]'. '[[['.
- '[\S]+[\s]+=[\s]+#[^\[(]'. 'foo = #bar'. 'foo = #[1 2 3]'.
- '[\d]+'. '123'. 'abc'.
- '[\D]+'. 'abc'. '123'.
- '[\w]+'. 'a1_b2'. '...'.
- '[\W]+'. '...'. 'a1_b2'.
- } groupsDo: [ :regexString :inputToAccept :inputToReject |
- | regex |
- regex := regexString asRegex.
- self
- assert: (regex search: inputToAccept);
- deny: (regex search: inputToReject) ]!
Item was removed:
- ----- Method: RxParserTest>>testLookaroundNullable (in category 'tests') -----
- testLookaroundNullable
-
- self should: ['(?<=a)?b' asRegex] raise: RegexSyntaxError.!
Item was removed:
- ----- Method: RxParserTest>>testMatchesInwW (in category 'tests') -----
- 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 = #(' ' ' ' ' ').
-
- "why do we get that"
- self assert: ('\w' asRegex matchesIn: 'now') asArray = #('n' 'o' 'w').!
Item was removed:
- ----- Method: RxParserTest>>testNegativeLookahead (in category 'tests') -----
- testNegativeLookahead
- self assert: ['A' matchesRegex: 'A(?!!BC).*'].
- self assert: ['AB' matchesRegex: 'A(?!!BC).*'].
- self deny: ['ABC' matchesRegex: 'A(?!!BC).*'].
- self deny: ['ABCD' matchesRegex: 'A(?!!BC).*'].!
Item was removed:
- ----- Method: RxParserTest>>testNegativeLookbehind (in category 'tests') -----
- testNegativeLookbehind
- self assert: ['C' matchesRegex: '.*(?<!!AB)C'].
- self assert: ['BC' matchesRegex: '.*(?<!!AB)C'].
- self deny: ['ABC' matchesRegex: '.*(?<!!AB)C'].
- self deny: ['ABCD' matchesRegex: '.*(?<!!AB)C'].!
Item was removed:
- ----- Method: RxParserTest>>testOptionalLookbehind (in category 'tests') -----
- testOptionalLookbehind
-
- self assert: ['A' matchesRegex: '((?<=^)A)+'].!
Item was removed:
- ----- Method: RxParserTest>>testOptionalLookbehind2 (in category 'tests') -----
- testOptionalLookbehind2
-
- self assert: [('AB' allRegexMatches: '((?<=a)b)?') asArray = #('A')].!
Item was removed:
- ----- Method: RxParserTest>>testOrOperator (in category 'tests') -----
- 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 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
- such expression: `(a|)*' is an invalid expression."
-
- self should: ['(a|)*' asRegex] raise: Error.
- !
Item was removed:
- ----- Method: RxParserTest>>testPositiveLookahead (in category 'tests') -----
- testPositiveLookahead
- self deny: ['A' matchesRegex: 'A(?=BC).*'].
- self deny: ['AB' matchesRegex: 'A(?=BC).*'].
- self assert: ['ABC' matchesRegex: 'A(?=BC).*'].
- self deny: ['ABC' matchesRegex: 'A(?=BCD).*'].!
Item was removed:
- ----- Method: RxParserTest>>testPositiveLookbehind (in category 'tests') -----
- testPositiveLookbehind
- self deny: ['A' matchesRegex: '.*(?<=AB)C'].
- self deny: ['AB' matchesRegex: '.*(?<=AB)C'].
- self assert: ['ABC' matchesRegex: '.*(?<=AB)C'].
- self deny: ['ABC' matchesRegex: '.*(?<=XAB)C'].
- self assert: #('C') asSet equals: ('ABC' allRegexMatches: '(?<=AB+)\w') asSet.!
Item was removed:
- ----- Method: RxParserTest>>testPredicates (in category 'tests') -----
- testPredicates
-
- #(
- "input" "regex" "expected case sensitive result" "expected case insensitive result"
- 'abc' '[a]bc' true true
- 'abc' '[A]bc' false true
- 'abc' '[ab]bc' true true
- 'abc' '[Ab]bc' false true
- 'Abc' '[a]bc' false true
- 'Abc' '[A]bc' true true
- 'Abc' '[ab]bc' false true
- 'Abc' '[Ab]bc' true true
- 'abc' '[b]bc' false false
- 'abc' '[bB]bc' false false
- 'abc' '[bc]bc' false false
- 'abc' '[bcBC]bc' false false
- ) groupsDo: [ :input :regexString :expectedCaseSensitiveResult :expectedCaseInsensitiveResult |
- self
- assert: expectedCaseSensitiveResult
- equals: (input matchesRegex: regexString)
- description: ('{1} matchesRegex: {2} should be {3}' format: { input. regexString. expectedCaseSensitiveResult }).
- self
- assert: expectedCaseInsensitiveResult
- equals: (input matchesRegexIgnoringCase: regexString)
- description: ('{1} matchesRegexIgnoringCase: {2} should be {3}' format: { input. regexString. expectedCaseInsensitiveResult }) ]!
Item was removed:
- ----- Method: RxParserTest>>testQuantifier (in category 'tests') -----
- testQuantifier
- self deny: ('' matchesRegex: 'a{3}').
- self deny: ('a' matchesRegex: 'a{3}').
- self deny: ('aa' matchesRegex: 'a{3}').
- self assert: ('aaa' matchesRegex: 'a{3}').
- self deny: ('aaaa' matchesRegex: 'a{3}').
-
- self deny: ('' matchesRegex: 'a{3,4}').
- self deny: ('a' matchesRegex: 'a{3,4}').
- self deny: ('aa' matchesRegex: 'a{3,4}').
- self assert: ('aaa' matchesRegex: 'a{3,4}').
- self assert: ('aaaa' matchesRegex: 'a{3,4}').
- self deny: ('aaaaa' matchesRegex: 'a{3,4}').
-
- self deny: ('' matchesRegex: 'a{3,}').
- self deny: ('a' matchesRegex: 'a{3,}').
- self deny: ('aa' matchesRegex: 'a{3,}').
- self assert: ('aaa' matchesRegex: 'a{3,}').
- self assert: ('aaaa' matchesRegex: 'a{3,}').
- self assert: ('aaaaa' matchesRegex: 'a{3,}').
-
- self assert: ('' matchesRegex: 'a{,4}').
- self assert: ('a' matchesRegex: 'a{,4}').
- self assert: ('aa' matchesRegex: 'a{,4}').
- self assert: ('aaa' matchesRegex: 'a{,4}').
- self assert: ('aaaa' matchesRegex: 'a{,4}').
- self deny: ('aaaaa' matchesRegex: 'a{,4}').!
Item was removed:
- ----- Method: RxParserTest>>testQuantifierSimple (in category 'tests') -----
- testQuantifierSimple
- "Test quantifier expressions that can be expressed with + or *"
- self assert: ('a' matchesRegex: 'a{1}').
- self deny: ('aa' matchesRegex: 'a{1}').
-
- self assert: ('a' matchesRegex: 'a{1,1}').
- self deny: ('aa' matchesRegex: 'a{1,1}').
-
- self assert: ('ab' matchesRegex: '(ab){1,}').
- self assert: ('abab' matchesRegex: '(ab){1,}').
- self deny: ('' matchesRegex: '(ab){1,}').
-
- self assert: ('ab' matchesRegex: '(ab){,1}').
- self assert: ('' matchesRegex: '(ab){,1}').
- self deny: ('abab' matchesRegex: '(ab){,1}').!
Item was removed:
- ----- Method: RxParserTest>>testQuotingOperators (in category 'tests') -----
- 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,
- backslash is also special character, and needs to be quoted for a
- literal match--as well as any other special character described
- 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'). !
Item was removed:
- ----- Method: RxParserTest>>testSimpleMatchesRegex (in category 'tests') -----
- 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:"
-
- self assert: ('a' matchesRegex: 'a').
- self assert: ('foobar' matchesRegex: 'foobar') .
- self deny: ('blorple' matchesRegex: 'foobar')!
Item was removed:
- ----- Method: RxParserTest>>testSimpleMatchesRegexWithStar (in category 'tests') -----
- 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.
- Sequencing (placing expressions one after another) as an operator is,
- in a certain sense, `invisible'--yet it is arguably the most common.
- A more `visible' operator is Kleene closure, more often simply
- referred to as `a star'. A regular expression followed by an asterisk
- 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'). !
Item was removed:
- ----- Method: RxParserTest>>testSpecialCharacterInSetRange (in category 'tests') -----
- 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] (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]').
- !
Item was removed:
- ----- Method: RxParserTest>>testStarPlusQuestionMark (in category 'tests') -----
- 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 deny: ('ac' matchesRegex: 'ab+c'). "-- false: need at least one b"
- self assert: ('abbc' matchesRegex: 'ab+c').
- self assert: ('abbbbbbc' matchesRegex: 'ab+c').
- self deny: ('abbc' matchesRegex: 'ab?c') "-- false: too many b's"!
Item was removed:
- ----- Method: RxParserTest>>testStarPrecedence (in category 'tests') -----
- 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*').
-
- "To actually make a regex matching `zero or more occurrences of ab',
- `ab' is enclosed in parentheses:"
- self assert: ('abab' matchesRegex: '(ab)*').
- self deny: ('abcab' matchesRegex: '(ab)*')!
Item was removed:
- ----- Method: RxParserTest>>testTranslatingMatchesUsing (in category 'tests') -----
- testTranslatingMatchesUsing
- "self debug: #testTranslatingMatchesUsing"
-
-
- self assert: ('\<t\w+' asRegexIgnoringCase
- 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"!
Item was removed:
- ----- Method: RxParserTest>>toDotestSpecialCharacterInSetRange (in category 'tests') -----
- toDotestSpecialCharacterInSetRange
- "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] (thus, empty and universal sets cannot be specified)"
-
- self assert: ('0' matchesRegex: '[01^]').
-
- self assert: ('0' matchesRegex: '[0-9]').
- !
More information about the Squeak-dev
mailing list
|