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