Debian Codegraph @

js/src/tests/non262/RegExp/properties-002.js

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