michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 11.4.1.js michael@0: ECMA Section: 11.4.1 the Delete Operator michael@0: Description: returns true if the property could be deleted michael@0: returns false if it could not be deleted michael@0: Author: christine@netscape.com michael@0: Date: 7 july 1997 michael@0: michael@0: */ michael@0: michael@0: michael@0: var SECTION = "11.4.1"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "The delete operator"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: // new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); michael@0: // new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); michael@0: new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); michael@0: michael@0: // array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) ); michael@0: // array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") ); michael@0: // array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) ); michael@0: // array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) ); michael@0: new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); michael@0: // array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) ); michael@0: // array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) ); michael@0: michael@0: // variables declared with the var statement are not deletable. michael@0: michael@0: var abc; michael@0: new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); michael@0: michael@0: new TestCase( SECTION, michael@0: "var OB = new MyObject(); for ( p in OB ) { delete p }", michael@0: true, michael@0: eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); michael@0: michael@0: test(); michael@0: michael@0: function MyObject() { michael@0: this.prop1 = true; michael@0: this.prop2 = false; michael@0: this.prop3 = null; michael@0: this.prop4 = void 0; michael@0: this.prop5 = "hi"; michael@0: this.prop6 = 42; michael@0: this.prop7 = new Date(); michael@0: this.prop8 = Math.PI; michael@0: }