Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/RegExp_object.js

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