2 "This test checks whether various forms of delete expression are allowed."
7 shouldBeTrue('delete x');
10 shouldBeTrue('delete window.x');
13 shouldBeTrue('delete window["x"]');
16 shouldBeTrue('delete (x)');
19 shouldBeTrue('delete (window.x)');
22 shouldBeTrue('delete (window["x"])');
25 shouldBeTrue('(y, delete x)');
28 shouldBeTrue('delete ((x))');
31 shouldBeTrue('delete ((window.x))');
34 shouldBeTrue('delete ((window["x"]))');
37 shouldBeTrue('delete (y, x)');
40 shouldBeTrue('delete (true ? x : y)');
44 shouldBeTrue('delete nonexistent');
45 shouldBeTrue('delete window.nonexistent');
46 shouldBeTrue('delete window["nonexistent"]');
47 shouldBeTrue('delete (nonexistent)');
48 shouldBeTrue('delete (window.nonexistent)');
49 shouldBeTrue('delete (window["nonexistent"])');
51 shouldBeTrue('delete "x"');
52 shouldBeTrue('delete (2 + 3)');
54 var mathCos = Math.cos;
57 // Try deleting & overwriting static properties.
58 shouldBe("Math.cos", "mathCos");
59 shouldBe("Math.sin", "undefined");
60 shouldBe("Math.tan", "null");
62 var regExpPrototypeCompile = RegExp.prototype.compile;
63 RegExp.prototype.test = null;
64 Object.preventExtensions(RegExp.prototype);
65 delete RegExp.prototype.exec;
66 // Reverse order of delete & overwrite, tests delete after preventExtensions.
67 shouldBe("RegExp.prototype.compile", "regExpPrototypeCompile");
68 shouldBe("RegExp.prototype.exec", "undefined");
69 shouldBe("RegExp.prototype.test", "null");
71 // Check that once a property is deleted its name is removed from the property name array.
72 delete Object.prototype.__defineSetter__;
73 shouldBe("Object.getOwnPropertyNames(Object.prototype).indexOf('__defineSetter__')", "-1");