1 load: 'src/lib/regex.slate'.
3 "UnitTests definePrototype: #Regex &basis: TestCase.
5 tc@(UnitTests Regex traits) shouldMatch: string against: regex withMatches: c
7 inform: 'Testing regex: ' ; regex.
8 matcher: (Regex Parser compileRegex: regex).
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
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.
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'].