js/src/tests/js1_2/function/regexparg-1.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:f6d5c3b97e45
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: regexparg-1.js
9 Description:
10
11 Regression test for
12 http://scopus/bugsplat/show_bug.cgi?id=122787
13 Passing a regular expression as the first constructor argument fails
14
15 Author: christine@netscape.com
16 Date: 15 June 1998
17 */
18
19 var SECTION = "JS_1.2";
20 var VERSION = "JS_1.2";
21 startTest();
22 var TITLE = "The variable statement";
23
24 writeHeaderToLog( SECTION + " "+ TITLE);
25
26 print("Note: Bug 61911 changed the behavior of typeof regexp in Gecko 1.9.");
27 print("Prior to Gecko 1.9, typeof regexp returned 'function'.");
28 print("However in Gecko 1.9 and later, typeof regexp will return 'object'.");
29
30 function f(x) {return x;}
31
32 x = f(/abc/);
33
34 new TestCase( SECTION,
35 "function f(x) {return x;}; f()",
36 void 0,
37 f() );
38
39 new TestCase( SECTION,
40 "f(\"hi\")",
41 "hi",
42 f("hi") );
43
44 new TestCase( SECTION,
45 "new f(/abc/) +''",
46 "/abc/",
47 new f(/abc/) +"" );
48
49 new TestCase( SECTION,
50 "f(/abc/)+'')",
51 "/abc/",
52 f(/abc/) +'');
53
54 new TestCase( SECTION,
55 "typeof f(/abc/)",
56 "object",
57 typeof f(/abc/) );
58
59 new TestCase( SECTION,
60 "typeof new f(/abc/)",
61 "object",
62 typeof new f(/abc/) );
63
64 new TestCase( SECTION,
65 "x = new f(/abc/); x.exec(\"hi\")",
66 null,
67 x.exec("hi") );
68
69
70 // js> x()
71 test();

mercurial