Fixed allSelectorsSent because a simpler implementation was overriding the original.
[cslatevm.git] / tests / regex.slate
blob78f8a3b2e2d81fb2504d36a94d22969ff9a911d0
1 load: 'src/lib/regex.slate'.
3 "UnitTests addPrototype: #Regex derivedFrom: {TestCase}.
5 tc@(UnitTests Regex traits) shouldMatch: string against: regex withMatches: c
6 [| matcher |
7   inform: 'Testing regex: ' ; regex.
8   matcher: (Regex Parser compileRegex: regex).
9   matcher
10     ifNil: [c ifNil: [inform: 'Compilation error as expected.']
11               ifNotNil: [inform: 'Compilation error, Unexpected!'.
12                          tc failures: tc failures + 1]]
13     ifNotNil: [c ifNil: [inform: 'Compilation succeeded, should have failed!'.
14                          tc failures: tc failures + 1]
15                  ifNotNil: [c do: [| :eachMatch | ]]]
18 tc@(UnitTests Regex traits) testSimple
19 [| src |
20   src: 'abc'.
21   tc shouldMatch: string against: string withMatches: {1. 'abc'}.
22   tc shouldMatch: string against: 'xbc' withMatches: Nil.
23   tc shouldMatch: string against: 'axc' withMatches: Nil.
24   tc shouldMatch: string against: 'abx' withMatches: Nil.
28 _@lobby testURLMatch
30   r ::= Regex Matcher for: '^(([^:/?#]+)X)?(//([^/?#]*))?([^?#]*)(Z([^#]*))?(#(.*))?'.
31   (r matches: 'httpX//www.foo.com/ra/ra/raZa=b') printOn: Console writer.
32   1 to: 10 do: [ | :a | Console ; (a as: '') ; ' ' . (r subexpression: a) printOn: Console writer. Console ; '\n'].