michael@0: // |reftest| fails -- bug 604301, at a minimum michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 616294; michael@0: var summary = michael@0: "|delete x| inside a function in eval code, where that eval code includes " + michael@0: "|var x| at top level, actually does delete the binding for x"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var f; michael@0: michael@0: function testOuterLet() michael@0: { michael@0: return eval("let x; (function() { return delete x; })"); michael@0: } michael@0: michael@0: f = testOuterLet(); michael@0: michael@0: assertEq(f(), true); // configurable, so remove => true michael@0: assertEq(f(), true); // not there => true (only non-configurable => false) michael@0: michael@0: michael@0: function testOuterForLet() michael@0: { michael@0: return eval("for (let x; false; ); (function() { return delete x; })"); michael@0: } michael@0: michael@0: f = testOuterForLet(); michael@0: michael@0: assertEq(f(), true); // not there => true (only non-configurable => false) michael@0: michael@0: michael@0: function testOuterForInLet() michael@0: { michael@0: return eval("for (let x in {}); (function() { return delete x; })"); michael@0: } michael@0: michael@0: f = testOuterForInLet(); michael@0: michael@0: assertEq(f(), true); // configurable, so remove => true michael@0: assertEq(f(), true); // not there => true (only non-configurable => false) michael@0: michael@0: michael@0: function testOuterNestedVarInLetBlock() michael@0: { michael@0: return eval("let (x = 7) { var x = 9; } (function() { return delete x; })"); michael@0: } michael@0: michael@0: f = testOuterNestedVarInLetBlock(); michael@0: michael@0: assertEq(f(), true); // configurable var, so remove => true michael@0: assertEq(f(), true); // let still there, configurable => true michael@0: assertEq(f(), true); // nothing at all => true michael@0: michael@0: michael@0: function testOuterNestedVarInForLet() michael@0: { michael@0: return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })"); michael@0: } michael@0: michael@0: f = testOuterNestedVarInForLet(); michael@0: michael@0: assertEq(f(), true); // configurable, so remove => true michael@0: assertEq(f(), true); // there => true michael@0: michael@0: michael@0: function testArgumentShadowLet() michael@0: { michael@0: return eval("let x; (function(x) { return delete x; })"); michael@0: } michael@0: michael@0: f = testArgumentShadowLet(); michael@0: michael@0: assertEq(f(), false); // non-configurable argument => false michael@0: michael@0: michael@0: function testFunctionLocal() michael@0: { michael@0: return eval("(function() { let x; return delete x; })"); michael@0: } michael@0: michael@0: f = testFunctionLocal(); michael@0: michael@0: assertEq(f(), false); // defined by function code => not configurable => false michael@0: michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");