1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/extensions/nested-delete-name-in-evalcode.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +// |reftest| fails -- bug 604301, at a minimum 1.5 +// Any copyright is dedicated to the Public Domain. 1.6 +// http://creativecommons.org/licenses/publicdomain/ 1.7 + 1.8 +//----------------------------------------------------------------------------- 1.9 +var BUGNUMBER = 616294; 1.10 +var summary = 1.11 + "|delete x| inside a function in eval code, where that eval code includes " + 1.12 + "|var x| at top level, actually does delete the binding for x"; 1.13 + 1.14 +print(BUGNUMBER + ": " + summary); 1.15 + 1.16 +/************** 1.17 + * BEGIN TEST * 1.18 + **************/ 1.19 + 1.20 +var f; 1.21 + 1.22 +function testOuterLet() 1.23 +{ 1.24 + return eval("let x; (function() { return delete x; })"); 1.25 +} 1.26 + 1.27 +f = testOuterLet(); 1.28 + 1.29 +assertEq(f(), true); // configurable, so remove => true 1.30 +assertEq(f(), true); // not there => true (only non-configurable => false) 1.31 + 1.32 + 1.33 +function testOuterForLet() 1.34 +{ 1.35 + return eval("for (let x; false; ); (function() { return delete x; })"); 1.36 +} 1.37 + 1.38 +f = testOuterForLet(); 1.39 + 1.40 +assertEq(f(), true); // not there => true (only non-configurable => false) 1.41 + 1.42 + 1.43 +function testOuterForInLet() 1.44 +{ 1.45 + return eval("for (let x in {}); (function() { return delete x; })"); 1.46 +} 1.47 + 1.48 +f = testOuterForInLet(); 1.49 + 1.50 +assertEq(f(), true); // configurable, so remove => true 1.51 +assertEq(f(), true); // not there => true (only non-configurable => false) 1.52 + 1.53 + 1.54 +function testOuterNestedVarInLetBlock() 1.55 +{ 1.56 + return eval("let (x = 7) { var x = 9; } (function() { return delete x; })"); 1.57 +} 1.58 + 1.59 +f = testOuterNestedVarInLetBlock(); 1.60 + 1.61 +assertEq(f(), true); // configurable var, so remove => true 1.62 +assertEq(f(), true); // let still there, configurable => true 1.63 +assertEq(f(), true); // nothing at all => true 1.64 + 1.65 + 1.66 +function testOuterNestedVarInForLet() 1.67 +{ 1.68 + return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })"); 1.69 +} 1.70 + 1.71 +f = testOuterNestedVarInForLet(); 1.72 + 1.73 +assertEq(f(), true); // configurable, so remove => true 1.74 +assertEq(f(), true); // there => true 1.75 + 1.76 + 1.77 +function testArgumentShadowLet() 1.78 +{ 1.79 + return eval("let x; (function(x) { return delete x; })"); 1.80 +} 1.81 + 1.82 +f = testArgumentShadowLet(); 1.83 + 1.84 +assertEq(f(), false); // non-configurable argument => false 1.85 + 1.86 + 1.87 +function testFunctionLocal() 1.88 +{ 1.89 + return eval("(function() { let x; return delete x; })"); 1.90 +} 1.91 + 1.92 +f = testFunctionLocal(); 1.93 + 1.94 +assertEq(f(), false); // defined by function code => not configurable => false 1.95 + 1.96 + 1.97 +/******************************************************************************/ 1.98 + 1.99 +if (typeof reportCompare === "function") 1.100 + reportCompare(true, true); 1.101 + 1.102 +print("All tests passed!");