initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / js1_2 / regexp / RegExp_multiline_as_array.js
1 /* The contents of this file are subject to the Netscape Public
2  * License Version 1.1 (the "License"); you may not use this file
3  * except in compliance with the License. You may obtain a copy of
4  * the License at http://www.mozilla.org/NPL/
5  *
6  * Software distributed under the License is distributed on an "AS
7  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8  * implied. See the License for the specific language governing
9  * rights and limitations under the License.
10  *
11  * The Original Code is Mozilla Communicator client code, released March
12  * 31, 1998.
13  *
14  * The Initial Developer of the Original Code is Netscape Communications
15  * Corporation. Portions created by Netscape are
16  * Copyright (C) 1998 Netscape Communications Corporation. All
17  * Rights Reserved.
18  *
19  * Contributor(s): 
20  * 
21  */
22 /**
23         Filename:     RegExp_multiline_as_array.js
24         Description:  'Tests RegExps $* property  (same tests as RegExp_multiline.js but using $*)'
25
26         Author:       Nick Lerissa
27         Date:         March 13, 1998
28 */
29
30         var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
31         var VERSION = 'no version';
32     startTest();
33         var TITLE   = 'RegExp: $*';
34
35         writeHeaderToLog('Executing script: RegExp_multiline_as_array.js');
36         writeHeaderToLog( SECTION + " "+ TITLE);
37
38         var count = 0;
39         var testcases = new Array();
40
41     // First we do a series of tests with RegExp['$*'] set to false (default value)
42     // Following this we do the same tests with RegExp['$*'] set true(**).
43     // RegExp['$*']
44         testcases[count++] = new TestCase ( SECTION, "RegExp['$*']",
45                                             false, RegExp['$*']);
46
47     // (['$*'] == false) '123\n456'.match(/^4../)
48         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)",
49                                             null, '123\n456'.match(/^4../));
50
51     // (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g)
52         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)",
53                                             String(['a11']), String('a11\na22\na23\na24'.match(/^a../g)));
54
55     // (['$*'] == false) 'a11\na22'.match(/^.+^./)
56         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)",
57                                             null, 'a11\na22'.match(/^.+^./));
58
59     // (['$*'] == false) '123\n456'.match(/.3$/)
60         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)",
61                                             null, '123\n456'.match(/.3$/));
62
63     // (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g)
64         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
65                                             String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
66
67     // (['$*'] == false) 'abc\ndef'.match(/c$...$/)
68         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)",
69                                             null, 'abc\ndef'.match(/c$...$/));
70
71     // (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
72         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
73                                             String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
74
75     // (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))
76         testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))",
77                                             null, 'abc\ndef'.match(new RegExp('c$...$')));
78
79     // **Now we do the tests with RegExp['$*'] set to true
80     // RegExp['$*'] = true; RegExp['$*']
81     RegExp['$*'] = true;
82         testcases[count++] = new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']",
83                                             true, RegExp['$*']);
84
85     // (['$*'] == true) '123\n456'.match(/^4../)
86         testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)",
87                                             String(['456']), String('123\n456'.match(/^4../)));
88
89     // (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g)
90         testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)",
91                                             String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g)));
92
93     // (['$*'] == true) 'a11\na22'.match(/^.+^./)
94         //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)",
95         //                                    String(['a11\na']), String('a11\na22'.match(/^.+^./)));
96
97     // (['$*'] == true) '123\n456'.match(/.3$/)
98         testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)",
99                                             String(['23']), String('123\n456'.match(/.3$/)));
100
101     // (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g)
102         testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)",
103                                             String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g)));
104
105     // (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g'))
106         testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))",
107                                             String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g'))));
108
109     // (['$*'] == true) 'abc\ndef'.match(/c$....$/)
110         //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)",
111         //                                    'c\ndef', String('abc\ndef'.match(/c$.+$/)));
112
113         RegExp['$*'] = false;
114
115         function test()
116         {
117            for ( tc=0; tc < testcases.length; tc++ ) {
118                 testcases[tc].passed = writeTestCaseResult(
119                 testcases[tc].expect,
120                 testcases[tc].actual,
121                 testcases[tc].description +" = "+
122                 testcases[tc].actual );
123                 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
124            }
125            stopTest();
126            return ( testcases );
127         }
128
129         test();