| 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 | * Date: 12 Mar 2001 |
| 8 | * |
| 9 | * |
| 10 | * SUMMARY: Testing Array.prototype.toLocaleString() |
| 11 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 |
| 12 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 |
| 13 | * |
| 14 | * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() |
| 15 | * should be applied to each element of the array, and the results should be |
| 16 | * concatenated with an implementation-specific delimiter. For example: |
| 17 | * |
| 18 | * myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. |
| 19 | * |
| 20 | * In this testcase toLocaleString is a user-defined property of each |
| 21 | * array element; therefore it is the function that should be |
| 22 | * invoked. This function increments a global variable. Therefore the |
| 23 | * end value of this variable should be myArray.length. |
| 24 | */ |
| 25 | //----------------------------------------------------------------------------- |
| 26 | var gTestfile = '15.4.4.3-1.js'; |
| 27 | var BUGNUMBER = 56883; |
| 28 | var summary = 'Testing Array.prototype.toLocaleString() -'; |
| 29 | var actual = ''; |
| 30 | var expect = ''; |
| 31 | var n = 0; |
| 32 | var obj = {toLocaleString: function() {n++}}; |
| 33 | var myArray = [obj, obj, obj]; |
| 34 | |
| 35 | |
| 36 | myArray.toLocaleString(); |
| 37 | actual = n; |
| 38 | expect = 3; // (see explanation above) |
| 39 | |
| 40 | |
| 41 | //----------------------------------------------------------------------------- |
| 42 | test(); |
| 43 | //----------------------------------------------------------------------------- |
| 44 | |
| 45 | |
| 46 | function test() |
| 47 | { |
| 48 | enterFunc ('test'); |
| 49 | printBugNumber(BUGNUMBER); |
| 50 | printStatus (summary); |
| 51 | |
| 52 | reportCompare(expect, actual, summary); |
| 53 | |
| 54 | exitFunc ('test'); |
| 55 | } |