The Trunk: Regex-Tests-Core-ul.2.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Regex-Tests-Core-ul.2.mcz

commits-2
Levente Uzonyi uploaded a new version of Regex-Tests-Core to project The Trunk:
http://source.squeak.org/trunk/Regex-Tests-Core-ul.2.mcz

==================== Summary ====================

Name: Regex-Tests-Core-ul.2
Author: ul
Time: 23 August 2015, 3:20:40.256 pm
UUID: f3dac194-a7e9-4ae1-a9be-4359591421c2
Ancestors: Regex-Tests-Core-ul.1

- added a test for the the bug caused by (aa)?{2}
- added #groupsDo: to RxMatcherTest>>runRegex: to make it easier to see what's being tested

=============== Diff against Regex-Tests-Core-ul.1 ===============

Item was changed:
  ----- 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 |
- 2 to: anArray size by: 3 do: [ :index |
  self
  runMatcher: matcher
+ with: input
+ expect: shouldMatch
+ withSubexpressions: expectedOutput ] ] ]!
- with: (anArray at: index)
- expect: (anArray at: index + 1)
- withSubexpressions: (anArray at: index + 2) ] ] ]!

Item was added:
+ ----- 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 (2 'aaa'))!