]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/mozilla/ecma_2/RegExp/properties-002.js
JavaScriptCore-461.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_2 / RegExp / properties-002.js
... / ...
CommitLineData
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 //-----------------------------------------------------------------------------
10var SECTION = "RegExp/properties-002.js";
11var VERSION = "ECMA_2";
12var TITLE = "Properties of RegExp Instances";
13var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346032";
14// ALSO SEE http://bugzilla.mozilla.org/show_bug.cgi?id=124339
15
16
17startTest();
18
19re_1 = /\cA?/g;
20re_1.lastIndex = Math.pow(2,31);
21AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) );
22
23re_2 = /\w*/i;
24re_2.lastIndex = Math.pow(2,32) -1;
25AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 );
26
27re_3 = /\*{0,80}/m;
28re_3.lastIndex = Math.pow(2,31) -1;
29AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 );
30
31re_4 = /^./gim;
32re_4.lastIndex = Math.pow(2,30) -1;
33AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 );
34
35re_5 = /\B/;
36re_5.lastIndex = Math.pow(2,30);
37AddRegExpCases( 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 */
50re_6 = /\B/;
51re_6.lastIndex = Math.pow(2,32);
52AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) );
53
54re_7 = /\B/;
55re_7.lastIndex = Math.pow(2,32) + 1;
56AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 );
57
58re_8 = /\B/;
59re_8.lastIndex = Math.pow(2,32) * 2;
60AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 );
61
62re_9 = /\B/;
63re_9.lastIndex = Math.pow(2,40);
64AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) );
65
66re_10 = /\B/;
67re_10.lastIndex = Number.MAX_VALUE;
68AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE );
69
70
71
72//-----------------------------------------------------------------------------
73test();
74//-----------------------------------------------------------------------------
75
76
77
78function 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}