|
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-001.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 var SECTION = "RegExp/properties-001.js"; |
|
16 var VERSION = "ECMA_2"; |
|
17 var TITLE = "Properties of RegExp Instances"; |
|
18 var BUGNUMBER =""; |
|
19 |
|
20 startTest(); |
|
21 |
|
22 AddRegExpCases( new RegExp, "", false, false, false, 0 ); |
|
23 AddRegExpCases( /.*/, ".*", false, false, false, 0 ); |
|
24 AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); |
|
25 AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); |
|
26 AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); |
|
27 AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); |
|
28 AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); |
|
29 AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); |
|
30 |
|
31 AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); |
|
32 AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); |
|
33 AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); |
|
34 |
|
35 test(); |
|
36 |
|
37 function AddRegExpCases( re, s, g, i, m, l ) { |
|
38 |
|
39 AddTestCase( re + ".test == RegExp.prototype.test", |
|
40 true, |
|
41 re.test == RegExp.prototype.test ); |
|
42 |
|
43 AddTestCase( re + ".toString == RegExp.prototype.toString", |
|
44 true, |
|
45 re.toString == RegExp.prototype.toString ); |
|
46 |
|
47 AddTestCase( re + ".contructor == RegExp.prototype.constructor", |
|
48 true, |
|
49 re.constructor == RegExp.prototype.constructor ); |
|
50 |
|
51 AddTestCase( re + ".compile == RegExp.prototype.compile", |
|
52 true, |
|
53 re.compile == RegExp.prototype.compile ); |
|
54 |
|
55 AddTestCase( re + ".exec == RegExp.prototype.exec", |
|
56 true, |
|
57 re.exec == RegExp.prototype.exec ); |
|
58 |
|
59 // properties |
|
60 |
|
61 AddTestCase( re + ".source", |
|
62 s, |
|
63 re.source ); |
|
64 |
|
65 /* |
|
66 * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed |
|
67 * the behavior of toString() and toSource() on empty regexps. |
|
68 * So branch if |s| is the empty string - |
|
69 */ |
|
70 var S = s? s : '(?:)'; |
|
71 |
|
72 AddTestCase( re + ".toString()", |
|
73 "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), |
|
74 re.toString() ); |
|
75 |
|
76 AddTestCase( re + ".global", |
|
77 g, |
|
78 re.global ); |
|
79 |
|
80 AddTestCase( re + ".ignoreCase", |
|
81 i, |
|
82 re.ignoreCase ); |
|
83 |
|
84 AddTestCase( re + ".multiline", |
|
85 m, |
|
86 re.multiline); |
|
87 |
|
88 AddTestCase( re + ".lastIndex", |
|
89 l, |
|
90 re.lastIndex ); |
|
91 } |