js/src/tests/ecma_3/extensions/10.1.3-2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     6 /*
     7  *
     8  * Date:    11 Feb 2002
     9  * SUMMARY: Testing functions having duplicate formal parameter names
    10  *
    11  * SpiderMonkey was crashing on each case below if the parameters had
    12  * the same name. But duplicate parameter names are permitted by ECMA;
    13  * see ECMA-262 3rd Edition Final Section 10.1.3
    14  *
    15  * NOTE: Rhino does not have toSource() and uneval(); they are non-ECMA
    16  * extensions to the language. So we include a test for them at the beginning -
    17  */
    18 //-----------------------------------------------------------------------------
    19 var UBound = 0;
    20 var BUGNUMBER = '(none)';
    21 var summary = 'Testing functions having duplicate formal parameter names';
    22 var status = '';
    23 var statusitems = [];
    24 var actual = '';
    25 var actualvalues = [];
    26 var expect= '';
    27 var expectedvalues = [];
    28 var OBJ = new Object();
    29 var OBJ_TYPE = OBJ.toString();
    31 /*
    32  * Exit if the implementation doesn't support toSource() or uneval(),
    33  * since these are non-ECMA extensions to the language -
    34  */
    35 try
    36 {
    37   if (!OBJ.toSource || !uneval(OBJ))
    38     quit();
    39 }
    40 catch(e)
    41 {
    42   quit();
    43 }
    46 /*
    47  * OK, now begin the test. Just checking that we don't crash on these -
    48  */
    49 function f1(x,x,x,x)
    50 {
    51   var ret = eval(arguments.toSource());
    52   return ret.toString();
    53 }
    54 status = inSection(1);
    55 actual = f1(1,2,3,4);
    56 expect = OBJ_TYPE;
    57 addThis();
    60 /*
    61  * Same thing, but preface |arguments| with the function name
    62  */
    63 function f2(x,x,x,x)
    64 {
    65   var ret = eval(f2.arguments.toSource());
    66   return ret.toString();
    67 }
    68 status = inSection(2);
    69 actual = f2(1,2,3,4);
    70 expect = OBJ_TYPE;
    71 addThis();
    74 function f3(x,x,x,x)
    75 {
    76   var ret = eval(uneval(arguments));
    77   return ret.toString();
    78 }
    79 status = inSection(3);
    80 actual = f3(1,2,3,4);
    81 expect = OBJ_TYPE;
    82 addThis();
    85 /*
    86  * Same thing, but preface |arguments| with the function name
    87  */
    88 function f4(x,x,x,x)
    89 {
    90   var ret = eval(uneval(f4.arguments));
    91   return ret.toString();
    92 }
    93 status = inSection(4);
    94 actual = f4(1,2,3,4);
    95 expect = OBJ_TYPE;
    96 addThis();
   101 //-----------------------------------------------------------------------------
   102 test();
   103 //-----------------------------------------------------------------------------
   107 function addThis()
   108 {
   109   statusitems[UBound] = status;
   110   actualvalues[UBound] = actual;
   111   expectedvalues[UBound] = expect;
   112   UBound++;
   113 }
   116 function test()
   117 {
   118   enterFunc('test');
   119   printBugNumber(BUGNUMBER);
   120   printStatus(summary);
   122   for (var i=0; i<UBound; i++)
   123   {
   124     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   125   }
   127   exitFunc ('test');
   128 }

mercurial