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