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