js/src/tests/ecma_5/extensions/nested-delete-name-in-evalcode.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:492d82ac13aa
1 // |reftest| fails -- bug 604301, at a minimum
2 // Any copyright is dedicated to the Public Domain.
3 // http://creativecommons.org/licenses/publicdomain/
4
5 //-----------------------------------------------------------------------------
6 var BUGNUMBER = 616294;
7 var summary =
8 "|delete x| inside a function in eval code, where that eval code includes " +
9 "|var x| at top level, actually does delete the binding for x";
10
11 print(BUGNUMBER + ": " + summary);
12
13 /**************
14 * BEGIN TEST *
15 **************/
16
17 var f;
18
19 function testOuterLet()
20 {
21 return eval("let x; (function() { return delete x; })");
22 }
23
24 f = testOuterLet();
25
26 assertEq(f(), true); // configurable, so remove => true
27 assertEq(f(), true); // not there => true (only non-configurable => false)
28
29
30 function testOuterForLet()
31 {
32 return eval("for (let x; false; ); (function() { return delete x; })");
33 }
34
35 f = testOuterForLet();
36
37 assertEq(f(), true); // not there => true (only non-configurable => false)
38
39
40 function testOuterForInLet()
41 {
42 return eval("for (let x in {}); (function() { return delete x; })");
43 }
44
45 f = testOuterForInLet();
46
47 assertEq(f(), true); // configurable, so remove => true
48 assertEq(f(), true); // not there => true (only non-configurable => false)
49
50
51 function testOuterNestedVarInLetBlock()
52 {
53 return eval("let (x = 7) { var x = 9; } (function() { return delete x; })");
54 }
55
56 f = testOuterNestedVarInLetBlock();
57
58 assertEq(f(), true); // configurable var, so remove => true
59 assertEq(f(), true); // let still there, configurable => true
60 assertEq(f(), true); // nothing at all => true
61
62
63 function testOuterNestedVarInForLet()
64 {
65 return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })");
66 }
67
68 f = testOuterNestedVarInForLet();
69
70 assertEq(f(), true); // configurable, so remove => true
71 assertEq(f(), true); // there => true
72
73
74 function testArgumentShadowLet()
75 {
76 return eval("let x; (function(x) { return delete x; })");
77 }
78
79 f = testArgumentShadowLet();
80
81 assertEq(f(), false); // non-configurable argument => false
82
83
84 function testFunctionLocal()
85 {
86 return eval("(function() { let x; return delete x; })");
87 }
88
89 f = testFunctionLocal();
90
91 assertEq(f(), false); // defined by function code => not configurable => false
92
93
94 /******************************************************************************/
95
96 if (typeof reportCompare === "function")
97 reportCompare(true, true);
98
99 print("All tests passed!");

mercurial