js/src/tests/ecma_3/Operators/11.13.1-001.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:    08 May 2003
     9  * SUMMARY: JS should evaluate RHS before binding LHS implicit variable
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=204919
    12  *
    13  */
    14 //-----------------------------------------------------------------------------
    15 var UBound = 0;
    16 var BUGNUMBER = 204919;
    17 var summary = 'JS should evaluate RHS before binding LHS implicit variable';
    18 var TEST_PASSED = 'ReferenceError';
    19 var TEST_FAILED = 'Generated an error, but NOT a ReferenceError!';
    20 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
    21 var status = '';
    22 var statusitems = [];
    23 var actual = '';
    24 var actualvalues = [];
    25 var expect= '';
    26 var expectedvalues = [];
    29 /*
    30  * global scope -
    31  */
    32 status = inSection(1);
    33 try
    34 {
    35   x = x;
    36   actual = TEST_FAILED_BADLY;
    37 }
    38 catch(e)
    39 {
    40   if (e instanceof ReferenceError)
    41     actual = TEST_PASSED;
    42   else
    43     actual = TEST_FAILED;
    44 }
    45 expect = TEST_PASSED;
    46 addThis();
    49 /*
    50  * function scope -
    51  */
    52 status = inSection(2);
    53 try
    54 {
    55   (function() {y = y;})();
    56   actual = TEST_FAILED_BADLY;
    57 }
    58 catch(e)
    59 {
    60   if (e instanceof ReferenceError)
    61     actual = TEST_PASSED;
    62   else
    63     actual = TEST_FAILED;
    64 }
    65 expect = TEST_PASSED;
    66 addThis();
    69 /*
    70  * eval scope -
    71  */
    72 status = inSection(3);
    73 try
    74 {
    75   eval('z = z');
    76   actual = TEST_FAILED_BADLY;
    77 }
    78 catch(e)
    79 {
    80   if (e instanceof ReferenceError)
    81     actual = TEST_PASSED;
    82   else
    83     actual = TEST_FAILED;
    84 }
    85 expect = TEST_PASSED;
    86 addThis();
    91 //-----------------------------------------------------------------------------
    92 test();
    93 //-----------------------------------------------------------------------------
    97 function addThis()
    98 {
    99   statusitems[UBound] = status;
   100   actualvalues[UBound] = actual;
   101   expectedvalues[UBound] = expect;
   102   UBound++;
   103 }
   106 function test()
   107 {
   108   enterFunc('test');
   109   printBugNumber(BUGNUMBER);
   110   printStatus(summary);
   112   for (var i=0; i<UBound; i++)
   113   {
   114     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   115   }
   117   exitFunc ('test');
   118 }

mercurial