1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Array/15.4.4.3-1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * Date: 12 Mar 2001 1.11 + * 1.12 + * 1.13 + * SUMMARY: Testing Array.prototype.toLocaleString() 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 1.15 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 1.16 + * 1.17 + * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() 1.18 + * should be applied to each element of the array, and the results should be 1.19 + * concatenated with an implementation-specific delimiter. For example: 1.20 + * 1.21 + * myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. 1.22 + * 1.23 + * In this testcase toLocaleString is a user-defined property of each 1.24 + * array element; therefore it is the function that should be 1.25 + * invoked. This function increments a global variable. Therefore the 1.26 + * end value of this variable should be myArray.length. 1.27 + */ 1.28 +//----------------------------------------------------------------------------- 1.29 +var BUGNUMBER = 56883; 1.30 +var summary = 'Testing Array.prototype.toLocaleString() -'; 1.31 +var actual = ''; 1.32 +var expect = ''; 1.33 +var n = 0; 1.34 +var obj = {toLocaleString: function() {n++}}; 1.35 +var myArray = [obj, obj, obj]; 1.36 + 1.37 + 1.38 +myArray.toLocaleString(); 1.39 +actual = n; 1.40 +expect = 3; // (see explanation above) 1.41 + 1.42 + 1.43 +//----------------------------------------------------------------------------- 1.44 +test(); 1.45 +//----------------------------------------------------------------------------- 1.46 + 1.47 + 1.48 +function test() 1.49 +{ 1.50 + enterFunc ('test'); 1.51 + printBugNumber(BUGNUMBER); 1.52 + printStatus (summary); 1.53 + 1.54 + reportCompare(expect, actual, summary); 1.55 + 1.56 + exitFunc ('test'); 1.57 +}