|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * If the property doesn't have the DontDelete attribute, remove the property |
|
6 * |
|
7 * @path ch11/11.4/11.4.1/S11.4.1_A3.3.js |
|
8 * @description Checking declared variable |
|
9 */ |
|
10 |
|
11 //CHECK#1 |
|
12 try { |
|
13 x = 1; |
|
14 delete x; |
|
15 x; |
|
16 $ERROR('#1: x = 1; delete x; x is not exist'); |
|
17 } catch (e) { |
|
18 if (e instanceof ReferenceError !== true) { |
|
19 $ERROR('#1: x = 1; delete x; x is not exist'); |
|
20 } |
|
21 } |
|
22 |
|
23 |
|
24 //CHECK#2 |
|
25 function MyFunction(){}; |
|
26 MyFunction.prop = 1; |
|
27 delete MyFunction.prop; |
|
28 if (MyFunction.prop !== undefined) { |
|
29 $ERROR('#2: function MyFunction(){}; MyFunction.prop = 1; delete MyFunction.prop; MyFunction.prop === undefined. Actual: ' + (MyFunction.prop)); |
|
30 |
|
31 } |
|
32 |
|
33 //CHECK#3 |
|
34 function MyFunction(){}; |
|
35 var MyObjectVar = new MyFunction(); |
|
36 MyObjectVar.prop = 1; |
|
37 delete MyObjectVar.prop; |
|
38 if (MyObjectVar.prop !== undefined) { |
|
39 $ERROR('#3: function MyFunction(){}; var MyObjectVar = new MyFunction(); MyFunction.prop = 1; delete MyObjectVar.prop; MyObjectVar.prop === undefined. Actual: ' + (MyObjectVar.prop)); |
|
40 } |
|
41 |
|
42 //CHECK#4 |
|
43 if (delete MyObjectVar !== false) { |
|
44 $ERROR('#4: function MyFunction(){}; var MyObjectVar = new MyFunction(); delete MyObjectVar === false'); |
|
45 } |
|
46 |
|
47 //CHECK#5 |
|
48 function MyFunction(){}; |
|
49 MyObjectNotVar = new MyFunction(); |
|
50 MyObjectNotVar.prop = 1; |
|
51 delete MyObjectNotVar.prop; |
|
52 if (MyObjectNotVar.prop !== undefined) { |
|
53 $ERROR('#5: function MyFunction(){}; MyObjectNotVar = new MyFunction(); MyFunction.prop = 1; delete MyObjectNotVar.prop; MyObjectNotVar.prop === undefined. Actual: ' + (MyObjectNotVar.prop)); |
|
54 } |
|
55 |
|
56 //CHECK#6 |
|
57 if (delete MyObjectNotVar !== true) { |
|
58 $ERROR('#6: function MyFunction(){}; var MyObjectNotVar = new MyFunction(); delete MyObjectNotVar === true'); |
|
59 } |
|
60 |
|
61 |