-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegex-Tests.pck.st
1400 lines (1144 loc) · 45.9 KB
/
Regex-Tests.pck.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From Cuis6.3 [latest update: #6350] on 9 May 2024 at 9:38:04 am'!
'Description Sincronized with Cuis 6.3'!
!provides: 'Regex-Tests' 1 4!
!requires: 'Regex-Core' 1 5 nil!
SystemOrganization addCategory: #'Regex-Tests-Core'!
!classDefinition: #RxMatcherTest category: #'Regex-Tests-Core'!
TestCase subclass: #RxMatcherTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Regex-Tests-Core'!
!classDefinition: 'RxMatcherTest class' category: #'Regex-Tests-Core'!
RxMatcherTest class
instanceVariableNames: ''!
!classDefinition: #RxParserTest category: #'Regex-Tests-Core'!
TestCase subclass: #RxParserTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Regex-Tests-Core'!
!classDefinition: 'RxParserTest class' category: #'Regex-Tests-Core'!
RxParserTest class
instanceVariableNames: ''!
!RxMatcherTest commentStamp: 'Tbn 11/12/2010 22:31' prior: 0!
This class provides tests for the regular expression matcher.!
!RxParserTest commentStamp: 'Tbn 11/12/2010 22:31' prior: 0!
This class provides tests for the regular expression parser.!
!RxMatcherTest methodsFor: 'accessing' stamp: 'gsa 12/22/2012 12:25'!
matcherClass
^ RxMatcher! !
!RxMatcherTest methodsFor: 'accessing' stamp: 'lr 1/15/2010 19:39'!
parserClass
^ RxParser! !
!RxMatcherTest methodsFor: 'utilties' stamp: 'TestRunner 1/15/2010 19:38'!
compileRegex: aString
"Compile the regex and answer the matcher, or answer nil if compilation fails."
| syntaxTree |
syntaxTree := self parserClass safelyParse: aString.
^ syntaxTree isNil ifFalse: [ self matcherClass for: syntaxTree ]! !
!RxMatcherTest methodsFor: 'utilties' stamp: 'gsa 12/22/2012 12:26'!
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 ]! !
!RxMatcherTest methodsFor: 'utilties' stamp: 'lr 1/15/2010 19:31'!
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: [
2 to: anArray size by: 3 do: [ :index |
self
runMatcher: matcher
with: (anArray at: index)
expect: (anArray at: index + 1)
withSubexpressions: (anArray at: index + 2) ] ] ]! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
henryReadme
self error: 'The tests in this category are based on the ones in Henry Spencer''s regexp.c package.'! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
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'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry002
self runRegex: #('ab*c'
'abc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry003
self runRegex: #('ab*bc'
'abc' true (1 'abc')
'abbc' true (1 'abbc')
'abbbbc' true (1 'abbbbc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry004
self runRegex: #('ab+bc'
'abbc' true (1 'abbc')
'abc' false nil
'abq' false nil
'abbbbc' true (1 'abbbbc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry005
self runRegex: #('ab?bc'
'abbc' true (1 'abbc')
'abc' true (1 'abc')
'abbbbc' false nil
'abc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry006
self runRegex: #('^abc$'
'abc' true (1 'abc')
'abcc' false nil
'aabc' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry007
self runRegex: #('^abc'
'abcc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry008
self runRegex: #('abc$'
'aabc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry009
self runRegex: #('^'
'abc' true nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry010
self runRegex: #('$'
'abc' true nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry011
self runRegex: #('a.c'
'abc' true (1 'abc')
'axc' true (1 'axc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'HAW 5/7/2024 17:24:49'!
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: (Character codePoint: 0)), 'zc'), #(false nil "testing that a dot does not match a null"
'axyzd' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry013
self runRegex: #('.a.*'
'1234abc' true (1 '4abc')
'abcd' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry014
self runRegex: #('a\w+c'
' abbbbc ' true (1 'abbbbc')
'abb bc' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry015
self runRegex: #('\w+'
' foobar quux' true (1 'foobar')
' ~!!@#$%^&*()-+=\|/?.>,<' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry016
self runRegex: #('a\W+c'
'a c' true (1 'a c')
'a bc' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry017
self runRegex: #('\W+'
'foo!!@#$bar' true (1 '!!@#$')
'foobar' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry018
self runRegex: #('a\s*c'
'a c' true (1 'a c')
'a bc' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry019
self runRegex: #('\s+'
'abc3457 sd' true (1 ' ')
'1234$^*^&asdfb' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry020
self runRegex: #('a\S*c'
'aqwertyc' true (1 'aqwertyc')
'ab c' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry021
self runRegex: #('\S+'
' asdf ' true (1 'asdf')
'
' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry022
self runRegex: #('a\d+c'
'a0123456789c' true (1 'a0123456789c')
'a12b34c' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry023
self runRegex: #('\d+'
'foo@#$%123ASD #$$%^&' true (1 '123')
'foo!!@#$asdfl;' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry024
self runRegex: #('a\D+c'
'aqwertyc' true (1 'aqwertyc')
'aqw6ertc' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry025
self runRegex: #('\D+'
'1234 abc 456' true (1 ' abc ')
'1234567890' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry026
self runRegex: #('(f|o)+\b'
'foo' true (1 'foo')
' foo ' true (1 'foo'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
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)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry028
self runRegex: #('(f|o)+\B'
'quuxfoobar' true (1 'foo')
'quuxfoo ' true (1 'fo'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
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)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry030
self runRegex: #('fooa\>.*'
'fooa ' true nil
'fooa123' false nil
'fooa bar' true nil
'fooa' true nil
'fooargh' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry031
self runRegex: #('\>.+abc'
' abcde fg' false nil
'foo abcde' true (1 ' abc')
'abcde' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry032
self runRegex: #('\<foo.*'
'foo' true nil
'foobar' true nil
'qfoobarq foonix' true (1 'foonix')
' foo' true nil
' 12foo' false nil
'barfoo' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry033
self runRegex: #('.+\<foo'
'foo' false nil
'ab foo' true (1 'ab foo')
'abfoo' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry034
self runRegex: #('a[bc]d'
'abc' false nil
'abd' true (1 'abd'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry035
self runRegex: #('a[b-d]e'
'abd' false nil
'ace' true (1 'ace'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry036
self runRegex: #('a[b-d]'
'aac' true (1 'ac'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry037
self runRegex: #('a[-b]'
'a-' true (1 'a-'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry038
self runRegex: #('a[b-]'
'a-' true (1 'a-'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry039
self runRegex: #('a[a-b-c]' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry040
self runRegex: #('[k]'
'ab' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry041
self runRegex: #('a[b-a]' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry042
self runRegex: #('a[]b' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry043
self runRegex: #('a[' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry044
self runRegex: #('a]'
'a]' true (1 'a]'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry045
self runRegex: #('a[]]b'
'a]b' true (1 'a]b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry046
self runRegex: #('a[^bc]d'
'aed' true (1 'aed')
'abd' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry047
self runRegex: #('a[^-b]c'
'adc' true (1 'adc')
'a-c' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry048
self runRegex: #('a[^]b]c'
'a]c' false nil
'adc' true (1 'adc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry049
self runRegex: #('[\de]+'
'01234' true (1 '01234')
'0123e456' true (1 '0123e456')
'0123e45g78' true (1 '0123e45'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
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'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry051
self runRegex: #('[\D]+'
'123abc45def78' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry052
self runRegex: #('[[:digit:]e]+'
'01234' true (1 '01234')
'0123e456' true (1 '0123e456')
'0123e45g78' true (1 '0123e45'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry053
self runRegex: #('[\s]+'
'2 spaces' true (1 ' '))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry054
self runRegex: #('[\S]+'
' word12!!@#$ ' true (1 'word12!!@#$'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry055
self runRegex: #('[\w]+'
' foo123bar 45' true (1 'foo123bar'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry056
self runRegex: #('[\W]+'
'fii234!!@#$34f' true (1 '!!@#$'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry057
self runRegex: #('[^[:alnum:]]+'
'fii234!!@#$34f' true (1 '!!@#$'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry058
self runRegex: #('[%&[:alnum:]]+'
'foo%3' true (1 'foo%3')
'foo34&rt4$57a' true (1 'foo34&rt4')
'!!@#$' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry059
self runRegex: #('[[:alpha:]]+'
' 123foo3 ' true (1 'foo')
'123foo' true (1 'foo')
'foo1b' true (1 'foo'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry060
self runRegex: #('[[:cntrl:]]+'
' a 1234asdf' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry061
self runRegex: #('[[:lower:]]+'
'UPPERlower1234' true (1 'lower')
'lowerUPPER' true (1 'lower'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry062
self runRegex: #('[[:upper:]]+'
'UPPERlower1234' true (1 'UPPER')
'lowerUPPER ' true (1 'UPPER'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry063
self runRegex: #('[[:space:]]+'
'2 spaces' true (1 ' '))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry064
self runRegex: #('[^[:space:]]+'
' word12!!@#$ ' true (1 'word12!!@#$'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry065
self runRegex: #('[[:graph:]]+'
'abc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry066
self runRegex: #('[[:print:]]+'
'abc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry067
self runRegex: #('[^[:punct:]]+'
'!!hello,world!!' true (1 'hello'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry068
self runRegex: #('[[:xdigit:]]+'
' x10FCD ' true (1 '10FCD')
' hgfedcba0123456789ABCDEFGH '
true (1 'fedcba0123456789ABCDEF'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry069
self runRegex: #('ab|cd'
'abc' true (1 'ab')
'abcd' true (1 'ab'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry070
self runRegex: #('()ef'
'def' true (1 'ef' 2 ''))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry071
self runRegex: #('()*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry072
self runRegex: #('*a' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry073
self runRegex: #('^*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry074
self runRegex: #('$*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry075
self runRegex: #('(*)b' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry076
self runRegex: #('$b' 'b' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry077
self runRegex: #('a\' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry078
self runRegex: #('a\(b'
'a(b' true (1 'a(b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry079
self runRegex: #('a\(*b'
'ab' true (1 'ab')
'a((b' true (1 'a((b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry080
self runRegex: #('a\\b'
'a\b' true (1 'a\b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry081
self runRegex: #('abc)' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry082
self runRegex: #('(abc' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry083
self runRegex: #('((a))'
'abc' true (1 'a' 2 'a' 3 'a'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry084
self runRegex: #('(a)b(c)'
'abc' true (1 'abc' 2 'a' 3 'c'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry085
self runRegex: #('a+b+c'
'aabbabc' true (1 'abc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry086
self runRegex: #('a**' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry087
self runRegex: #('a*?' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry088
self runRegex: #('(a*)*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry089
self runRegex: #('(a*)+' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry090
self runRegex: #('(a|)*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry091
self runRegex: #('(a*|b)*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry092
self runRegex: #('(a+|b)*'
'ab' true (1 'ab' 2 'b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry093
self runRegex: #('(a+|b)+'
'ab' true (1 'ab' 2 'b'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry094
self runRegex: #('(a+|b)?'
'ab' true (1 'a' 2 'a'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry095
self runRegex: #('[^ab]*'
'cde' true (1 'cde'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry096
self runRegex: #('(^)*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry097
self runRegex: #('(ab|)*' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry098
self runRegex: #(')(' nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry099
self runRegex: #('' 'abc' true (1 ''))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry100
self runRegex: #('abc' '' false nil)! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry101
self runRegex: #('a*'
'' true '')! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry102
self runRegex: #('abcd'
'abcd' true (1 'abcd'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry103
self runRegex: #('a(bc)d'
'abcd' true (1 'abcd' 2 'bc'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry104
self runRegex: #('([abc])*d'
'abbbcd' true (1 'abbbcd' 2 'c'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry105
self runRegex: #('([abc])*bcd'
'abcd' true (1 'abcd' 2 'a'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry106
self runRegex: #('a|b|c|d|e' 'e' true (1 'e'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry107
self runRegex: #('(a|b|c|d|e)f'
'ef' true (1 'ef' 2 'e'))
" ((a*|b))* - c - -"! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry108
self runRegex: #('abcd*efg'
'abcdefg' true (1 'abcdefg'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry109
self runRegex: #('ab*'
'xabyabbbz' true (1 'ab')
'xayabbbz' true (1 'a'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry110
self runRegex: #('(ab|cd)e' 'abcde' true (1 'cde' 2 'cd'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry111
self runRegex: #('[abhgefdc]ij' 'hij' true (1 'hij'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry112
self runRegex: #('^(ab|cd)e' 'abcde' false nil)
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry113
self runRegex: #('(abc|)def' 'abcdef' true nil)
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry114
self runRegex: #('(a|b)c*d' 'abcd' true (1 'bcd' 2 'b'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry115
self runRegex: #('(ab|ab*)bc' 'abc' true (1 'abc' 2 'a'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry116
self runRegex: #('a([bc]*)c*' 'abc' true (1 'abc' 2 'bc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry117
self runRegex: #('a([bc]*)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry118
self runRegex: #('a([bc]+)(c*d)' 'abcd' true (1 'abcd' 2 'bc' 3 'd'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry119
self runRegex: #('a([bc]*)(c+d)' 'abcd' true (1 'abcd' 2 'b' 3 'cd'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry120
self runRegex: #('a[bcd]*dcdcde' 'adcdcde' true (1 'adcdcde'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry121
self runRegex: #('a[bcd]+dcdcde' 'adcdcde' false nil)
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry122
self runRegex: #('(ab|a)b*c' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry123
self runRegex: #('((a)(b)c)(d)' 'abcd' true (1 'abcd' 3 'a' 4 'b' 5 'd'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry124
self runRegex: #('[ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry125
self runRegex: #('[ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry126
self runRegex: #('[ -~ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry127
self runRegex: #('[ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry128
self runRegex: #('[ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry129
self runRegex: #('[ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry130
self runRegex: #('[ -~ -~ -~ -~ -~ -~ -~]*' 'abc' true (1 'abc'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry131
self runRegex: #('[a-zA-Z_][a-zA-Z0-9_]*' 'alpha' true (1 'alpha'))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry132
self runRegex: #('^a(bc+|b[eh])g|.h$' 'abh' true (1 'bh' 2 nil))
! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
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))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry134
self runRegex: #('(((((((((a)))))))))' 'a' true (1 'a'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry135
self runRegex: #('multiple words of text'
'uh-uh' false nil
'multiple words of text, yeah' true (1 'multiple words of text'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry136
self runRegex: #('(.*)c(.*)' 'abcde' true (1 'abcde' 2 'ab' 3 'de'))! !
!RxMatcherTest methodsFor: 'testing-henry' stamp: 'lr 1/15/2010 19:46'!
testHenry137
self runRegex: #('\((.*), (.*)\)' '(a, b)' true (2 'a' 3 'b'))! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:28'!
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?')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:28'!
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?')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:38'!
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'! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'hfm 4/2/2010 13:52'!
testCopyTranslatingMatches
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher copy: 'now is the time ' translatingMatchesUsing: [ :each | each reversed ])
= 'won si eht emit '! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:45'!
testMatches
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher matches: 'now').
self deny: (matcher matches: 'now is')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:38'!
testMatchesIn
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher matchesIn: 'now is the time') asArray
= #('now' 'is' 'the' 'time')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'hfm 4/2/2010 13:52'!
testMatchesInCollect
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher
matchesIn: 'now is the time'
collect: [ :each | each reversed ]) asArray
= #('won' 'si' 'eht' 'emit')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:44'!
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! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:39'!
testMatchesOnStream
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher matchesOnStream: 'now is the time' readStream) asArray
= #('now' 'is' 'the' 'time')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'hfm 4/2/2010 13:52'!
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')! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:44'!
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! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:45'!
testMatchesStream
| matcher |
matcher := self matcherClass forString: '\w+'.
self assert: (matcher matchesStream: 'now' readStream).
self deny: (matcher matchesStream: 'now is' readStream)! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'TestRunner 1/15/2010 20:51'!
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! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'KenD 11/25/2016 13:39:02'!
testRemoveHTMLTags
"Remove HTML Tags"
| regex html |
regex := '</?[0-9A-Za-z]+[^>]*>' asRegex.
html := '<a>foo<b>bar</b></a>'.
self assert: (regex copy: html replacingMatchesWith: '') = 'foobar'
! !
!RxMatcherTest methodsFor: 'testing-protocol' stamp: 'lr 1/15/2010 20:55'!
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 ] ]! !
!RxMatcherTest methodsFor: 'testing-empty' stamp: 'gsa 12/20/2012 20:02'!
testEmptyStringAtBeginningOfLine
| matcher |
matcher := self matcherClass forString: '^'.
self
assert: (matcher copy: 'foo1 bar1' , String crString , 'foo2 bar2' replacingMatchesWith: '*')
= ('*foo1 bar1' , String crString , '*foo2 bar2')
description: 'An empty string at the beginning of a line'! !
!RxMatcherTest methodsFor: 'testing-empty' stamp: 'gsa 12/22/2012 12:34'!
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'! !
!RxMatcherTest methodsFor: 'testing-empty' stamp: 'gsa 12/20/2012 20:02'!
testEmptyStringAtEndOfLine
| matcher |
matcher := self matcherClass forString: '$'.
self
assert: (matcher copy: 'foo1 bar1' , String crString , 'foo2 bar2' replacingMatchesWith: '*')
= ('foo1 bar1*', String crString , 'foo2 bar2*')
description: 'An empty string at the end of a line'! !
!RxMatcherTest methodsFor: 'testing-empty' stamp: 'gsa 12/22/2012 12:34'!
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'! !