Debian Codegraph @

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