tor-browser

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

RegExp_object.js (2078B)


      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   Filename:     RegExp_object.js
      9   Description:  'Tests regular expressions creating RexExp Objects'
     10 
     11   Author:       Nick Lerissa
     12   Date:         March 10, 1998
     13 */
     14 
     15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
     16 var TITLE   = 'RegExp: object';
     17 
     18 writeHeaderToLog('Executing script: RegExp_object.js');
     19 writeHeaderToLog( SECTION + " "+ TITLE);
     20 
     21 var SSN_pattern = new RegExp("\\d{3}-\\d{2}-\\d{4}");
     22 
     23 // testing SSN pattern
     24 new TestCase ( "'Test SSN is 123-34-4567'.match(SSN_pattern))",
     25        String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern)));
     26 
     27 // testing SSN pattern
     28 new TestCase ( "'Test SSN is 123-34-4567'.match(SSN_pattern))",
     29        String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern)));
     30 
     31 var PHONE_pattern = new RegExp("\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})");
     32 // testing PHONE pattern
     33 new TestCase ( "'Our phone number is (408)345-2345.'.match(PHONE_pattern))",
     34        String(["(408)345-2345","408","345","2345"]), String('Our phone number is (408)345-2345.'.match(PHONE_pattern)));
     35 
     36 // testing PHONE pattern
     37 new TestCase ( "'The phone number is 408-345-2345!'.match(PHONE_pattern))",
     38        String(["408-345-2345","408","345","2345"]), String('The phone number is 408-345-2345!'.match(PHONE_pattern)));
     39 
     40 // testing PHONE pattern
     41 new TestCase ( "String(PHONE_pattern.toString())",
     42        "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/", String(PHONE_pattern.toString()));
     43 
     44 // testing conversion to String
     45 new TestCase ( "PHONE_pattern + ' is the string'",
     46        "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/ is the string",PHONE_pattern + ' is the string');
     47 
     48 // testing conversion to int
     49 new TestCase ( "SSN_pattern - 8",
     50        NaN,SSN_pattern - 8);
     51 
     52 var testPattern = new RegExp("(\\d+)45(\\d+)90");
     53 
     54 test();