NASHORN-172.js revision 877:cf4d2252d444
1122592Ssam/* 2122592Ssam * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3122592Ssam * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4122592Ssam * 5122592Ssam * This code is free software; you can redistribute it and/or modify it 6122592Ssam * under the terms of the GNU General Public License version 2 only, as 7122592Ssam * published by the Free Software Foundation. 8122592Ssam * 9122592Ssam * This code is distributed in the hope that it will be useful, but WITHOUT 10122592Ssam * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11122592Ssam * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12122592Ssam * version 2 for more details (a copy is included in the LICENSE file that 13122592Ssam * accompanied this code). 14122592Ssam * 15122592Ssam * You should have received a copy of the GNU General Public License version 16122592Ssam * 2 along with this work; if not, write to the Free Software Foundation, 17122592Ssam * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18122592Ssam * 19122592Ssam * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20122592Ssam * or visit www.oracle.com if you need additional information or have any 21122592Ssam * questions. 22122592Ssam */ 23122592Ssam 24122592Ssam/** 25122592Ssam * NASHORN-172 : delete of undeclared global variable returns false. 26122592Ssam * 27122592Ssam * @test 28122592Ssam * @run 29122592Ssam */ 30122592Ssam 31122592Ssamif (delete x !== true) { 32122592Ssam fail('#1: delete x === true'); 33122592Ssam} 34122592Ssam 35122592Ssamif (delete this.x !== true) { 36122592Ssam fail('#2: delete this.x === true'); 37122592Ssam} 38122592Ssam 39122592Ssamvar y = 23; 40122592Ssamif (delete y != false) { 41122592Ssam fail('#3: can delete declared var y'); 42122592Ssam} 43122592Ssam 44122592Ssamif (delete this.y != false) { 45122592Ssam fail('#4: can delete declared var using this.y'); 46122592Ssam} 47122592Ssam 48122592Ssamfoo = 'hello'; 49122592Ssamif (delete foo != true) { 50122592Ssam fail('#5: can not delete "foo"'); 51122592Ssam} 52122592Ssam 53122592Ssamif (typeof foo != 'undefined') { 54122592Ssam fail('#6: huh? "foo" is not undefined'); 55122592Ssam} 56122629Ssam