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