js/src/tests/ecma_3/RegExp/perlstress-001.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial