tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

properties-001.js (2734B)


      1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 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/. */
      5 
      6 
      7 /**
      8 *  File Name:          RegExp/properties-001.js
      9 *  ECMA Section:       15.7.6.js
     10 *  Description:        Based on ECMA 2 Draft 7 February 1999
     11 *
     12 *  Author:             christine@netscape.com
     13 *  Date:               19 February 1999
     14 */
     15 var SECTION = "RegExp/properties-001.js";
     16 var TITLE   = "Properties of RegExp Instances";
     17 
     18 AddRegExpCases( new RegExp, "(?:)",   false, false, false, 0 );
     19 AddRegExpCases( /.*/,       ".*", false, false, false, 0 );
     20 AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 );
     21 AddRegExpCases( /[\S]?$/i,  "[\\S]?$", false, true, false, 0 );
     22 AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m,  "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 );
     23 AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi,      "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 );
     24 AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 );
     25 AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 );
     26 
     27 AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 );
     28 AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 );
     29 AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 );
     30 
     31 test();
     32 
     33 function AddRegExpCases( re, s, g, i, m, l ) {
     34 
     35  AddTestCase( re + ".test == RegExp.prototype.test",
     36        true,
     37        re.test == RegExp.prototype.test );
     38 
     39  AddTestCase( re + ".toString == RegExp.prototype.toString",
     40        true,
     41        re.toString == RegExp.prototype.toString );
     42 
     43  AddTestCase( re + ".contructor == RegExp.prototype.constructor",
     44        true,
     45        re.constructor == RegExp.prototype.constructor );
     46 
     47  AddTestCase( re + ".compile == RegExp.prototype.compile",
     48        true,
     49        re.compile == RegExp.prototype.compile );
     50 
     51  AddTestCase( re + ".exec == RegExp.prototype.exec",
     52        true,
     53        re.exec == RegExp.prototype.exec );
     54 
     55  // properties
     56 
     57  AddTestCase( re + ".source",
     58        s,
     59        re.source );
     60 
     61 /*
     62 * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed
     63 * the behavior of toString() and toSource() on empty regexps.
     64 * So branch if |s| is the empty string -
     65 */
     66  var S = s? s : '(?:)';
     67 
     68  AddTestCase( re + ".toString()",
     69        "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
     70        re.toString() );
     71 
     72  AddTestCase( re + ".global",
     73        g,
     74        re.global );
     75 
     76  AddTestCase( re + ".ignoreCase",
     77        i,
     78        re.ignoreCase );
     79 
     80  AddTestCase( re + ".multiline",
     81        m,
     82        re.multiline);
     83 
     84  AddTestCase( re + ".lastIndex",
     85        l,
     86        re.lastIndex  );
     87 }