1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 ECMA Section: 11.4.1 the Delete Operator
25 Description: returns true if the property could be deleted
26 returns false if it could not be deleted
27 Author: christine@netscape.com
33 var SECTION = "11.4.1";
34 var VERSION = "ECMA_1";
36 var TITLE = "The delete operator";
38 writeHeaderToLog( SECTION + " "+ TITLE);
40 var testcases = getTestCases();
44 function getTestCases() {
45 var array = new Array();
48 // array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") );
49 // array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") );
50 array[item++] = new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") );
52 // array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) );
53 // array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") );
54 // array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) );
55 // array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) );
56 array[item++] = new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) );
57 // array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) );
58 // array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) );
60 // variables declared with the var statement are not deletable.
63 array[item++] = new TestCase( SECTION, "var abc; delete(abc)", false, delete abc );
65 array[item++] = new TestCase( SECTION,
66 "var OB = new MyObject(); for ( p in OB ) { delete p }",
68 eval("var OB = new MyObject(); for ( p in OB ) { delete p }") );
73 for ( tc = 0; tc < testcases.length; tc++ ) {
74 testcases[tc].passed = writeTestCaseResult(
77 testcases[tc].description +" = "+ testcases[tc].actual );
79 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "
93 this.prop7 = new Date();