1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * JDK-8131683: Delete fails over multiple scopes 26 * 27 * @test 28 * @run 29 */ 30 31 a = 1; 32 b = 2; 33 c = 3; 34 35 var A = 1; 36 var B = 2; 37 var C = 3; 38 function D() {} 39 40 print((function() { 41 var x; // force creation of scope 42 (function() { x; })(); 43 return delete a; 44 })()); 45 46 print((function() { 47 eval(""); 48 return delete b; 49 })()); 50 51 print((function() { 52 return eval("delete c"); 53 })()); 54 55 print((function() { 56 eval("d = 4"); 57 return eval("delete d"); 58 })()); 59 60 print(typeof a); 61 print(typeof b); 62 print(typeof c); 63 print(typeof d); 64 65 print((function() { 66 var x; // force creation of scope 67 (function() { x; })(); 68 return delete A; 69 })()); 70 71 print((function() { 72 eval(""); 73 return delete B; 74 })()); 75 76 print((function() { 77 return eval("delete C"); 78 })()); 79 80 print((function() { 81 eval(""); 82 return delete D; 83 })()); 84 85 print(typeof A); 86 print(typeof B); 87 print(typeof C); 88 print(typeof D); 89