1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Operators/11.13.1-001.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 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 + * 1.11 + * Date: 08 May 2003 1.12 + * SUMMARY: JS should evaluate RHS before binding LHS implicit variable 1.13 + * 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=204919 1.15 + * 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var UBound = 0; 1.19 +var BUGNUMBER = 204919; 1.20 +var summary = 'JS should evaluate RHS before binding LHS implicit variable'; 1.21 +var TEST_PASSED = 'ReferenceError'; 1.22 +var TEST_FAILED = 'Generated an error, but NOT a ReferenceError!'; 1.23 +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; 1.24 +var status = ''; 1.25 +var statusitems = []; 1.26 +var actual = ''; 1.27 +var actualvalues = []; 1.28 +var expect= ''; 1.29 +var expectedvalues = []; 1.30 + 1.31 + 1.32 +/* 1.33 + * global scope - 1.34 + */ 1.35 +status = inSection(1); 1.36 +try 1.37 +{ 1.38 + x = x; 1.39 + actual = TEST_FAILED_BADLY; 1.40 +} 1.41 +catch(e) 1.42 +{ 1.43 + if (e instanceof ReferenceError) 1.44 + actual = TEST_PASSED; 1.45 + else 1.46 + actual = TEST_FAILED; 1.47 +} 1.48 +expect = TEST_PASSED; 1.49 +addThis(); 1.50 + 1.51 + 1.52 +/* 1.53 + * function scope - 1.54 + */ 1.55 +status = inSection(2); 1.56 +try 1.57 +{ 1.58 + (function() {y = y;})(); 1.59 + actual = TEST_FAILED_BADLY; 1.60 +} 1.61 +catch(e) 1.62 +{ 1.63 + if (e instanceof ReferenceError) 1.64 + actual = TEST_PASSED; 1.65 + else 1.66 + actual = TEST_FAILED; 1.67 +} 1.68 +expect = TEST_PASSED; 1.69 +addThis(); 1.70 + 1.71 + 1.72 +/* 1.73 + * eval scope - 1.74 + */ 1.75 +status = inSection(3); 1.76 +try 1.77 +{ 1.78 + eval('z = z'); 1.79 + actual = TEST_FAILED_BADLY; 1.80 +} 1.81 +catch(e) 1.82 +{ 1.83 + if (e instanceof ReferenceError) 1.84 + actual = TEST_PASSED; 1.85 + else 1.86 + actual = TEST_FAILED; 1.87 +} 1.88 +expect = TEST_PASSED; 1.89 +addThis(); 1.90 + 1.91 + 1.92 + 1.93 + 1.94 +//----------------------------------------------------------------------------- 1.95 +test(); 1.96 +//----------------------------------------------------------------------------- 1.97 + 1.98 + 1.99 + 1.100 +function addThis() 1.101 +{ 1.102 + statusitems[UBound] = status; 1.103 + actualvalues[UBound] = actual; 1.104 + expectedvalues[UBound] = expect; 1.105 + UBound++; 1.106 +} 1.107 + 1.108 + 1.109 +function test() 1.110 +{ 1.111 + enterFunc('test'); 1.112 + printBugNumber(BUGNUMBER); 1.113 + printStatus(summary); 1.114 + 1.115 + for (var i=0; i<UBound; i++) 1.116 + { 1.117 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.118 + } 1.119 + 1.120 + exitFunc ('test'); 1.121 +}