Debian Codegraph @

rhino/testsrc/tests/ecma_2/RegExp/properties-002.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-002.js';
7
8 /**
9 * File Name: RegExp/properties-002.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 //-----------------------------------------------------------------------------
17 var SECTION = "RegExp/properties-002.js";
18 var VERSION = "ECMA_2";
19 var TITLE = "Properties of RegExp Instances";
20 var BUGNUMBER ="124339";
21
22 startTest();
23
24 re_1 = /\cA?/g;
25 re_1.lastIndex = Math.pow(2,31);
26 AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) );
27
28 re_2 = /\w*/i;
29 re_2.lastIndex = Math.pow(2,32) -1;
30 AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 );
31
32 re_3 = /\*{0,80}/m;
33 re_3.lastIndex = Math.pow(2,31) -1;
34 AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 );
35
36 re_4 = /^./gim;
37 re_4.lastIndex = Math.pow(2,30) -1;
38 AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 );
39
40 re_5 = /\B/;
41 re_5.lastIndex = Math.pow(2,30);
42 AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) );
43
44 /*
45 * Brendan: "need to test cases Math.pow(2,32) and greater to see
46 * whether they round-trip." Reason: thanks to the work done in
47 * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex
48 * is now stored as a double instead of a uint32 (unsigned integer).
49 *
50 * Note 2^32 -1 is the upper bound for uint32's, but doubles can go
51 * all the way up to Number.MAX_VALUE. So that's why we need cases
52 * between those two numbers.
53 *
54 */
55 re_6 = /\B/;
56 re_6.lastIndex = Math.pow(2,32);
57 AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) );
58
59 re_7 = /\B/;
60 re_7.lastIndex = Math.pow(2,32) + 1;
61 AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 );
62
63 re_8 = /\B/;
64 re_8.lastIndex = Math.pow(2,32) * 2;
65 AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 );
66
67 re_9 = /\B/;
68 re_9.lastIndex = Math.pow(2,40);
69 AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) );
70
71 re_10 = /\B/;
72 re_10.lastIndex = Number.MAX_VALUE;
73 AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE );
74
75
76
77 //-----------------------------------------------------------------------------
78 test();
79 //-----------------------------------------------------------------------------
80
81
82
83 function AddRegExpCases( re, s, g, i, m, l ){
84
85 AddTestCase( re + ".test == RegExp.prototype.test",
86 true,
87 re.test == RegExp.prototype.test );
88
89 AddTestCase( re + ".toString == RegExp.prototype.toString",
90 true,
91 re.toString == RegExp.prototype.toString );
92
93 AddTestCase( re + ".contructor == RegExp.prototype.constructor",
94 true,
95 re.constructor == RegExp.prototype.constructor );
96
97 AddTestCase( re + ".compile == RegExp.prototype.compile",
98 true,
99 re.compile == RegExp.prototype.compile );
100
101 AddTestCase( re + ".exec == RegExp.prototype.exec",
102 true,
103 re.exec == RegExp.prototype.exec );
104
105 // properties
106
107 AddTestCase( re + ".source",
108 s,
109 re.source );
110
111 AddTestCase( re + ".toString()",
112 "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
113 re.toString() );
114
115 AddTestCase( re + ".global",
116 g,
117 re.global );
118
119 AddTestCase( re + ".ignoreCase",
120 i,
121 re.ignoreCase );
122
123 AddTestCase( re + ".multiline",
124 m,
125 re.multiline);
126
127 AddTestCase( re + ".lastIndex",
128 l,
129 re.lastIndex );
130 }