michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * michael@0: * Date: 11 Feb 2002 michael@0: * SUMMARY: Testing functions having duplicate formal parameter names michael@0: * michael@0: * Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. michael@0: * See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation michael@0: * michael@0: * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var UBound = 0; michael@0: var BUGNUMBER = 124900; michael@0: var summary = 'Testing functions having duplicate formal parameter names'; michael@0: var status = ''; michael@0: var statusitems = []; michael@0: var actual = ''; michael@0: var actualvalues = []; michael@0: var expect= ''; michael@0: var expectedvalues = []; michael@0: michael@0: michael@0: function f1(x,x) michael@0: { michael@0: return x; michael@0: } michael@0: status = inSection(1); michael@0: actual = f1(1,2); michael@0: expect = 2; michael@0: addThis(); michael@0: michael@0: michael@0: function f2(x,x,x) michael@0: { michael@0: return x*x*x; michael@0: } michael@0: status = inSection(2); michael@0: actual = f2(1,2,3); michael@0: expect = 27; michael@0: addThis(); michael@0: michael@0: michael@0: function f3(x,x,x,x) michael@0: { michael@0: return 'a' + x + 'b' + x + 'c' + x ; michael@0: } michael@0: status = inSection(3); michael@0: actual = f3(1,2,3,4); michael@0: expect = 'a4b4c4'; michael@0: addThis(); michael@0: michael@0: michael@0: /* michael@0: * If the value of the last duplicate parameter is not provided by michael@0: * the function caller, the value of this parameter is undefined michael@0: */ michael@0: function f4(x,a,b,x,z) michael@0: { michael@0: return x; michael@0: } michael@0: status = inSection(4); michael@0: actual = f4(1,2); michael@0: expect = undefined; michael@0: addThis(); michael@0: michael@0: michael@0: /* michael@0: * f.toString() should preserve any duplicate formal parameter names that exist michael@0: */ michael@0: function f5(x,x,x,x) michael@0: { michael@0: } michael@0: status = inSection(5); michael@0: actual = f5.toString().match(/\((.*)\)/)[1]; michael@0: actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space michael@0: expect = 'x,x,x,x'; michael@0: addThis(); michael@0: michael@0: michael@0: function f6(x,x,x,x) michael@0: { michael@0: var ret = []; michael@0: michael@0: for (var i=0; i