js/src/tests/ecma_3/RegExp/15.10.2-1.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /*
     7  *
     8  * Date:    09 July 2002
     9  * SUMMARY: RegExp conformance test
    10  *
    11  *   These testcases are derived from the examples in the ECMA-262 Ed.3 spec
    12  *   scattered through section 15.10.2.
    13  *
    14  */
    15 //-----------------------------------------------------------------------------
    16 var i = 0;
    17 var BUGNUMBER = '(none)';
    18 var summary = 'RegExp conformance test';
    19 var status = '';
    20 var statusmessages = new Array();
    21 var pattern = '';
    22 var patterns = new Array();
    23 var string = '';
    24 var strings = new Array();
    25 var actualmatch = '';
    26 var actualmatches = new Array();
    27 var expectedmatch = '';
    28 var expectedmatches = new Array();
    31 status = inSection(1);
    32 pattern = /a|ab/;
    33 string = 'abc';
    34 actualmatch = string.match(pattern);
    35 expectedmatch = Array('a');
    36 addThis();
    38 status = inSection(2);
    39 pattern = /((a)|(ab))((c)|(bc))/;
    40 string = 'abc';
    41 actualmatch = string.match(pattern);
    42 expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc');
    43 addThis();
    45 status = inSection(3);
    46 pattern = /a[a-z]{2,4}/;
    47 string = 'abcdefghi';
    48 actualmatch = string.match(pattern);
    49 expectedmatch = Array('abcde');
    50 addThis();
    52 status = inSection(4);
    53 pattern = /a[a-z]{2,4}?/;
    54 string = 'abcdefghi';
    55 actualmatch = string.match(pattern);
    56 expectedmatch = Array('abc');
    57 addThis();
    59 status = inSection(5);
    60 pattern = /(aa|aabaac|ba|b|c)*/;
    61 string = 'aabaac';
    62 actualmatch = string.match(pattern);
    63 expectedmatch = Array('aaba', 'ba');
    64 addThis();
    66 status = inSection(6);
    67 pattern = /^(a+)\1*,\1+$/;
    68 string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa';
    69 actualmatch = string.match(pattern);
    70 expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa');
    71 addThis();
    73 status = inSection(7);
    74 pattern = /(z)((a+)?(b+)?(c))*/;
    75 string = 'zaacbbbcac';
    76 actualmatch = string.match(pattern);
    77 expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c');
    78 addThis();
    80 status = inSection(8);
    81 pattern = /(a*)*/;
    82 string = 'b';
    83 actualmatch = string.match(pattern);
    84 expectedmatch = Array('', undefined);
    85 addThis();
    87 status = inSection(9);
    88 pattern = /(a*)b\1+/;
    89 string = 'baaaac';
    90 actualmatch = string.match(pattern);
    91 expectedmatch = Array('b', '');
    92 addThis();
    94 status = inSection(10);
    95 pattern = /(?=(a+))/;
    96 string = 'baaabac';
    97 actualmatch = string.match(pattern);
    98 expectedmatch = Array('', 'aaa');
    99 addThis();
   101 status = inSection(11);
   102 pattern = /(?=(a+))a*b\1/;
   103 string = 'baaabac';
   104 actualmatch = string.match(pattern);
   105 expectedmatch = Array('aba', 'a');
   106 addThis();
   108 status = inSection(12);
   109 pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/;
   110 string = 'baaabaac';
   111 actualmatch = string.match(pattern);
   112 expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac');
   113 addThis();
   115 status = inSection(13);
   116 pattern = /(?=(a+))/;
   117 string = 'baaabac';
   118 actualmatch = string.match(pattern);
   119 expectedmatch = Array('', 'aaa');
   120 addThis();
   124 //-------------------------------------------------------------------------------------------------
   125 test();
   126 //-------------------------------------------------------------------------------------------------
   129 function addThis()
   130 {
   131   statusmessages[i] = status;
   132   patterns[i] = pattern;
   133   strings[i] = string;
   134   actualmatches[i] = actualmatch;
   135   expectedmatches[i] = expectedmatch;
   136   i++;
   137 }
   140 function test()
   141 {
   142   enterFunc ('test');
   143   printBugNumber(BUGNUMBER);
   144   printStatus (summary);
   145   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   146   exitFunc ('test');
   147 }

mercurial