initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma_3 / Array / 15.4.4.3-1.js
1 /*
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
6 *
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
11 *
12 * The Original Code is mozilla.org code.
13 *
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation.  Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
18 *
19 * Contributor(s): pschwartau@netscape.com  
20 * Date: 12 Mar 2001
21 *
22 *
23 * SUMMARY: Testing Array.prototype.toLocaleString()
24 * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883
25 * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031
26 *
27 * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString()
28 * should be applied to each element of the array, and the results should be
29 * concatenated with an implementation-specific delimiter. For example:
30 *
31 *  myArray[0].toLocaleString()  +  ','  +  myArray[1].toLocaleString()  +  etc.
32 *
33 * In this testcase toLocaleString is a user-defined property of each array element;
34 * therefore it is the function that should be invoked. This function increments a
35 * global variable. Therefore the end value of this variable should be myArray.length.
36 */
37 //-------------------------------------------------------------------------------------------------
38 var bug = 56883;
39 var summary = 'Testing Array.prototype.toLocaleString() -';
40 var actual = '';
41 var expect = '';
42 var n = 0;
43 var obj = {toLocaleString: function() {n++}};
44 var myArray = [obj, obj, obj];
45
46
47 myArray.toLocaleString();
48 actual = n;
49 expect = 3; // (see explanation above)
50
51
52 //-------------------------------------------------------------------------------------------------
53 test();
54 //-------------------------------------------------------------------------------------------------
55
56
57 function test()
58 {
59   enterFunc ('test');
60   printBugNumber (bug);
61   printStatus (summary);
62   
63   reportCompare(expect, actual, summary);
64
65   exitFunc ('test');
66 }