tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / script-tests / delete-syntax.js
1 description(
2 "This test checks whether various forms of delete expression are allowed."
3 );
4
5 window.y = 0;
6
7 shouldBeTrue('delete x');
8 window.x = 0;
9 window.y = 0;
10 shouldBeTrue('delete window.x');
11 window.x = 0;
12 window.y = 0;
13 shouldBeTrue('delete window["x"]');
14 window.x = 0;
15 window.y = 0;
16 shouldBeTrue('delete (x)');
17 window.x = 0;
18 window.y = 0;
19 shouldBeTrue('delete (window.x)');
20 window.x = 0;
21 window.y = 0;
22 shouldBeTrue('delete (window["x"])');
23 window.x = 0;
24 window.y = 0;
25 shouldBeTrue('(y, delete x)');
26 window.x = 0;
27 window.y = 0;
28 shouldBeTrue('delete ((x))');
29 window.x = 0;
30 window.y = 0;
31 shouldBeTrue('delete ((window.x))');
32 window.x = 0;
33 window.y = 0;
34 shouldBeTrue('delete ((window["x"]))');
35 window.x = 0;
36 window.y = 0;
37 shouldBeTrue('delete (y, x)');
38 window.x = 0;
39 window.y = 0;
40 shouldBeTrue('delete (true ? x : y)');
41 window.x = 0;
42 window.y = 0;
43
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"])');
50
51 shouldBeTrue('delete "x"');
52 shouldBeTrue('delete (2 + 3)');
53
54 var mathCos = Math.cos;
55 delete Math.sin;
56 Math.tan = null;
57 // Try deleting & overwriting static properties.
58 shouldBe("Math.cos", "mathCos");
59 shouldBe("Math.sin", "undefined");
60 shouldBe("Math.tan", "null");
61
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");
70
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");
74