1/* ***** BEGIN LICENSE BLOCK *****
2* Version: NPL 1.1/GPL 2.0/LGPL 2.1
3*
4* The contents of this file are subject to the Netscape Public License
5* Version 1.1 (the "License"); you may not use this file except in
6* compliance with the License. You may obtain a copy of the License at
7* http://www.mozilla.org/NPL/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is JavaScript Engine testing utilities.
15*
16* The Initial Developer of the Original Code is Netscape Communications Corp.
17* Portions created by the Initial Developer are Copyright (C) 2002
18* the Initial Developer. All Rights Reserved.
19*
20* Contributor(s): pschwartau@netscape.com, rogerl@netscape.com
21*
22* Alternatively, the contents of this file may be used under the terms of
23* either the GNU General Public License Version 2 or later (the "GPL"), or
24* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25* in which case the provisions of the GPL or the LGPL are applicable instead
26* of those above. If you wish to allow use of your version of this file only
27* under the terms of either the GPL or the LGPL, and not to allow others to
28* use your version of this file under the terms of the NPL, indicate your
29* decision by deleting the provisions above and replace them with the notice
30* and other provisions required by the GPL or the LGPL. If you do not delete
31* the provisions above, a recipient may use your version of this file under
32* the terms of any one of the NPL, the GPL or the LGPL.
33*
34* ***** END LICENSE BLOCK *****
35*
36*
37* Date:    2002-07-07
38* SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine.
39* Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested.
40*
41* This test was created by running various patterns and strings through the
42* Perl 5 RegExp engine. We saved the results below to test the JS engine.
43*
44* NOTE: ECMA/JS and Perl do differ on certain points. We have either commented
45* out such sections altogether, or modified them to fit what we expect from JS.
46*
47* EXAMPLES:
48*
49* - In JS, regexp captures (/(a) etc./) must hold |undefined| if not used.
50*   See http://bugzilla.mozilla.org/show_bug.cgi?id=123437.
51*   By contrast, in Perl, unmatched captures hold the empty string.
52*   We have modified such sections accordingly. Example:
53
54    pattern = /^([^a-z])|(\^)$/;
55    string = '.';
56    actualmatch = string.match(pattern);
57  //expectedmatch = Array('.', '.', '');        <<<--- Perl
58    expectedmatch = Array('.', '.', undefined); <<<--- JS
59    addThis();
60
61
62* - In JS, you can't refer to a capture before it's encountered & completed
63*
64* - Perl supports ] & ^] inside a [], ECMA does not
65*
66* - ECMA does support (?: (?= and (?! operators, but doesn't support (?<  etc.
67*
68* - ECMA doesn't support (?imsx or (?-imsx
69*
70* - ECMA doesn't support (?(condition)
71*
72* - Perl has \Z has end-of-line, ECMA doesn't
73*
74* - In ECMA, ^ matches only the empty string before the first character
75*
76* - In ECMA, $ matches only the empty string at end of input (unless multiline)
77*
78* - ECMA spec says that each atom in a range must be a single character
79*
80* - ECMA doesn't support \A
81*
82* - ECMA doesn't have rules for [:
83*
84*/
85//-----------------------------------------------------------------------------
86var i = 0;
87var bug = 85721;
88var summary = 'Testing regular expression edge cases';
89var cnSingleSpace = ' ';
90var status = '';
91var statusmessages = new Array();
92var pattern = '';
93var patterns = new Array();
94var string = '';
95var strings = new Array();
96var actualmatch = '';
97var actualmatches = new Array();
98var expectedmatch = '';
99var expectedmatches = new Array();
100var cnLBOUND = 1;
101var cnUBOUND = 1000;
102
103
104status = inSection(1);
105pattern = /abc/;
106string = 'abc';
107actualmatch = string.match(pattern);
108expectedmatch = Array('abc');
109addThis();
110
111status = inSection(2);
112pattern = /abc/;
113string = 'xabcy';
114actualmatch = string.match(pattern);
115expectedmatch = Array('abc');
116addThis();
117
118status = inSection(3);
119pattern = /abc/;
120string = 'ababc';
121actualmatch = string.match(pattern);
122expectedmatch = Array('abc');
123addThis();
124
125status = inSection(4);
126pattern = /ab*c/;
127string = 'abc';
128actualmatch = string.match(pattern);
129expectedmatch = Array('abc');
130addThis();
131
132status = inSection(5);
133pattern = /ab*bc/;
134string = 'abc';
135actualmatch = string.match(pattern);
136expectedmatch = Array('abc');
137addThis();
138
139status = inSection(6);
140pattern = /ab*bc/;
141string = 'abbc';
142actualmatch = string.match(pattern);
143expectedmatch = Array('abbc');
144addThis();
145
146status = inSection(7);
147pattern = /ab*bc/;
148string = 'abbbbc';
149actualmatch = string.match(pattern);
150expectedmatch = Array('abbbbc');
151addThis();
152
153status = inSection(8);
154pattern = /.{1}/;
155string = 'abbbbc';
156actualmatch = string.match(pattern);
157expectedmatch = Array('a');
158addThis();
159
160status = inSection(9);
161pattern = /.{3,4}/;
162string = 'abbbbc';
163actualmatch = string.match(pattern);
164expectedmatch = Array('abbb');
165addThis();
166
167status = inSection(10);
168pattern = /ab{0,}bc/;
169string = 'abbbbc';
170actualmatch = string.match(pattern);
171expectedmatch = Array('abbbbc');
172addThis();
173
174status = inSection(11);
175pattern = /ab+bc/;
176string = 'abbc';
177actualmatch = string.match(pattern);
178expectedmatch = Array('abbc');
179addThis();
180
181status = inSection(12);
182pattern = /ab+bc/;
183string = 'abbbbc';
184actualmatch = string.match(pattern);
185expectedmatch = Array('abbbbc');
186addThis();
187
188status = inSection(13);
189pattern = /ab{1,}bc/;
190string = 'abbbbc';
191actualmatch = string.match(pattern);
192expectedmatch = Array('abbbbc');
193addThis();
194
195status = inSection(14);
196pattern = /ab{1,3}bc/;
197string = 'abbbbc';
198actualmatch = string.match(pattern);
199expectedmatch = Array('abbbbc');
200addThis();
201
202status = inSection(15);
203pattern = /ab{3,4}bc/;
204string = 'abbbbc';
205actualmatch = string.match(pattern);
206expectedmatch = Array('abbbbc');
207addThis();
208
209status = inSection(16);
210pattern = /ab?bc/;
211string = 'abbc';
212actualmatch = string.match(pattern);
213expectedmatch = Array('abbc');
214addThis();
215
216status = inSection(17);
217pattern = /ab?bc/;
218string = 'abc';
219actualmatch = string.match(pattern);
220expectedmatch = Array('abc');
221addThis();
222
223status = inSection(18);
224pattern = /ab{0,1}bc/;
225string = 'abc';
226actualmatch = string.match(pattern);
227expectedmatch = Array('abc');
228addThis();
229
230status = inSection(19);
231pattern = /ab?c/;
232string = 'abc';
233actualmatch = string.match(pattern);
234expectedmatch = Array('abc');
235addThis();
236
237status = inSection(20);
238pattern = /ab{0,1}c/;
239string = 'abc';
240actualmatch = string.match(pattern);
241expectedmatch = Array('abc');
242addThis();
243
244status = inSection(21);
245pattern = /^abc$/;
246string = 'abc';
247actualmatch = string.match(pattern);
248expectedmatch = Array('abc');
249addThis();
250
251status = inSection(22);
252pattern = /^abc/;
253string = 'abcc';
254actualmatch = string.match(pattern);
255expectedmatch = Array('abc');
256addThis();
257
258status = inSection(23);
259pattern = /abc$/;
260string = 'aabc';
261actualmatch = string.match(pattern);
262expectedmatch = Array('abc');
263addThis();
264
265status = inSection(24);
266pattern = /^/;
267string = 'abc';
268actualmatch = string.match(pattern);
269expectedmatch = Array('');
270addThis();
271
272status = inSection(25);
273pattern = /$/;
274string = 'abc';
275actualmatch = string.match(pattern);
276expectedmatch = Array('');
277addThis();
278
279status = inSection(26);
280pattern = /a.c/;
281string = 'abc';
282actualmatch = string.match(pattern);
283expectedmatch = Array('abc');
284addThis();
285
286status = inSection(27);
287pattern = /a.c/;
288string = 'axc';
289actualmatch = string.match(pattern);
290expectedmatch = Array('axc');
291addThis();
292
293status = inSection(28);
294pattern = /a.*c/;
295string = 'axyzc';
296actualmatch = string.match(pattern);
297expectedmatch = Array('axyzc');
298addThis();
299
300status = inSection(29);
301pattern = /a[bc]d/;
302string = 'abd';
303actualmatch = string.match(pattern);
304expectedmatch = Array('abd');
305addThis();
306
307status = inSection(30);
308pattern = /a[b-d]e/;
309string = 'ace';
310actualmatch = string.match(pattern);
311expectedmatch = Array('ace');
312addThis();
313
314status = inSection(31);
315pattern = /a[b-d]/;
316string = 'aac';
317actualmatch = string.match(pattern);
318expectedmatch = Array('ac');
319addThis();
320
321status = inSection(32);
322pattern = /a[-b]/;
323string = 'a-';
324actualmatch = string.match(pattern);
325expectedmatch = Array('a-');
326addThis();
327
328status = inSection(33);
329pattern = /a[b-]/;
330string = 'a-';
331actualmatch = string.match(pattern);
332expectedmatch = Array('a-');
333addThis();
334
335status = inSection(34);
336pattern = /a]/;
337string = 'a]';
338actualmatch = string.match(pattern);
339expectedmatch = Array('a]');
340addThis();
341
342/* Perl supports ] & ^] inside a [], ECMA does not
343pattern = /a[]]b/;
344status = inSection(35);
345string = 'a]b';
346actualmatch = string.match(pattern);
347expectedmatch = Array('a]b');
348addThis();
349*/
350
351status = inSection(36);
352pattern = /a[^bc]d/;
353string = 'aed';
354actualmatch = string.match(pattern);
355expectedmatch = Array('aed');
356addThis();
357
358status = inSection(37);
359pattern = /a[^-b]c/;
360string = 'adc';
361actualmatch = string.match(pattern);
362expectedmatch = Array('adc');
363addThis();
364
365/* Perl supports ] & ^] inside a [], ECMA does not
366status = inSection(38);
367pattern = /a[^]b]c/;
368string = 'adc';
369actualmatch = string.match(pattern);
370expectedmatch = Array('adc');
371addThis();
372*/
373
374status = inSection(39);
375pattern = /\ba\b/;
376string = 'a-';
377actualmatch = string.match(pattern);
378expectedmatch = Array('a');
379addThis();
380
381status = inSection(40);
382pattern = /\ba\b/;
383string = '-a';
384actualmatch = string.match(pattern);
385expectedmatch = Array('a');
386addThis();
387
388status = inSection(41);
389pattern = /\ba\b/;
390string = '-a-';
391actualmatch = string.match(pattern);
392expectedmatch = Array('a');
393addThis();
394
395status = inSection(42);
396pattern = /\By\b/;
397string = 'xy';
398actualmatch = string.match(pattern);
399expectedmatch = Array('y');
400addThis();
401
402status = inSection(43);
403pattern = /\by\B/;
404string = 'yz';
405actualmatch = string.match(pattern);
406expectedmatch = Array('y');
407addThis();
408
409status = inSection(44);
410pattern = /\By\B/;
411string = 'xyz';
412actualmatch = string.match(pattern);
413expectedmatch = Array('y');
414addThis();
415
416status = inSection(45);
417pattern = /\w/;
418string = 'a';
419actualmatch = string.match(pattern);
420expectedmatch = Array('a');
421addThis();
422
423status = inSection(46);
424pattern = /\W/;
425string = '-';
426actualmatch = string.match(pattern);
427expectedmatch = Array('-');
428addThis();
429
430status = inSection(47);
431pattern = /a\Sb/;
432string = 'a-b';
433actualmatch = string.match(pattern);
434expectedmatch = Array('a-b');
435addThis();
436
437status = inSection(48);
438pattern = /\d/;
439string = '1';
440actualmatch = string.match(pattern);
441expectedmatch = Array('1');
442addThis();
443
444status = inSection(49);
445pattern = /\D/;
446string = '-';
447actualmatch = string.match(pattern);
448expectedmatch = Array('-');
449addThis();
450
451status = inSection(50);
452pattern = /[\w]/;
453string = 'a';
454actualmatch = string.match(pattern);
455expectedmatch = Array('a');
456addThis();
457
458status = inSection(51);
459pattern = /[\W]/;
460string = '-';
461actualmatch = string.match(pattern);
462expectedmatch = Array('-');
463addThis();
464
465status = inSection(52);
466pattern = /a[\S]b/;
467string = 'a-b';
468actualmatch = string.match(pattern);
469expectedmatch = Array('a-b');
470addThis();
471
472status = inSection(53);
473pattern = /[\d]/;
474string = '1';
475actualmatch = string.match(pattern);
476expectedmatch = Array('1');
477addThis();
478
479status = inSection(54);
480pattern = /[\D]/;
481string = '-';
482actualmatch = string.match(pattern);
483expectedmatch = Array('-');
484addThis();
485
486status = inSection(55);
487pattern = /ab|cd/;
488string = 'abc';
489actualmatch = string.match(pattern);
490expectedmatch = Array('ab');
491addThis();
492
493status = inSection(56);
494pattern = /ab|cd/;
495string = 'abcd';
496actualmatch = string.match(pattern);
497expectedmatch = Array('ab');
498addThis();
499
500status = inSection(57);
501pattern = /()ef/;
502string = 'def';
503actualmatch = string.match(pattern);
504expectedmatch = Array('ef', '');
505addThis();
506
507status = inSection(58);
508pattern = /a\(b/;
509string = 'a(b';
510actualmatch = string.match(pattern);
511expectedmatch = Array('a(b');
512addThis();
513
514status = inSection(59);
515pattern = /a\(*b/;
516string = 'ab';
517actualmatch = string.match(pattern);
518expectedmatch = Array('ab');
519addThis();
520
521status = inSection(60);
522pattern = /a\(*b/;
523string = 'a((b';
524actualmatch = string.match(pattern);
525expectedmatch = Array('a((b');
526addThis();
527
528status = inSection(61);
529pattern = /a\\b/;
530string = 'a\\b';
531actualmatch = string.match(pattern);
532expectedmatch = Array('a\\b');
533addThis();
534
535status = inSection(62);
536pattern = /((a))/;
537string = 'abc';
538actualmatch = string.match(pattern);
539expectedmatch = Array('a', 'a', 'a');
540addThis();
541
542status = inSection(63);
543pattern = /(a)b(c)/;
544string = 'abc';
545actualmatch = string.match(pattern);
546expectedmatch = Array('abc', 'a', 'c');
547addThis();
548
549status = inSection(64);
550pattern = /a+b+c/;
551string = 'aabbabc';
552actualmatch = string.match(pattern);
553expectedmatch = Array('abc');
554addThis();
555
556status = inSection(65);
557pattern = /a{1,}b{1,}c/;
558string = 'aabbabc';
559actualmatch = string.match(pattern);
560expectedmatch = Array('abc');
561addThis();
562
563status = inSection(66);
564pattern = /a.+?c/;
565string = 'abcabc';
566actualmatch = string.match(pattern);
567expectedmatch = Array('abc');
568addThis();
569
570status = inSection(67);
571pattern = /(a+|b)*/;
572string = 'ab';
573actualmatch = string.match(pattern);
574expectedmatch = Array('ab', 'b');
575addThis();
576
577status = inSection(68);
578pattern = /(a+|b){0,}/;
579string = 'ab';
580actualmatch = string.match(pattern);
581expectedmatch = Array('ab', 'b');
582addThis();
583
584status = inSection(69);
585pattern = /(a+|b)+/;
586string = 'ab';
587actualmatch = string.match(pattern);
588expectedmatch = Array('ab', 'b');
589addThis();
590
591status = inSection(70);
592pattern = /(a+|b){1,}/;
593string = 'ab';
594actualmatch = string.match(pattern);
595expectedmatch = Array('ab', 'b');
596addThis();
597
598status = inSection(71);
599pattern = /(a+|b)?/;
600string = 'ab';
601actualmatch = string.match(pattern);
602expectedmatch = Array('a', 'a');
603addThis();
604
605status = inSection(72);
606pattern = /(a+|b){0,1}/;
607string = 'ab';
608actualmatch = string.match(pattern);
609expectedmatch = Array('a', 'a');
610addThis();
611
612status = inSection(73);
613pattern = /[^ab]*/;
614string = 'cde';
615actualmatch = string.match(pattern);
616expectedmatch = Array('cde');
617addThis();
618
619status = inSection(74);
620pattern = /([abc])*d/;
621string = 'abbbcd';
622actualmatch = string.match(pattern);
623expectedmatch = Array('abbbcd', 'c');
624addThis();
625
626status = inSection(75);
627pattern = /([abc])*bcd/;
628string = 'abcd';
629actualmatch = string.match(pattern);
630expectedmatch = Array('abcd', 'a');
631addThis();
632
633status = inSection(76);
634pattern = /a|b|c|d|e/;
635string = 'e';
636actualmatch = string.match(pattern);
637expectedmatch = Array('e');
638addThis();
639
640status = inSection(77);
641pattern = /(a|b|c|d|e)f/;
642string = 'ef';
643actualmatch = string.match(pattern);
644expectedmatch = Array('ef', 'e');
645addThis();
646
647status = inSection(78);
648pattern = /abcd*efg/;
649string = 'abcdefg';
650actualmatch = string.match(pattern);
651expectedmatch = Array('abcdefg');
652addThis();
653
654status = inSection(79);
655pattern = /ab*/;
656string = 'xabyabbbz';
657actualmatch = string.match(pattern);
658expectedmatch = Array('ab');
659addThis();
660
661status = inSection(80);
662pattern = /ab*/;
663string = 'xayabbbz';
664actualmatch = string.match(pattern);
665expectedmatch = Array('a');
666addThis();
667
668status = inSection(81);
669pattern = /(ab|cd)e/;
670string = 'abcde';
671actualmatch = string.match(pattern);
672expectedmatch = Array('cde', 'cd');
673addThis();
674
675status = inSection(82);
676pattern = /[abhgefdc]ij/;
677string = 'hij';
678actualmatch = string.match(pattern);
679expectedmatch = Array('hij');
680addThis();
681
682status = inSection(83);
683pattern = /(abc|)ef/;
684string = 'abcdef';
685actualmatch = string.match(pattern);
686expectedmatch = Array('ef', '');
687addThis();
688
689status = inSection(84);
690pattern = /(a|b)c*d/;
691string = 'abcd';
692actualmatch = string.match(pattern);
693expectedmatch = Array('bcd', 'b');
694addThis();
695
696status = inSection(85);
697pattern = /(ab|ab*)bc/;
698string = 'abc';
699actualmatch = string.match(pattern);
700expectedmatch = Array('abc', 'a');
701addThis();
702
703status = inSection(86);
704pattern = /a([bc]*)c*/;
705string = 'abc';
706actualmatch = string.match(pattern);
707expectedmatch = Array('abc', 'bc');
708addThis();
709
710status = inSection(87);
711pattern = /a([bc]*)(c*d)/;
712string = 'abcd';
713actualmatch = string.match(pattern);
714expectedmatch = Array('abcd', 'bc', 'd');
715addThis();
716
717status = inSection(88);
718pattern = /a([bc]+)(c*d)/;
719string = 'abcd';
720actualmatch = string.match(pattern);
721expectedmatch = Array('abcd', 'bc', 'd');
722addThis();
723
724status = inSection(89);
725pattern = /a([bc]*)(c+d)/;
726string = 'abcd';
727actualmatch = string.match(pattern);
728expectedmatch = Array('abcd', 'b', 'cd');
729addThis();
730
731status = inSection(90);
732pattern = /a[bcd]*dcdcde/;
733string = 'adcdcde';
734actualmatch = string.match(pattern);
735expectedmatch = Array('adcdcde');
736addThis();
737
738status = inSection(91);
739pattern = /(ab|a)b*c/;
740string = 'abc';
741actualmatch = string.match(pattern);
742expectedmatch = Array('abc', 'ab');
743addThis();
744
745status = inSection(92);
746pattern = /((a)(b)c)(d)/;
747string = 'abcd';
748actualmatch = string.match(pattern);
749expectedmatch = Array('abcd', 'abc', 'a', 'b', 'd');
750addThis();
751
752status = inSection(93);
753pattern = /[a-zA-Z_][a-zA-Z0-9_]*/;
754string = 'alpha';
755actualmatch = string.match(pattern);
756expectedmatch = Array('alpha');
757addThis();
758
759status = inSection(94);
760pattern = /^a(bc+|b[eh])g|.h$/;
761string = 'abh';
762actualmatch = string.match(pattern);
763expectedmatch = Array('bh', undefined);
764addThis();
765
766status = inSection(95);
767pattern = /(bc+d$|ef*g.|h?i(j|k))/;
768string = 'effgz';
769actualmatch = string.match(pattern);
770expectedmatch = Array('effgz', 'effgz', undefined);
771addThis();
772
773status = inSection(96);
774pattern = /(bc+d$|ef*g.|h?i(j|k))/;
775string = 'ij';
776actualmatch = string.match(pattern);
777expectedmatch = Array('ij', 'ij', 'j');
778addThis();
779
780status = inSection(97);
781pattern = /(bc+d$|ef*g.|h?i(j|k))/;
782string = 'reffgz';
783actualmatch = string.match(pattern);
784expectedmatch = Array('effgz', 'effgz', undefined);
785addThis();
786
787status = inSection(98);
788pattern = /((((((((((a))))))))))/;
789string = 'a';
790actualmatch = string.match(pattern);
791expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
792addThis();
793
794status = inSection(99);
795pattern = /((((((((((a))))))))))\10/;
796string = 'aa';
797actualmatch = string.match(pattern);
798expectedmatch = Array('aa', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
799addThis();
800
801status = inSection(100);
802pattern = /((((((((((a))))))))))/;
803string = 'a!';
804actualmatch = string.match(pattern);
805expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
806addThis();
807
808status = inSection(101);
809pattern = /(((((((((a)))))))))/;
810string = 'a';
811actualmatch = string.match(pattern);
812expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a');
813addThis();
814
815status = inSection(102);
816pattern = /(.*)c(.*)/;
817string = 'abcde';
818actualmatch = string.match(pattern);
819expectedmatch = Array('abcde', 'ab', 'de');
820addThis();
821
822status = inSection(103);
823pattern = /abcd/;
824string = 'abcd';
825actualmatch = string.match(pattern);
826expectedmatch = Array('abcd');
827addThis();
828
829status = inSection(104);
830pattern = /a(bc)d/;
831string = 'abcd';
832actualmatch = string.match(pattern);
833expectedmatch = Array('abcd', 'bc');
834addThis();
835
836status = inSection(105);
837pattern = /a[-]?c/;
838string = 'ac';
839actualmatch = string.match(pattern);
840expectedmatch = Array('ac');
841addThis();
842
843status = inSection(106);
844pattern = /(abc)\1/;
845string = 'abcabc';
846actualmatch = string.match(pattern);
847expectedmatch = Array('abcabc', 'abc');
848addThis();
849
850status = inSection(107);
851pattern = /([a-c]*)\1/;
852string = 'abcabc';
853actualmatch = string.match(pattern);
854expectedmatch = Array('abcabc', 'abc');
855addThis();
856
857status = inSection(108);
858pattern = /(a)|\1/;
859string = 'a';
860actualmatch = string.match(pattern);
861expectedmatch = Array('a', 'a');
862addThis();
863
864status = inSection(109);
865pattern = /(([a-c])b*?\2)*/;
866string = 'ababbbcbc';
867actualmatch = string.match(pattern);
868expectedmatch = Array('ababb', 'bb', 'b');
869addThis();
870
871status = inSection(110);
872pattern = /(([a-c])b*?\2){3}/;
873string = 'ababbbcbc';
874actualmatch = string.match(pattern);
875expectedmatch = Array('ababbbcbc', 'cbc', 'c');
876addThis();
877
878/* Can't refer to a capture before it's encountered & completed
879status = inSection(111);
880pattern = /((\3|b)\2(a)x)+/;
881string = 'aaaxabaxbaaxbbax';
882actualmatch = string.match(pattern);
883expectedmatch = Array('bbax', 'bbax', 'b', 'a');
884addThis();
885
886status = inSection(112);
887pattern = /((\3|b)\2(a)){2,}/;
888string = 'bbaababbabaaaaabbaaaabba';
889actualmatch = string.match(pattern);
890expectedmatch = Array('bbaaaabba', 'bba', 'b', 'a');
891addThis();
892*/
893
894status = inSection(113);
895pattern = /abc/i;
896string = 'ABC';
897actualmatch = string.match(pattern);
898expectedmatch = Array('ABC');
899addThis();
900
901status = inSection(114);
902pattern = /abc/i;
903string = 'XABCY';
904actualmatch = string.match(pattern);
905expectedmatch = Array('ABC');
906addThis();
907
908status = inSection(115);
909pattern = /abc/i;
910string = 'ABABC';
911actualmatch = string.match(pattern);
912expectedmatch = Array('ABC');
913addThis();
914
915status = inSection(116);
916pattern = /ab*c/i;
917string = 'ABC';
918actualmatch = string.match(pattern);
919expectedmatch = Array('ABC');
920addThis();
921
922status = inSection(117);
923pattern = /ab*bc/i;
924string = 'ABC';
925actualmatch = string.match(pattern);
926expectedmatch = Array('ABC');
927addThis();
928
929status = inSection(118);
930pattern = /ab*bc/i;
931string = 'ABBC';
932actualmatch = string.match(pattern);
933expectedmatch = Array('ABBC');
934addThis();
935
936status = inSection(119);
937pattern = /ab*?bc/i;
938string = 'ABBBBC';
939actualmatch = string.match(pattern);
940expectedmatch = Array('ABBBBC');
941addThis();
942
943status = inSection(120);
944pattern = /ab{0,}?bc/i;
945string = 'ABBBBC';
946actualmatch = string.match(pattern);
947expectedmatch = Array('ABBBBC');
948addThis();
949
950status = inSection(121);
951pattern = /ab+?bc/i;
952string = 'ABBC';
953actualmatch = string.match(pattern);
954expectedmatch = Array('ABBC');
955addThis();
956
957status = inSection(122);
958pattern = /ab+bc/i;
959string = 'ABBBBC';
960actualmatch = string.match(pattern);
961expectedmatch = Array('ABBBBC');
962addThis();
963
964status = inSection(123);
965pattern = /ab{1,}?bc/i;
966string = 'ABBBBC';
967actualmatch = string.match(pattern);
968expectedmatch = Array('ABBBBC');
969addThis();
970
971status = inSection(124);
972pattern = /ab{1,3}?bc/i;
973string = 'ABBBBC';
974actualmatch = string.match(pattern);
975expectedmatch = Array('ABBBBC');
976addThis();
977
978status = inSection(125);
979pattern = /ab{3,4}?bc/i;
980string = 'ABBBBC';
981actualmatch = string.match(pattern);
982expectedmatch = Array('ABBBBC');
983addThis();
984
985status = inSection(126);
986pattern = /ab??bc/i;
987string = 'ABBC';
988actualmatch = string.match(pattern);
989expectedmatch = Array('ABBC');
990addThis();
991
992status = inSection(127);
993pattern = /ab??bc/i;
994string = 'ABC';
995actualmatch = string.match(pattern);
996expectedmatch = Array('ABC');
997addThis();
998
999status = inSection(128);
1000pattern = /ab{0,1}?bc/i;
1001string = 'ABC';
1002actualmatch = string.match(pattern);
1003expectedmatch = Array('ABC');
1004addThis();
1005
1006status = inSection(129);
1007pattern = /ab??c/i;
1008string = 'ABC';
1009actualmatch = string.match(pattern);
1010expectedmatch = Array('ABC');
1011addThis();
1012
1013status = inSection(130);
1014pattern = /ab{0,1}?c/i;
1015string = 'ABC';
1016actualmatch = string.match(pattern);
1017expectedmatch = Array('ABC');
1018addThis();
1019
1020status = inSection(131);
1021pattern = /^abc$/i;
1022string = 'ABC';
1023actualmatch = string.match(pattern);
1024expectedmatch = Array('ABC');
1025addThis();
1026
1027status = inSection(132);
1028pattern = /^abc/i;
1029string = 'ABCC';
1030actualmatch = string.match(pattern);
1031expectedmatch = Array('ABC');
1032addThis();
1033
1034status = inSection(133);
1035pattern = /abc$/i;
1036string = 'AABC';
1037actualmatch = string.match(pattern);
1038expectedmatch = Array('ABC');
1039addThis();
1040
1041status = inSection(134);
1042pattern = /^/i;
1043string = 'ABC';
1044actualmatch = string.match(pattern);
1045expectedmatch = Array('');
1046addThis();
1047
1048status = inSection(135);
1049pattern = /$/i;
1050string = 'ABC';
1051actualmatch = string.match(pattern);
1052expectedmatch = Array('');
1053addThis();
1054
1055status = inSection(136);
1056pattern = /a.c/i;
1057string = 'ABC';
1058actualmatch = string.match(pattern);
1059expectedmatch = Array('ABC');
1060addThis();
1061
1062status = inSection(137);
1063pattern = /a.c/i;
1064string = 'AXC';
1065actualmatch = string.match(pattern);
1066expectedmatch = Array('AXC');
1067addThis();
1068
1069status = inSection(138);
1070pattern = /a.*?c/i;
1071string = 'AXYZC';
1072actualmatch = string.match(pattern);
1073expectedmatch = Array('AXYZC');
1074addThis();
1075
1076status = inSection(139);
1077pattern = /a[bc]d/i;
1078string = 'ABD';
1079actualmatch = string.match(pattern);
1080expectedmatch = Array('ABD');
1081addThis();
1082
1083status = inSection(140);
1084pattern = /a[b-d]e/i;
1085string = 'ACE';
1086actualmatch = string.match(pattern);
1087expectedmatch = Array('ACE');
1088addThis();
1089
1090status = inSection(141);
1091pattern = /a[b-d]/i;
1092string = 'AAC';
1093actualmatch = string.match(pattern);
1094expectedmatch = Array('AC');
1095addThis();
1096
1097status = inSection(142);
1098pattern = /a[-b]/i;
1099string = 'A-';
1100actualmatch = string.match(pattern);
1101expectedmatch = Array('A-');
1102addThis();
1103
1104status = inSection(143);
1105pattern = /a[b-]/i;
1106string = 'A-';
1107actualmatch = string.match(pattern);
1108expectedmatch = Array('A-');
1109addThis();
1110
1111status = inSection(144);
1112pattern = /a]/i;
1113string = 'A]';
1114actualmatch = string.match(pattern);
1115expectedmatch = Array('A]');
1116addThis();
1117
1118/* Perl supports ] & ^] inside a [], ECMA does not
1119status = inSection(145);
1120pattern = /a[]]b/i;
1121string = 'A]B';
1122actualmatch = string.match(pattern);
1123expectedmatch = Array('A]B');
1124addThis();
1125*/
1126
1127status = inSection(146);
1128pattern = /a[^bc]d/i;
1129string = 'AED';
1130actualmatch = string.match(pattern);
1131expectedmatch = Array('AED');
1132addThis();
1133
1134status = inSection(147);
1135pattern = /a[^-b]c/i;
1136string = 'ADC';
1137actualmatch = string.match(pattern);
1138expectedmatch = Array('ADC');
1139addThis();
1140
1141/* Perl supports ] & ^] inside a [], ECMA does not
1142status = inSection(148);
1143pattern = /a[^]b]c/i;
1144string = 'ADC';
1145actualmatch = string.match(pattern);
1146expectedmatch = Array('ADC');
1147addThis();
1148*/
1149
1150status = inSection(149);
1151pattern = /ab|cd/i;
1152string = 'ABC';
1153actualmatch = string.match(pattern);
1154expectedmatch = Array('AB');
1155addThis();
1156
1157status = inSection(150);
1158pattern = /ab|cd/i;
1159string = 'ABCD';
1160actualmatch = string.match(pattern);
1161expectedmatch = Array('AB');
1162addThis();
1163
1164status = inSection(151);
1165pattern = /()ef/i;
1166string = 'DEF';
1167actualmatch = string.match(pattern);
1168expectedmatch = Array('EF', '');
1169addThis();
1170
1171status = inSection(152);
1172pattern = /a\(b/i;
1173string = 'A(B';
1174actualmatch = string.match(pattern);
1175expectedmatch = Array('A(B');
1176addThis();
1177
1178status = inSection(153);
1179pattern = /a\(*b/i;
1180string = 'AB';
1181actualmatch = string.match(pattern);
1182expectedmatch = Array('AB');
1183addThis();
1184
1185status = inSection(154);
1186pattern = /a\(*b/i;
1187string = 'A((B';
1188actualmatch = string.match(pattern);
1189expectedmatch = Array('A((B');
1190addThis();
1191
1192status = inSection(155);
1193pattern = /a\\b/i;
1194string = 'A\\B';
1195actualmatch = string.match(pattern);
1196expectedmatch = Array('A\\B');
1197addThis();
1198
1199status = inSection(156);
1200pattern = /((a))/i;
1201string = 'ABC';
1202actualmatch = string.match(pattern);
1203expectedmatch = Array('A', 'A', 'A');
1204addThis();
1205
1206status = inSection(157);
1207pattern = /(a)b(c)/i;
1208string = 'ABC';
1209actualmatch = string.match(pattern);
1210expectedmatch = Array('ABC', 'A', 'C');
1211addThis();
1212
1213status = inSection(158);
1214pattern = /a+b+c/i;
1215string = 'AABBABC';
1216actualmatch = string.match(pattern);
1217expectedmatch = Array('ABC');
1218addThis();
1219
1220status = inSection(159);
1221pattern = /a{1,}b{1,}c/i;
1222string = 'AABBABC';
1223actualmatch = string.match(pattern);
1224expectedmatch = Array('ABC');
1225addThis();
1226
1227status = inSection(160);
1228pattern = /a.+?c/i;
1229string = 'ABCABC';
1230actualmatch = string.match(pattern);
1231expectedmatch = Array('ABC');
1232addThis();
1233
1234status = inSection(161);
1235pattern = /a.*?c/i;
1236string = 'ABCABC';
1237actualmatch = string.match(pattern);
1238expectedmatch = Array('ABC');
1239addThis();
1240
1241status = inSection(162);
1242pattern = /a.{0,5}?c/i;
1243string = 'ABCABC';
1244actualmatch = string.match(pattern);
1245expectedmatch = Array('ABC');
1246addThis();
1247
1248status = inSection(163);
1249pattern = /(a+|b)*/i;
1250string = 'AB';
1251actualmatch = string.match(pattern);
1252expectedmatch = Array('AB', 'B');
1253addThis();
1254
1255status = inSection(164);
1256pattern = /(a+|b){0,}/i;
1257string = 'AB';
1258actualmatch = string.match(pattern);
1259expectedmatch = Array('AB', 'B');
1260addThis();
1261
1262status = inSection(165);
1263pattern = /(a+|b)+/i;
1264string = 'AB';
1265actualmatch = string.match(pattern);
1266expectedmatch = Array('AB', 'B');
1267addThis();
1268
1269status = inSection(166);
1270pattern = /(a+|b){1,}/i;
1271string = 'AB';
1272actualmatch = string.match(pattern);
1273expectedmatch = Array('AB', 'B');
1274addThis();
1275
1276status = inSection(167);
1277pattern = /(a+|b)?/i;
1278string = 'AB';
1279actualmatch = string.match(pattern);
1280expectedmatch = Array('A', 'A');
1281addThis();
1282
1283status = inSection(168);
1284pattern = /(a+|b){0,1}/i;
1285string = 'AB';
1286actualmatch = string.match(pattern);
1287expectedmatch = Array('A', 'A');
1288addThis();
1289
1290status = inSection(169);
1291pattern = /(a+|b){0,1}?/i;
1292string = 'AB';
1293actualmatch = string.match(pattern);
1294expectedmatch = Array('', undefined);
1295addThis();
1296
1297status = inSection(170);
1298pattern = /[^ab]*/i;
1299string = 'CDE';
1300actualmatch = string.match(pattern);
1301expectedmatch = Array('CDE');
1302addThis();
1303
1304status = inSection(171);
1305pattern = /([abc])*d/i;
1306string = 'ABBBCD';
1307actualmatch = string.match(pattern);
1308expectedmatch = Array('ABBBCD', 'C');
1309addThis();
1310
1311status = inSection(172);
1312pattern = /([abc])*bcd/i;
1313string = 'ABCD';
1314actualmatch = string.match(pattern);
1315expectedmatch = Array('ABCD', 'A');
1316addThis();
1317
1318status = inSection(173);
1319pattern = /a|b|c|d|e/i;
1320string = 'E';
1321actualmatch = string.match(pattern);
1322expectedmatch = Array('E');
1323addThis();
1324
1325status = inSection(174);
1326pattern = /(a|b|c|d|e)f/i;
1327string = 'EF';
1328actualmatch = string.match(pattern);
1329expectedmatch = Array('EF', 'E');
1330addThis();
1331
1332status = inSection(175);
1333pattern = /abcd*efg/i;
1334string = 'ABCDEFG';
1335actualmatch = string.match(pattern);
1336expectedmatch = Array('ABCDEFG');
1337addThis();
1338
1339status = inSection(176);
1340pattern = /ab*/i;
1341string = 'XABYABBBZ';
1342actualmatch = string.match(pattern);
1343expectedmatch = Array('AB');
1344addThis();
1345
1346status = inSection(177);
1347pattern = /ab*/i;
1348string = 'XAYABBBZ';
1349actualmatch = string.match(pattern);
1350expectedmatch = Array('A');
1351addThis();
1352
1353status = inSection(178);
1354pattern = /(ab|cd)e/i;
1355string = 'ABCDE';
1356actualmatch = string.match(pattern);
1357expectedmatch = Array('CDE', 'CD');
1358addThis();
1359
1360status = inSection(179);
1361pattern = /[abhgefdc]ij/i;
1362string = 'HIJ';
1363actualmatch = string.match(pattern);
1364expectedmatch = Array('HIJ');
1365addThis();
1366
1367status = inSection(180);
1368pattern = /(abc|)ef/i;
1369string = 'ABCDEF';
1370actualmatch = string.match(pattern);
1371expectedmatch = Array('EF', '');
1372addThis();
1373
1374status = inSection(181);
1375pattern = /(a|b)c*d/i;
1376string = 'ABCD';
1377actualmatch = string.match(pattern);
1378expectedmatch = Array('BCD', 'B');
1379addThis();
1380
1381status = inSection(182);
1382pattern = /(ab|ab*)bc/i;
1383string = 'ABC';
1384actualmatch = string.match(pattern);
1385expectedmatch = Array('ABC', 'A');
1386addThis();
1387
1388status = inSection(183);
1389pattern = /a([bc]*)c*/i;
1390string = 'ABC';
1391actualmatch = string.match(pattern);
1392expectedmatch = Array('ABC', 'BC');
1393addThis();
1394
1395status = inSection(184);
1396pattern = /a([bc]*)(c*d)/i;
1397string = 'ABCD';
1398actualmatch = string.match(pattern);
1399expectedmatch = Array('ABCD', 'BC', 'D');
1400addThis();
1401
1402status = inSection(185);
1403pattern = /a([bc]+)(c*d)/i;
1404string = 'ABCD';
1405actualmatch = string.match(pattern);
1406expectedmatch = Array('ABCD', 'BC', 'D');
1407addThis();
1408
1409status = inSection(186);
1410pattern = /a([bc]*)(c+d)/i;
1411string = 'ABCD';
1412actualmatch = string.match(pattern);
1413expectedmatch = Array('ABCD', 'B', 'CD');
1414addThis();
1415
1416status = inSection(187);
1417pattern = /a[bcd]*dcdcde/i;
1418string = 'ADCDCDE';
1419actualmatch = string.match(pattern);
1420expectedmatch = Array('ADCDCDE');
1421addThis();
1422
1423status = inSection(188);
1424pattern = /(ab|a)b*c/i;
1425string = 'ABC';
1426actualmatch = string.match(pattern);
1427expectedmatch = Array('ABC', 'AB');
1428addThis();
1429
1430status = inSection(189);
1431pattern = /((a)(b)c)(d)/i;
1432string = 'ABCD';
1433actualmatch = string.match(pattern);
1434expectedmatch = Array('ABCD', 'ABC', 'A', 'B', 'D');
1435addThis();
1436
1437status = inSection(190);
1438pattern = /[a-zA-Z_][a-zA-Z0-9_]*/i;
1439string = 'ALPHA';
1440actualmatch = string.match(pattern);
1441expectedmatch = Array('ALPHA');
1442addThis();
1443
1444status = inSection(191);
1445pattern = /^a(bc+|b[eh])g|.h$/i;
1446string = 'ABH';
1447actualmatch = string.match(pattern);
1448expectedmatch = Array('BH', undefined);
1449addThis();
1450
1451status = inSection(192);
1452pattern = /(bc+d$|ef*g.|h?i(j|k))/i;
1453string = 'EFFGZ';
1454actualmatch = string.match(pattern);
1455expectedmatch = Array('EFFGZ', 'EFFGZ', undefined);
1456addThis();
1457
1458status = inSection(193);
1459pattern = /(bc+d$|ef*g.|h?i(j|k))/i;
1460string = 'IJ';
1461actualmatch = string.match(pattern);
1462expectedmatch = Array('IJ', 'IJ', 'J');
1463addThis();
1464
1465status = inSection(194);
1466pattern = /(bc+d$|ef*g.|h?i(j|k))/i;
1467string = 'REFFGZ';
1468actualmatch = string.match(pattern);
1469expectedmatch = Array('EFFGZ', 'EFFGZ', undefined);
1470addThis();
1471
1472status = inSection(195);
1473pattern = /((((((((((a))))))))))/i;
1474string = 'A';
1475actualmatch = string.match(pattern);
1476expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A');
1477addThis();
1478
1479status = inSection(196);
1480pattern = /((((((((((a))))))))))\10/i;
1481string = 'AA';
1482actualmatch = string.match(pattern);
1483expectedmatch = Array('AA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A');
1484addThis();
1485
1486status = inSection(197);
1487pattern = /((((((((((a))))))))))/i;
1488string = 'A!';
1489actualmatch = string.match(pattern);
1490expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A');
1491addThis();
1492
1493status = inSection(198);
1494pattern = /(((((((((a)))))))))/i;
1495string = 'A';
1496actualmatch = string.match(pattern);
1497expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A');
1498addThis();
1499
1500status = inSection(199);
1501pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i;
1502string = 'A';
1503actualmatch = string.match(pattern);
1504expectedmatch = Array('A', 'A');
1505addThis();
1506
1507status = inSection(200);
1508pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i;
1509string = 'C';
1510actualmatch = string.match(pattern);
1511expectedmatch = Array('C', 'C');
1512addThis();
1513
1514status = inSection(201);
1515pattern = /(.*)c(.*)/i;
1516string = 'ABCDE';
1517actualmatch = string.match(pattern);
1518expectedmatch = Array('ABCDE', 'AB', 'DE');
1519addThis();
1520
1521status = inSection(202);
1522pattern = /abcd/i;
1523string = 'ABCD';
1524actualmatch = string.match(pattern);
1525expectedmatch = Array('ABCD');
1526addThis();
1527
1528status = inSection(203);
1529pattern = /a(bc)d/i;
1530string = 'ABCD';
1531actualmatch = string.match(pattern);
1532expectedmatch = Array('ABCD', 'BC');
1533addThis();
1534
1535status = inSection(204);
1536pattern = /a[-]?c/i;
1537string = 'AC';
1538actualmatch = string.match(pattern);
1539expectedmatch = Array('AC');
1540addThis();
1541
1542status = inSection(205);
1543pattern = /(abc)\1/i;
1544string = 'ABCABC';
1545actualmatch = string.match(pattern);
1546expectedmatch = Array('ABCABC', 'ABC');
1547addThis();
1548
1549status = inSection(206);
1550pattern = /([a-c]*)\1/i;
1551string = 'ABCABC';
1552actualmatch = string.match(pattern);
1553expectedmatch = Array('ABCABC', 'ABC');
1554addThis();
1555
1556status = inSection(207);
1557pattern = /a(?!b)./;
1558string = 'abad';
1559actualmatch = string.match(pattern);
1560expectedmatch = Array('ad');
1561addThis();
1562
1563status = inSection(208);
1564pattern = /a(?=d)./;
1565string = 'abad';
1566actualmatch = string.match(pattern);
1567expectedmatch = Array('ad');
1568addThis();
1569
1570status = inSection(209);
1571pattern = /a(?=c|d)./;
1572string = 'abad';
1573actualmatch = string.match(pattern);
1574expectedmatch = Array('ad');
1575addThis();
1576
1577status = inSection(210);
1578pattern = /a(?:b|c|d)(.)/;
1579string = 'ace';
1580actualmatch = string.match(pattern);
1581expectedmatch = Array('ace', 'e');
1582addThis();
1583
1584status = inSection(211);
1585pattern = /a(?:b|c|d)*(.)/;
1586string = 'ace';
1587actualmatch = string.match(pattern);
1588expectedmatch = Array('ace', 'e');
1589addThis();
1590
1591status = inSection(212);
1592pattern = /a(?:b|c|d)+?(.)/;
1593string = 'ace';
1594actualmatch = string.match(pattern);
1595expectedmatch = Array('ace', 'e');
1596addThis();
1597
1598status = inSection(213);
1599pattern = /a(?:b|c|d)+?(.)/;
1600string = 'acdbcdbe';
1601actualmatch = string.match(pattern);
1602expectedmatch = Array('acd', 'd');
1603addThis();
1604
1605status = inSection(214);
1606pattern = /a(?:b|c|d)+(.)/;
1607string = 'acdbcdbe';
1608actualmatch = string.match(pattern);
1609expectedmatch = Array('acdbcdbe', 'e');
1610addThis();
1611
1612status = inSection(215);
1613pattern = /a(?:b|c|d){2}(.)/;
1614string = 'acdbcdbe';
1615actualmatch = string.match(pattern);
1616expectedmatch = Array('acdb', 'b');
1617addThis();
1618
1619status = inSection(216);
1620pattern = /a(?:b|c|d){4,5}(.)/;
1621string = 'acdbcdbe';
1622actualmatch = string.match(pattern);
1623expectedmatch = Array('acdbcdb', 'b');
1624addThis();
1625
1626status = inSection(217);
1627pattern = /a(?:b|c|d){4,5}?(.)/;
1628string = 'acdbcdbe';
1629actualmatch = string.match(pattern);
1630expectedmatch = Array('acdbcd', 'd');
1631addThis();
1632
1633// MODIFIED - ECMA has different rules for paren contents
1634status = inSection(218);
1635pattern = /((foo)|(bar))*/;
1636string = 'foobar';
1637actualmatch = string.match(pattern);
1638//expectedmatch = Array('foobar', 'bar', 'foo', 'bar');
1639expectedmatch = Array('foobar', 'bar', undefined, 'bar');
1640addThis();
1641
1642status = inSection(219);
1643pattern = /a(?:b|c|d){6,7}(.)/;
1644string = 'acdbcdbe';
1645actualmatch = string.match(pattern);
1646expectedmatch = Array('acdbcdbe', 'e');
1647addThis();
1648
1649status = inSection(220);
1650pattern = /a(?:b|c|d){6,7}?(.)/;
1651string = 'acdbcdbe';
1652actualmatch = string.match(pattern);
1653expectedmatch = Array('acdbcdbe', 'e');
1654addThis();
1655
1656status = inSection(221);
1657pattern = /a(?:b|c|d){5,6}(.)/;
1658string = 'acdbcdbe';
1659actualmatch = string.match(pattern);
1660expectedmatch = Array('acdbcdbe', 'e');
1661addThis();
1662
1663status = inSection(222);
1664pattern = /a(?:b|c|d){5,6}?(.)/;
1665string = 'acdbcdbe';
1666actualmatch = string.match(pattern);
1667expectedmatch = Array('acdbcdb', 'b');
1668addThis();
1669
1670status = inSection(223);
1671pattern = /a(?:b|c|d){5,7}(.)/;
1672string = 'acdbcdbe';
1673actualmatch = string.match(pattern);
1674expectedmatch = Array('acdbcdbe', 'e');
1675addThis();
1676
1677status = inSection(224);
1678pattern = /a(?:b|c|d){5,7}?(.)/;
1679string = 'acdbcdbe';
1680actualmatch = string.match(pattern);
1681expectedmatch = Array('acdbcdb', 'b');
1682addThis();
1683
1684status = inSection(225);
1685pattern = /a(?:b|(c|e){1,2}?|d)+?(.)/;
1686string = 'ace';
1687actualmatch = string.match(pattern);
1688expectedmatch = Array('ace', 'c', 'e');
1689addThis();
1690
1691status = inSection(226);
1692pattern = /^(.+)?B/;
1693string = 'AB';
1694actualmatch = string.match(pattern);
1695expectedmatch = Array('AB', 'A');
1696addThis();
1697
1698/* MODIFIED - ECMA has different rules for paren contents */
1699status = inSection(227);
1700pattern = /^([^a-z])|(\^)$/;
1701string = '.';
1702actualmatch = string.match(pattern);
1703//expectedmatch = Array('.', '.', '');
1704expectedmatch = Array('.', '.', undefined);
1705addThis();
1706
1707status = inSection(228);
1708pattern = /^[<>]&/;
1709string = '<&OUT';
1710actualmatch = string.match(pattern);
1711expectedmatch = Array('<&');
1712addThis();
1713
1714/* Can't refer to a capture before it's encountered & completed
1715status = inSection(229);
1716pattern = /^(a\1?){4}$/;
1717string = 'aaaaaaaaaa';
1718actualmatch = string.match(pattern);
1719expectedmatch = Array('aaaaaaaaaa', 'aaaa');
1720addThis();
1721
1722status = inSection(230);
1723pattern = /^(a(?(1)\1)){4}$/;
1724string = 'aaaaaaaaaa';
1725actualmatch = string.match(pattern);
1726expectedmatch = Array('aaaaaaaaaa', 'aaaa');
1727addThis();
1728*/
1729
1730status = inSection(231);
1731pattern = /((a{4})+)/;
1732string = 'aaaaaaaaa';
1733actualmatch = string.match(pattern);
1734expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa');
1735addThis();
1736
1737status = inSection(232);
1738pattern = /(((aa){2})+)/;
1739string = 'aaaaaaaaaa';
1740actualmatch = string.match(pattern);
1741expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa');
1742addThis();
1743
1744status = inSection(233);
1745pattern = /(((a{2}){2})+)/;
1746string = 'aaaaaaaaaa';
1747actualmatch = string.match(pattern);
1748expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa');
1749addThis();
1750
1751status = inSection(234);
1752pattern = /(?:(f)(o)(o)|(b)(a)(r))*/;
1753string = 'foobar';
1754actualmatch = string.match(pattern);
1755//expectedmatch = Array('foobar', 'f', 'o', 'o', 'b', 'a', 'r');
1756expectedmatch = Array('foobar', undefined, undefined, undefined, 'b', 'a', 'r');
1757addThis();
1758
1759/* ECMA supports (?: (?= and (?! but doesn't support (?< etc.
1760status = inSection(235);
1761pattern = /(?<=a)b/;
1762string = 'ab';
1763actualmatch = string.match(pattern);
1764expectedmatch = Array('b');
1765addThis();
1766
1767status = inSection(236);
1768pattern = /(?<!c)b/;
1769string = 'ab';
1770actualmatch = string.match(pattern);
1771expectedmatch = Array('b');
1772addThis();
1773
1774status = inSection(237);
1775pattern = /(?<!c)b/;
1776string = 'b';
1777actualmatch = string.match(pattern);
1778expectedmatch = Array('b');
1779addThis();
1780
1781status = inSection(238);
1782pattern = /(?<!c)b/;
1783string = 'b';
1784actualmatch = string.match(pattern);
1785expectedmatch = Array('b');
1786addThis();
1787*/
1788
1789status = inSection(239);
1790pattern = /(?:..)*a/;
1791string = 'aba';
1792actualmatch = string.match(pattern);
1793expectedmatch = Array('aba');
1794addThis();
1795
1796status = inSection(240);
1797pattern = /(?:..)*?a/;
1798string = 'aba';
1799actualmatch = string.match(pattern);
1800expectedmatch = Array('a');
1801addThis();
1802
1803/*
1804 * MODIFIED - ECMA has different rules for paren contents. Note
1805 * this regexp has two non-capturing parens, and one capturing
1806 *
1807 * The issue: shouldn't the match be ['ab', undefined]? Because the
1808 * '\1' matches the undefined value of the second iteration of the '*'
1809 * (in which the 'b' part of the '|' matches). But Perl wants ['ab','b'].
1810 *
1811 * Answer: waldemar@netscape.com:
1812 *
1813 * The correct answer is ['ab', undefined].  Perl doesn't match
1814 * ECMAScript here, and I'd say that Perl is wrong in this case.
1815 */
1816status = inSection(241);
1817pattern = /^(?:b|a(?=(.)))*\1/;
1818string = 'abc';
1819actualmatch = string.match(pattern);
1820//expectedmatch = Array('ab', 'b');
1821expectedmatch = Array('ab', undefined);
1822addThis();
1823
1824status = inSection(242);
1825pattern = /^(){3,5}/;
1826string = 'abc';
1827actualmatch = string.match(pattern);
1828expectedmatch = Array('', '');
1829addThis();
1830
1831status = inSection(243);
1832pattern = /^(a+)*ax/;
1833string = 'aax';
1834actualmatch = string.match(pattern);
1835expectedmatch = Array('aax', 'a');
1836addThis();
1837
1838status = inSection(244);
1839pattern = /^((a|b)+)*ax/;
1840string = 'aax';
1841actualmatch = string.match(pattern);
1842expectedmatch = Array('aax', 'a', 'a');
1843addThis();
1844
1845status = inSection(245);
1846pattern = /^((a|bc)+)*ax/;
1847string = 'aax';
1848actualmatch = string.match(pattern);
1849expectedmatch = Array('aax', 'a', 'a');
1850addThis();
1851
1852/* MODIFIED - ECMA has different rules for paren contents */
1853status = inSection(246);
1854pattern = /(a|x)*ab/;
1855string = 'cab';
1856actualmatch = string.match(pattern);
1857//expectedmatch = Array('ab', '');
1858expectedmatch = Array('ab', undefined);
1859addThis();
1860
1861status = inSection(247);
1862pattern = /(a)*ab/;
1863string = 'cab';
1864actualmatch = string.match(pattern);
1865expectedmatch = Array('ab', undefined);
1866addThis();
1867
1868/* ECMA doesn't support (?imsx or (?-imsx
1869status = inSection(248);
1870pattern = /(?:(?i)a)b/;
1871string = 'ab';
1872actualmatch = string.match(pattern);
1873expectedmatch = Array('ab');
1874addThis();
1875
1876status = inSection(249);
1877pattern = /((?i)a)b/;
1878string = 'ab';
1879actualmatch = string.match(pattern);
1880expectedmatch = Array('ab', 'a');
1881addThis();
1882
1883status = inSection(250);
1884pattern = /(?:(?i)a)b/;
1885string = 'Ab';
1886actualmatch = string.match(pattern);
1887expectedmatch = Array('Ab');
1888addThis();
1889
1890status = inSection(251);
1891pattern = /((?i)a)b/;
1892string = 'Ab';
1893actualmatch = string.match(pattern);
1894expectedmatch = Array('Ab', 'A');
1895addThis();
1896
1897status = inSection(252);
1898pattern = /(?i:a)b/;
1899string = 'ab';
1900actualmatch = string.match(pattern);
1901expectedmatch = Array('ab');
1902addThis();
1903
1904status = inSection(253);
1905pattern = /((?i:a))b/;
1906string = 'ab';
1907actualmatch = string.match(pattern);
1908expectedmatch = Array('ab', 'a');
1909addThis();
1910
1911status = inSection(254);
1912pattern = /(?i:a)b/;
1913string = 'Ab';
1914actualmatch = string.match(pattern);
1915expectedmatch = Array('Ab');
1916addThis();
1917
1918status = inSection(255);
1919pattern = /((?i:a))b/;
1920string = 'Ab';
1921actualmatch = string.match(pattern);
1922expectedmatch = Array('Ab', 'A');
1923addThis();
1924
1925status = inSection(256);
1926pattern = /(?:(?-i)a)b/i;
1927string = 'ab';
1928actualmatch = string.match(pattern);
1929expectedmatch = Array('ab');
1930addThis();
1931
1932status = inSection(257);
1933pattern = /((?-i)a)b/i;
1934string = 'ab';
1935actualmatch = string.match(pattern);
1936expectedmatch = Array('ab', 'a');
1937addThis();
1938
1939status = inSection(258);
1940pattern = /(?:(?-i)a)b/i;
1941string = 'aB';
1942actualmatch = string.match(pattern);
1943expectedmatch = Array('aB');
1944addThis();
1945
1946status = inSection(259);
1947pattern = /((?-i)a)b/i;
1948string = 'aB';
1949actualmatch = string.match(pattern);
1950expectedmatch = Array('aB', 'a');
1951addThis();
1952
1953status = inSection(260);
1954pattern = /(?:(?-i)a)b/i;
1955string = 'aB';
1956actualmatch = string.match(pattern);
1957expectedmatch = Array('aB');
1958addThis();
1959
1960status = inSection(261);
1961pattern = /((?-i)a)b/i;
1962string = 'aB';
1963actualmatch = string.match(pattern);
1964expectedmatch = Array('aB', 'a');
1965addThis();
1966
1967status = inSection(262);
1968pattern = /(?-i:a)b/i;
1969string = 'ab';
1970actualmatch = string.match(pattern);
1971expectedmatch = Array('ab');
1972addThis();
1973
1974status = inSection(263);
1975pattern = /((?-i:a))b/i;
1976string = 'ab';
1977actualmatch = string.match(pattern);
1978expectedmatch = Array('ab', 'a');
1979addThis();
1980
1981status = inSection(264);
1982pattern = /(?-i:a)b/i;
1983string = 'aB';
1984actualmatch = string.match(pattern);
1985expectedmatch = Array('aB');
1986addThis();
1987
1988status = inSection(265);
1989pattern = /((?-i:a))b/i;
1990string = 'aB';
1991actualmatch = string.match(pattern);
1992expectedmatch = Array('aB', 'a');
1993addThis();
1994
1995status = inSection(266);
1996pattern = /(?-i:a)b/i;
1997string = 'aB';
1998actualmatch = string.match(pattern);
1999expectedmatch = Array('aB');
2000addThis();
2001
2002status = inSection(267);
2003pattern = /((?-i:a))b/i;
2004string = 'aB';
2005actualmatch = string.match(pattern);
2006expectedmatch = Array('aB', 'a');
2007addThis();
2008
2009status = inSection(268);
2010pattern = /((?s-i:a.))b/i;
2011string = 'a\nB';
2012actualmatch = string.match(pattern);
2013expectedmatch = Array('a\nB', 'a\n');
2014addThis();
2015*/
2016
2017status = inSection(269);
2018pattern = /(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))/;
2019string = 'cabbbb';
2020actualmatch = string.match(pattern);
2021expectedmatch = Array('cabbbb');
2022addThis();
2023
2024status = inSection(270);
2025pattern = /(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))/;
2026string = 'caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb';
2027actualmatch = string.match(pattern);
2028expectedmatch = Array('caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
2029addThis();
2030
2031status = inSection(271);
2032pattern = /(ab)\d\1/i;
2033string = 'Ab4ab';
2034actualmatch = string.match(pattern);
2035expectedmatch = Array('Ab4ab', 'Ab');
2036addThis();
2037
2038status = inSection(272);
2039pattern = /(ab)\d\1/i;
2040string = 'ab4Ab';
2041actualmatch = string.match(pattern);
2042expectedmatch = Array('ab4Ab', 'ab');
2043addThis();
2044
2045status = inSection(273);
2046pattern = /foo\w*\d{4}baz/;
2047string = 'foobar1234baz';
2048actualmatch = string.match(pattern);
2049expectedmatch = Array('foobar1234baz');
2050addThis();
2051
2052status = inSection(274);
2053pattern = /x(~~)*(?:(?:F)?)?/;
2054string = 'x~~';
2055actualmatch = string.match(pattern);
2056expectedmatch = Array('x~~', '~~');
2057addThis();
2058
2059/* Perl supports (?# but JS doesn't
2060status = inSection(275);
2061pattern = /^a(?#xxx){3}c/;
2062string = 'aaac';
2063actualmatch = string.match(pattern);
2064expectedmatch = Array('aaac');
2065addThis();
2066*/
2067
2068/* ECMA doesn't support (?< etc
2069status = inSection(276);
2070pattern = /(?<![cd])[ab]/;
2071string = 'dbaacb';
2072actualmatch = string.match(pattern);
2073expectedmatch = Array('a');
2074addThis();
2075
2076status = inSection(277);
2077pattern = /(?<!(c|d))[ab]/;
2078string = 'dbaacb';
2079actualmatch = string.match(pattern);
2080expectedmatch = Array('a');
2081addThis();
2082
2083status = inSection(278);
2084pattern = /(?<!cd)[ab]/;
2085string = 'cdaccb';
2086actualmatch = string.match(pattern);
2087expectedmatch = Array('b');
2088addThis();
2089
2090status = inSection(279);
2091pattern = /((?s)^a(.))((?m)^b$)/;
2092string = 'a\nb\nc\n';
2093actualmatch = string.match(pattern);
2094expectedmatch = Array('a\nb', 'a\n', '\n', 'b');
2095addThis();
2096
2097status = inSection(280);
2098pattern = /((?m)^b$)/;
2099string = 'a\nb\nc\n';
2100actualmatch = string.match(pattern);
2101expectedmatch = Array('b', 'b');
2102addThis();
2103
2104status = inSection(281);
2105pattern = /(?m)^b/;
2106string = 'a\nb\n';
2107actualmatch = string.match(pattern);
2108expectedmatch = Array('b');
2109addThis();
2110
2111status = inSection(282);
2112pattern = /(?m)^(b)/;
2113string = 'a\nb\n';
2114actualmatch = string.match(pattern);
2115expectedmatch = Array('b', 'b');
2116addThis();
2117
2118status = inSection(283);
2119pattern = /((?m)^b)/;
2120string = 'a\nb\n';
2121actualmatch = string.match(pattern);
2122expectedmatch = Array('b', 'b');
2123addThis();
2124
2125status = inSection(284);
2126pattern = /\n((?m)^b)/;
2127string = 'a\nb\n';
2128actualmatch = string.match(pattern);
2129expectedmatch = Array('\nb', 'b');
2130addThis();
2131
2132status = inSection(285);
2133pattern = /((?s).)c(?!.)/;
2134string = 'a\nb\nc\n';
2135actualmatch = string.match(pattern);
2136expectedmatch = Array('\nc', '\n');
2137addThis();
2138
2139status = inSection(286);
2140pattern = /((?s).)c(?!.)/;
2141string = 'a\nb\nc\n';
2142actualmatch = string.match(pattern);
2143expectedmatch = Array('\nc', '\n');
2144addThis();
2145
2146status = inSection(287);
2147pattern = /((?s)b.)c(?!.)/;
2148string = 'a\nb\nc\n';
2149actualmatch = string.match(pattern);
2150expectedmatch = Array('b\nc', 'b\n');
2151addThis();
2152
2153status = inSection(288);
2154pattern = /((?s)b.)c(?!.)/;
2155string = 'a\nb\nc\n';
2156actualmatch = string.match(pattern);
2157expectedmatch = Array('b\nc', 'b\n');
2158addThis();
2159
2160status = inSection(289);
2161pattern = /((?m)^b)/;
2162string = 'a\nb\nc\n';
2163actualmatch = string.match(pattern);
2164expectedmatch = Array('b', 'b');
2165addThis();
2166*/
2167
2168/* ECMA doesn't support (?(condition)
2169status = inSection(290);
2170pattern = /(?(1)b|a)/;
2171string = 'a';
2172actualmatch = string.match(pattern);
2173expectedmatch = Array('a');
2174addThis();
2175
2176status = inSection(291);
2177pattern = /(x)?(?(1)b|a)/;
2178string = 'a';
2179actualmatch = string.match(pattern);
2180expectedmatch = Array('a');
2181addThis();
2182
2183status = inSection(292);
2184pattern = /()?(?(1)b|a)/;
2185string = 'a';
2186actualmatch = string.match(pattern);
2187expectedmatch = Array('a');
2188addThis();
2189
2190status = inSection(293);
2191pattern = /()?(?(1)a|b)/;
2192string = 'a';
2193actualmatch = string.match(pattern);
2194expectedmatch = Array('a');
2195addThis();
2196
2197status = inSection(294);
2198pattern = /^(\()?blah(?(1)(\)))$/;
2199string = '(blah)';
2200actualmatch = string.match(pattern);
2201expectedmatch = Array('(blah)', '(', ')');
2202addThis();
2203
2204status = inSection(295);
2205pattern = /^(\()?blah(?(1)(\)))$/;
2206string = 'blah';
2207actualmatch = string.match(pattern);
2208expectedmatch = Array('blah');
2209addThis();
2210
2211status = inSection(296);
2212pattern = /^(\(+)?blah(?(1)(\)))$/;
2213string = '(blah)';
2214actualmatch = string.match(pattern);
2215expectedmatch = Array('(blah)', '(', ')');
2216addThis();
2217
2218status = inSection(297);
2219pattern = /^(\(+)?blah(?(1)(\)))$/;
2220string = 'blah';
2221actualmatch = string.match(pattern);
2222expectedmatch = Array('blah');
2223addThis();
2224
2225status = inSection(298);
2226pattern = /(?(?!a)b|a)/;
2227string = 'a';
2228actualmatch = string.match(pattern);
2229expectedmatch = Array('a');
2230addThis();
2231
2232status = inSection(299);
2233pattern = /(?(?=a)a|b)/;
2234string = 'a';
2235actualmatch = string.match(pattern);
2236expectedmatch = Array('a');
2237addThis();
2238*/
2239
2240status = inSection(300);
2241pattern = /(?=(a+?))(\1ab)/;
2242string = 'aaab';
2243actualmatch = string.match(pattern);
2244expectedmatch = Array('aab', 'a', 'aab');
2245addThis();
2246
2247status = inSection(301);
2248pattern = /(\w+:)+/;
2249string = 'one:';
2250actualmatch = string.match(pattern);
2251expectedmatch = Array('one:', 'one:');
2252addThis();
2253
2254/* ECMA doesn't support (?< etc
2255status = inSection(302);
2256pattern = /$(?<=^(a))/;
2257string = 'a';
2258actualmatch = string.match(pattern);
2259expectedmatch = Array('', 'a');
2260addThis();
2261*/
2262
2263status = inSection(303);
2264pattern = /(?=(a+?))(\1ab)/;
2265string = 'aaab';
2266actualmatch = string.match(pattern);
2267expectedmatch = Array('aab', 'a', 'aab');
2268addThis();
2269
2270/* MODIFIED - ECMA has different rules for paren contents */
2271status = inSection(304);
2272pattern = /([\w:]+::)?(\w+)$/;
2273string = 'abcd';
2274actualmatch = string.match(pattern);
2275//expectedmatch = Array('abcd', '', 'abcd');
2276expectedmatch = Array('abcd', undefined, 'abcd');
2277addThis();
2278
2279status = inSection(305);
2280pattern = /([\w:]+::)?(\w+)$/;
2281string = 'xy:z:::abcd';
2282actualmatch = string.match(pattern);
2283expectedmatch = Array('xy:z:::abcd', 'xy:z:::', 'abcd');
2284addThis();
2285
2286status = inSection(306);
2287pattern = /^[^bcd]*(c+)/;
2288string = 'aexycd';
2289actualmatch = string.match(pattern);
2290expectedmatch = Array('aexyc', 'c');
2291addThis();
2292
2293status = inSection(307);
2294pattern = /(a*)b+/;
2295string = 'caab';
2296actualmatch = string.match(pattern);
2297expectedmatch = Array('aab', 'aa');
2298addThis();
2299
2300/* MODIFIED - ECMA has different rules for paren contents */
2301status = inSection(308);
2302pattern = /([\w:]+::)?(\w+)$/;
2303string = 'abcd';
2304actualmatch = string.match(pattern);
2305//expectedmatch = Array('abcd', '', 'abcd');
2306expectedmatch = Array('abcd', undefined, 'abcd');
2307addThis();
2308
2309status = inSection(309);
2310pattern = /([\w:]+::)?(\w+)$/;
2311string = 'xy:z:::abcd';
2312actualmatch = string.match(pattern);
2313expectedmatch = Array('xy:z:::abcd', 'xy:z:::', 'abcd');
2314addThis();
2315
2316status = inSection(310);
2317pattern = /^[^bcd]*(c+)/;
2318string = 'aexycd';
2319actualmatch = string.match(pattern);
2320expectedmatch = Array('aexyc', 'c');
2321addThis();
2322
2323/* ECMA doesn't support (?>
2324status = inSection(311);
2325pattern = /(?>a+)b/;
2326string = 'aaab';
2327actualmatch = string.match(pattern);
2328expectedmatch = Array('aaab');
2329addThis();
2330*/
2331
2332status = inSection(312);
2333pattern = /([[:]+)/;
2334string = 'a:[b]:';
2335actualmatch = string.match(pattern);
2336expectedmatch = Array(':[', ':[');
2337addThis();
2338
2339status = inSection(313);
2340pattern = /([[=]+)/;
2341string = 'a=[b]=';
2342actualmatch = string.match(pattern);
2343expectedmatch = Array('=[', '=[');
2344addThis();
2345
2346status = inSection(314);
2347pattern = /([[.]+)/;
2348string = 'a.[b].';
2349actualmatch = string.match(pattern);
2350expectedmatch = Array('.[', '.[');
2351addThis();
2352
2353/* ECMA doesn't have rules for [:
2354status = inSection(315);
2355pattern = /[a[:]b[:c]/;
2356string = 'abc';
2357actualmatch = string.match(pattern);
2358expectedmatch = Array('abc');
2359addThis();
2360*/
2361
2362/* ECMA doesn't support (?>
2363status = inSection(316);
2364pattern = /((?>a+)b)/;
2365string = 'aaab';
2366actualmatch = string.match(pattern);
2367expectedmatch = Array('aaab', 'aaab');
2368addThis();
2369
2370status = inSection(317);
2371pattern = /(?>(a+))b/;
2372string = 'aaab';
2373actualmatch = string.match(pattern);
2374expectedmatch = Array('aaab', 'aaa');
2375addThis();
2376
2377status = inSection(318);
2378pattern = /((?>[^()]+)|\([^()]*\))+/;
2379string = '((abc(ade)ufh()()x';
2380actualmatch = string.match(pattern);
2381expectedmatch = Array('abc(ade)ufh()()x', 'x');
2382addThis();
2383*/
2384
2385/* Perl has \Z has end-of-line, ECMA doesn't
2386status = inSection(319);
2387pattern = /\Z/;
2388string = 'a\nb\n';
2389actualmatch = string.match(pattern);
2390expectedmatch = Array('');
2391addThis();
2392
2393status = inSection(320);
2394pattern = /\z/;
2395string = 'a\nb\n';
2396actualmatch = string.match(pattern);
2397expectedmatch = Array('');
2398addThis();
2399*/
2400
2401status = inSection(321);
2402pattern = /$/;
2403string = 'a\nb\n';
2404actualmatch = string.match(pattern);
2405expectedmatch = Array('');
2406addThis();
2407
2408/* Perl has \Z has end-of-line, ECMA doesn't
2409status = inSection(322);
2410pattern = /\Z/;
2411string = 'b\na\n';
2412actualmatch = string.match(pattern);
2413expectedmatch = Array('');
2414addThis();
2415
2416status = inSection(323);
2417pattern = /\z/;
2418string = 'b\na\n';
2419actualmatch = string.match(pattern);
2420expectedmatch = Array('');
2421addThis();
2422*/
2423
2424status = inSection(324);
2425pattern = /$/;
2426string = 'b\na\n';
2427actualmatch = string.match(pattern);
2428expectedmatch = Array('');
2429addThis();
2430
2431/* Perl has \Z has end-of-line, ECMA doesn't
2432status = inSection(325);
2433pattern = /\Z/;
2434string = 'b\na';
2435actualmatch = string.match(pattern);
2436expectedmatch = Array('');
2437addThis();
2438
2439status = inSection(326);
2440pattern = /\z/;
2441string = 'b\na';
2442actualmatch = string.match(pattern);
2443expectedmatch = Array('');
2444addThis();
2445*/
2446
2447status = inSection(327);
2448pattern = /$/;
2449string = 'b\na';
2450actualmatch = string.match(pattern);
2451expectedmatch = Array('');
2452addThis();
2453
2454/* Perl has \Z has end-of-line, ECMA doesn't
2455status = inSection(328);
2456pattern = /\Z/m;
2457string = 'a\nb\n';
2458actualmatch = string.match(pattern);
2459expectedmatch = Array('');
2460addThis();
2461
2462status = inSection(329);
2463pattern = /\z/m;
2464string = 'a\nb\n';
2465actualmatch = string.match(pattern);
2466expectedmatch = Array('');
2467addThis();
2468*/
2469
2470status = inSection(330);
2471pattern = /$/m;
2472string = 'a\nb\n';
2473actualmatch = string.match(pattern);
2474expectedmatch = Array('');
2475addThis();
2476
2477/* Perl has \Z has end-of-line, ECMA doesn't
2478status = inSection(331);
2479pattern = /\Z/m;
2480string = 'b\na\n';
2481actualmatch = string.match(pattern);
2482expectedmatch = Array('');
2483addThis();
2484
2485status = inSection(332);
2486pattern = /\z/m;
2487string = 'b\na\n';
2488actualmatch = string.match(pattern);
2489expectedmatch = Array('');
2490addThis();
2491*/
2492
2493status = inSection(333);
2494pattern = /$/m;
2495string = 'b\na\n';
2496actualmatch = string.match(pattern);
2497expectedmatch = Array('');
2498addThis();
2499
2500/* Perl has \Z has end-of-line, ECMA doesn't
2501status = inSection(334);
2502pattern = /\Z/m;
2503string = 'b\na';
2504actualmatch = string.match(pattern);
2505expectedmatch = Array('');
2506addThis();
2507
2508status = inSection(335);
2509pattern = /\z/m;
2510string = 'b\na';
2511actualmatch = string.match(pattern);
2512expectedmatch = Array('');
2513addThis();
2514*/
2515
2516status = inSection(336);
2517pattern = /$/m;
2518string = 'b\na';
2519actualmatch = string.match(pattern);
2520expectedmatch = Array('');
2521addThis();
2522
2523/* Perl has \Z has end-of-line, ECMA doesn't
2524status = inSection(337);
2525pattern = /a\Z/;
2526string = 'b\na\n';
2527actualmatch = string.match(pattern);
2528expectedmatch = Array('a');
2529addThis();
2530*/
2531
2532/* $ only matches end of input unless multiline
2533status = inSection(338);
2534pattern = /a$/;
2535string = 'b\na\n';
2536actualmatch = string.match(pattern);
2537expectedmatch = Array('a');
2538addThis();
2539*/
2540
2541/* Perl has \Z has end-of-line, ECMA doesn't
2542status = inSection(339);
2543pattern = /a\Z/;
2544string = 'b\na';
2545actualmatch = string.match(pattern);
2546expectedmatch = Array('a');
2547addThis();
2548
2549status = inSection(340);
2550pattern = /a\z/;
2551string = 'b\na';
2552actualmatch = string.match(pattern);
2553expectedmatch = Array('a');
2554addThis();
2555*/
2556
2557status = inSection(341);
2558pattern = /a$/;
2559string = 'b\na';
2560actualmatch = string.match(pattern);
2561expectedmatch = Array('a');
2562addThis();
2563
2564status = inSection(342);
2565pattern = /a$/m;
2566string = 'a\nb\n';
2567actualmatch = string.match(pattern);
2568expectedmatch = Array('a');
2569addThis();
2570
2571/* Perl has \Z has end-of-line, ECMA doesn't
2572status = inSection(343);
2573pattern = /a\Z/m;
2574string = 'b\na\n';
2575actualmatch = string.match(pattern);
2576expectedmatch = Array('a');
2577addThis();
2578*/
2579
2580status = inSection(344);
2581pattern = /a$/m;
2582string = 'b\na\n';
2583actualmatch = string.match(pattern);
2584expectedmatch = Array('a');
2585addThis();
2586
2587/* Perl has \Z has end-of-line, ECMA doesn't
2588status = inSection(345);
2589pattern = /a\Z/m;
2590string = 'b\na';
2591actualmatch = string.match(pattern);
2592expectedmatch = Array('a');
2593addThis();
2594
2595status = inSection(346);
2596pattern = /a\z/m;
2597string = 'b\na';
2598actualmatch = string.match(pattern);
2599expectedmatch = Array('a');
2600addThis();
2601*/
2602
2603status = inSection(347);
2604pattern = /a$/m;
2605string = 'b\na';
2606actualmatch = string.match(pattern);
2607expectedmatch = Array('a');
2608addThis();
2609
2610/* Perl has \Z has end-of-line, ECMA doesn't
2611status = inSection(348);
2612pattern = /aa\Z/;
2613string = 'b\naa\n';
2614actualmatch = string.match(pattern);
2615expectedmatch = Array('aa');
2616addThis();
2617*/
2618
2619/* $ only matches end of input unless multiline
2620status = inSection(349);
2621pattern = /aa$/;
2622string = 'b\naa\n';
2623actualmatch = string.match(pattern);
2624expectedmatch = Array('aa');
2625addThis();
2626*/
2627
2628/* Perl has \Z has end-of-line, ECMA doesn't
2629status = inSection(350);
2630pattern = /aa\Z/;
2631string = 'b\naa';
2632actualmatch = string.match(pattern);
2633expectedmatch = Array('aa');
2634addThis();
2635
2636status = inSection(351);
2637pattern = /aa\z/;
2638string = 'b\naa';
2639actualmatch = string.match(pattern);
2640expectedmatch = Array('aa');
2641addThis();
2642*/
2643
2644status = inSection(352);
2645pattern = /aa$/;
2646string = 'b\naa';
2647actualmatch = string.match(pattern);
2648expectedmatch = Array('aa');
2649addThis();
2650
2651status = inSection(353);
2652pattern = /aa$/m;
2653string = 'aa\nb\n';
2654actualmatch = string.match(pattern);
2655expectedmatch = Array('aa');
2656addThis();
2657
2658/* Perl has \Z has end-of-line, ECMA doesn't
2659status = inSection(354);
2660pattern = /aa\Z/m;
2661string = 'b\naa\n';
2662actualmatch = string.match(pattern);
2663expectedmatch = Array('aa');
2664addThis();
2665*/
2666
2667status = inSection(355);
2668pattern = /aa$/m;
2669string = 'b\naa\n';
2670actualmatch = string.match(pattern);
2671expectedmatch = Array('aa');
2672addThis();
2673
2674/* Perl has \Z has end-of-line, ECMA doesn't
2675status = inSection(356);
2676pattern = /aa\Z/m;
2677string = 'b\naa';
2678actualmatch = string.match(pattern);
2679expectedmatch = Array('aa');
2680addThis();
2681
2682status = inSection(357);
2683pattern = /aa\z/m;
2684string = 'b\naa';
2685actualmatch = string.match(pattern);
2686expectedmatch = Array('aa');
2687addThis();
2688*/
2689
2690status = inSection(358);
2691pattern = /aa$/m;
2692string = 'b\naa';
2693actualmatch = string.match(pattern);
2694expectedmatch = Array('aa');
2695addThis();
2696
2697/* Perl has \Z has end-of-line, ECMA doesn't
2698status = inSection(359);
2699pattern = /ab\Z/;
2700string = 'b\nab\n';
2701actualmatch = string.match(pattern);
2702expectedmatch = Array('ab');
2703addThis();
2704*/
2705
2706/* $ only matches end of input unless multiline
2707status = inSection(360);
2708pattern = /ab$/;
2709string = 'b\nab\n';
2710actualmatch = string.match(pattern);
2711expectedmatch = Array('ab');
2712addThis();
2713*/
2714
2715/* Perl has \Z has end-of-line, ECMA doesn't
2716status = inSection(361);
2717pattern = /ab\Z/;
2718string = 'b\nab';
2719actualmatch = string.match(pattern);
2720expectedmatch = Array('ab');
2721addThis();
2722
2723status = inSection(362);
2724pattern = /ab\z/;
2725string = 'b\nab';
2726actualmatch = string.match(pattern);
2727expectedmatch = Array('ab');
2728addThis();
2729*/
2730
2731status = inSection(363);
2732pattern = /ab$/;
2733string = 'b\nab';
2734actualmatch = string.match(pattern);
2735expectedmatch = Array('ab');
2736addThis();
2737
2738status = inSection(364);
2739pattern = /ab$/m;
2740string = 'ab\nb\n';
2741actualmatch = string.match(pattern);
2742expectedmatch = Array('ab');
2743addThis();
2744
2745/* Perl has \Z has end-of-line, ECMA doesn't
2746status = inSection(365);
2747pattern = /ab\Z/m;
2748string = 'b\nab\n';
2749actualmatch = string.match(pattern);
2750expectedmatch = Array('ab');
2751addThis();
2752*/
2753
2754status = inSection(366);
2755pattern = /ab$/m;
2756string = 'b\nab\n';
2757actualmatch = string.match(pattern);
2758expectedmatch = Array('ab');
2759addThis();
2760
2761/* Perl has \Z has end-of-line, ECMA doesn't
2762status = inSection(367);
2763pattern = /ab\Z/m;
2764string = 'b\nab';
2765actualmatch = string.match(pattern);
2766expectedmatch = Array('ab');
2767addThis();
2768
2769status = inSection(368);
2770pattern = /ab\z/m;
2771string = 'b\nab';
2772actualmatch = string.match(pattern);
2773expectedmatch = Array('ab');
2774addThis();
2775*/
2776
2777status = inSection(369);
2778pattern = /ab$/m;
2779string = 'b\nab';
2780actualmatch = string.match(pattern);
2781expectedmatch = Array('ab');
2782addThis();
2783
2784/* Perl has \Z has end-of-line, ECMA doesn't
2785status = inSection(370);
2786pattern = /abb\Z/;
2787string = 'b\nabb\n';
2788actualmatch = string.match(pattern);
2789expectedmatch = Array('abb');
2790addThis();
2791*/
2792
2793/* $ only matches end of input unless multiline
2794status = inSection(371);
2795pattern = /abb$/;
2796string = 'b\nabb\n';
2797actualmatch = string.match(pattern);
2798expectedmatch = Array('abb');
2799addThis();
2800*/
2801
2802/* Perl has \Z has end-of-line, ECMA doesn't
2803status = inSection(372);
2804pattern = /abb\Z/;
2805string = 'b\nabb';
2806actualmatch = string.match(pattern);
2807expectedmatch = Array('abb');
2808addThis();
2809
2810status = inSection(373);
2811pattern = /abb\z/;
2812string = 'b\nabb';
2813actualmatch = string.match(pattern);
2814expectedmatch = Array('abb');
2815addThis();
2816*/
2817
2818status = inSection(374);
2819pattern = /abb$/;
2820string = 'b\nabb';
2821actualmatch = string.match(pattern);
2822expectedmatch = Array('abb');
2823addThis();
2824
2825status = inSection(375);
2826pattern = /abb$/m;
2827string = 'abb\nb\n';
2828actualmatch = string.match(pattern);
2829expectedmatch = Array('abb');
2830addThis();
2831
2832/* Perl has \Z has end-of-line, ECMA doesn't
2833status = inSection(376);
2834pattern = /abb\Z/m;
2835string = 'b\nabb\n';
2836actualmatch = string.match(pattern);
2837expectedmatch = Array('abb');
2838addThis();
2839*/
2840
2841status = inSection(377);
2842pattern = /abb$/m;
2843string = 'b\nabb\n';
2844actualmatch = string.match(pattern);
2845expectedmatch = Array('abb');
2846addThis();
2847
2848/* Perl has \Z has end-of-line, ECMA doesn't
2849status = inSection(378);
2850pattern = /abb\Z/m;
2851string = 'b\nabb';
2852actualmatch = string.match(pattern);
2853expectedmatch = Array('abb');
2854addThis();
2855
2856status = inSection(379);
2857pattern = /abb\z/m;
2858string = 'b\nabb';
2859actualmatch = string.match(pattern);
2860expectedmatch = Array('abb');
2861addThis();
2862*/
2863
2864status = inSection(380);
2865pattern = /abb$/m;
2866string = 'b\nabb';
2867actualmatch = string.match(pattern);
2868expectedmatch = Array('abb');
2869addThis();
2870
2871status = inSection(381);
2872pattern = /(^|x)(c)/;
2873string = 'ca';
2874actualmatch = string.match(pattern);
2875expectedmatch = Array('c', '', 'c');
2876addThis();
2877
2878status = inSection(382);
2879pattern = /foo.bart/;
2880string = 'foo.bart';
2881actualmatch = string.match(pattern);
2882expectedmatch = Array('foo.bart');
2883addThis();
2884
2885status = inSection(383);
2886pattern = /^d[x][x][x]/m;
2887string = 'abcd\ndxxx';
2888actualmatch = string.match(pattern);
2889expectedmatch = Array('dxxx');
2890addThis();
2891
2892status = inSection(384);
2893pattern = /tt+$/;
2894string = 'xxxtt';
2895actualmatch = string.match(pattern);
2896expectedmatch = Array('tt');
2897addThis();
2898
2899/* ECMA spec says that each atom in a range must be a single character
2900status = inSection(385);
2901pattern = /([a-\d]+)/;
2902string = 'za-9z';
2903actualmatch = string.match(pattern);
2904expectedmatch = Array('9', '9');
2905addThis();
2906
2907status = inSection(386);
2908pattern = /([\d-z]+)/;
2909string = 'a0-za';
2910actualmatch = string.match(pattern);
2911expectedmatch = Array('0-z', '0-z');
2912addThis();
2913*/
2914
2915/* ECMA doesn't support [:
2916status = inSection(387);
2917pattern = /([a-[:digit:]]+)/;
2918string = 'za-9z';
2919actualmatch = string.match(pattern);
2920expectedmatch = Array('a-9', 'a-9');
2921addThis();
2922
2923status = inSection(388);
2924pattern = /([[:digit:]-z]+)/;
2925string = '=0-z=';
2926actualmatch = string.match(pattern);
2927expectedmatch = Array('0-z', '0-z');
2928addThis();
2929
2930status = inSection(389);
2931pattern = /([[:digit:]-[:alpha:]]+)/;
2932string = '=0-z=';
2933actualmatch = string.match(pattern);
2934expectedmatch = Array('0-z', '0-z');
2935addThis();
2936*/
2937
2938status = inSection(390);
2939pattern = /(\d+\.\d+)/;
2940string = '3.1415926';
2941actualmatch = string.match(pattern);
2942expectedmatch = Array('3.1415926', '3.1415926');
2943addThis();
2944
2945status = inSection(391);
2946pattern = /\.c(pp|xx|c)?$/i;
2947string = 'IO.c';
2948actualmatch = string.match(pattern);
2949expectedmatch = Array('.c', undefined);
2950addThis();
2951
2952status = inSection(392);
2953pattern = /(\.c(pp|xx|c)?$)/i;
2954string = 'IO.c';
2955actualmatch = string.match(pattern);
2956expectedmatch = Array('.c', '.c', undefined);
2957addThis();
2958
2959status = inSection(393);
2960pattern = /(^|a)b/;
2961string = 'ab';
2962actualmatch = string.match(pattern);
2963expectedmatch = Array('ab', 'a');
2964addThis();
2965
2966status = inSection(394);
2967pattern = /^([ab]*?)(b)?(c)$/;
2968string = 'abac';
2969actualmatch = string.match(pattern);
2970expectedmatch = Array('abac', 'aba', undefined, 'c');
2971addThis();
2972
2973status = inSection(395);
2974pattern = /^(?:.,){2}c/i;
2975string = 'a,b,c';
2976actualmatch = string.match(pattern);
2977expectedmatch = Array('a,b,c');
2978addThis();
2979
2980status = inSection(396);
2981pattern = /^(.,){2}c/i;
2982string = 'a,b,c';
2983actualmatch = string.match(pattern);
2984expectedmatch =  Array('a,b,c', 'b,');
2985addThis();
2986
2987status = inSection(397);
2988pattern = /^(?:[^,]*,){2}c/;
2989string = 'a,b,c';
2990actualmatch = string.match(pattern);
2991expectedmatch = Array('a,b,c');
2992addThis();
2993
2994status = inSection(398);
2995pattern = /^([^,]*,){2}c/;
2996string = 'a,b,c';
2997actualmatch = string.match(pattern);
2998expectedmatch = Array('a,b,c', 'b,');
2999addThis();
3000
3001status = inSection(399);
3002pattern = /^([^,]*,){3}d/;
3003string = 'aaa,b,c,d';
3004actualmatch = string.match(pattern);
3005expectedmatch = Array('aaa,b,c,d', 'c,');
3006addThis();
3007
3008status = inSection(400);
3009pattern = /^([^,]*,){3,}d/;
3010string = 'aaa,b,c,d';
3011actualmatch = string.match(pattern);
3012expectedmatch = Array('aaa,b,c,d', 'c,');
3013addThis();
3014
3015status = inSection(401);
3016pattern = /^([^,]*,){0,3}d/;
3017string = 'aaa,b,c,d';
3018actualmatch = string.match(pattern);
3019expectedmatch = Array('aaa,b,c,d', 'c,');
3020addThis();
3021
3022status = inSection(402);
3023pattern = /^([^,]{1,3},){3}d/i;
3024string = 'aaa,b,c,d';
3025actualmatch = string.match(pattern);
3026expectedmatch = Array('aaa,b,c,d', 'c,');
3027addThis();
3028
3029status = inSection(403);
3030pattern = /^([^,]{1,3},){3,}d/;
3031string = 'aaa,b,c,d';
3032actualmatch = string.match(pattern);
3033expectedmatch = Array('aaa,b,c,d', 'c,');
3034addThis();
3035
3036status = inSection(404);
3037pattern = /^([^,]{1,3},){0,3}d/;
3038string = 'aaa,b,c,d';
3039actualmatch = string.match(pattern);
3040expectedmatch = Array('aaa,b,c,d', 'c,');
3041addThis();
3042
3043status = inSection(405);
3044pattern = /^([^,]{1,},){3}d/;
3045string = 'aaa,b,c,d';
3046actualmatch = string.match(pattern);
3047expectedmatch = Array('aaa,b,c,d', 'c,');
3048addThis();
3049
3050status = inSection(406);
3051pattern = /^([^,]{1,},){3,}d/;
3052string = 'aaa,b,c,d';
3053actualmatch = string.match(pattern);
3054expectedmatch = Array('aaa,b,c,d', 'c,');
3055addThis();
3056
3057status = inSection(407);
3058pattern = /^([^,]{1,},){0,3}d/;
3059string = 'aaa,b,c,d';
3060actualmatch = string.match(pattern);
3061expectedmatch = Array('aaa,b,c,d', 'c,');
3062addThis();
3063
3064status = inSection(408);
3065pattern = /^([^,]{0,3},){3}d/i;
3066string = 'aaa,b,c,d';
3067actualmatch = string.match(pattern);
3068expectedmatch = Array('aaa,b,c,d', 'c,');
3069addThis();
3070
3071status = inSection(409);
3072pattern = /^([^,]{0,3},){3,}d/;
3073string = 'aaa,b,c,d';
3074actualmatch = string.match(pattern);
3075expectedmatch = Array('aaa,b,c,d', 'c,');
3076addThis();
3077
3078status = inSection(410);
3079pattern = /^([^,]{0,3},){0,3}d/;
3080string = 'aaa,b,c,d';
3081actualmatch = string.match(pattern);
3082expectedmatch = Array('aaa,b,c,d', 'c,');
3083addThis();
3084
3085/* ECMA doesn't support \A
3086status = inSection(411);
3087pattern = /(?!\A)x/m;
3088string = 'a\nxb\n';
3089actualmatch = string.match(pattern);
3090expectedmatch = Array('\n');
3091addThis();
3092*/
3093
3094status = inSection(412);
3095pattern = /^(a(b)?)+$/;
3096string = 'aba';
3097actualmatch = string.match(pattern);
3098expectedmatch = Array('aba', 'a', undefined);
3099addThis();
3100
3101status = inSection(413);
3102pattern = /^(aa(bb)?)+$/;
3103string = 'aabbaa';
3104actualmatch = string.match(pattern);
3105expectedmatch = Array('aabbaa', 'aa', undefined);
3106addThis();
3107
3108status = inSection(414);
3109pattern = /^.{9}abc.*\n/m;
3110string = '123\nabcabcabcabc\n';
3111actualmatch = string.match(pattern);
3112expectedmatch = Array('abcabcabcabc\n');
3113addThis();
3114
3115status = inSection(415);
3116pattern = /^(a)?a$/;
3117string = 'a';
3118actualmatch = string.match(pattern);
3119expectedmatch = Array('a', undefined);
3120addThis();
3121
3122status = inSection(416);
3123pattern = /^(a\1?)(a\1?)(a\2?)(a\3?)$/;
3124string = 'aaaaaa';
3125actualmatch = string.match(pattern);
3126expectedmatch = Array('aaaaaa', 'a', 'aa', 'a', 'aa');
3127addThis();
3128
3129/* Can't refer to a capture before it's encountered & completed
3130status = inSection(417);
3131pattern = /^(a\1?){4}$/;
3132string = 'aaaaaa';
3133actualmatch = string.match(pattern);
3134expectedmatch = Array('aaaaaa', 'aaa');
3135addThis();
3136*/
3137
3138status = inSection(418);
3139pattern = /^(0+)?(?:x(1))?/;
3140string = 'x1';
3141actualmatch = string.match(pattern);
3142expectedmatch = Array('x1', undefined, '1');
3143addThis();
3144
3145status = inSection(419);
3146pattern = /^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?/;
3147string = '012cxx0190';
3148actualmatch = string.match(pattern);
3149expectedmatch = Array('012cxx0190', '012c', undefined, '0190');
3150addThis();
3151
3152status = inSection(420);
3153pattern = /^(b+?|a){1,2}c/;
3154string = 'bbbac';
3155actualmatch = string.match(pattern);
3156expectedmatch = Array('bbbac', 'a');
3157addThis();
3158
3159status = inSection(421);
3160pattern = /^(b+?|a){1,2}c/;
3161string = 'bbbbac';
3162actualmatch = string.match(pattern);
3163expectedmatch = Array('bbbbac', 'a');
3164addThis();
3165
3166status = inSection(422);
3167pattern = /((?:aaaa|bbbb)cccc)?/;
3168string = 'aaaacccc';
3169actualmatch = string.match(pattern);
3170expectedmatch = Array('aaaacccc', 'aaaacccc');
3171addThis();
3172
3173status = inSection(423);
3174pattern = /((?:aaaa|bbbb)cccc)?/;
3175string = 'bbbbcccc';
3176actualmatch = string.match(pattern);
3177expectedmatch = Array('bbbbcccc', 'bbbbcccc');
3178addThis();
3179
3180
3181
3182
3183//-----------------------------------------------------------------------------
3184test();
3185//-----------------------------------------------------------------------------
3186
3187
3188
3189function addThis()
3190{
3191  if(omitCurrentSection())
3192    return;
3193
3194  statusmessages[i] = status;
3195  patterns[i] = pattern;
3196  strings[i] = string;
3197  actualmatches[i] = actualmatch;
3198  expectedmatches[i] = expectedmatch;
3199  i++;
3200}
3201
3202
3203function omitCurrentSection()
3204{
3205  try
3206  {
3207    // current section number is in global status variable
3208    var n = status.match(/(\d+)/)[1];
3209    return ((n < cnLBOUND) || (n > cnUBOUND));
3210  }
3211  catch(e)
3212  {
3213    return false;
3214  }
3215}
3216
3217
3218function test()
3219{
3220  enterFunc ('test');
3221  printBugNumber (bug);
3222  printStatus (summary);
3223  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
3224  exitFunc ('test');
3225}
3226