|
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 * Deleting property using "eval" statement containing "with" statement |
|
6 * |
|
7 * @path ch12/12.10/S12.10_A5_T6.js |
|
8 * @description Deleting function property |
|
9 * @noStrict |
|
10 */ |
|
11 |
|
12 this.p1 = 'a'; |
|
13 var myObj = { |
|
14 p1: function(){return 0;}, |
|
15 del:false |
|
16 } |
|
17 eval("with(myObj){del = delete p1}"); |
|
18 |
|
19 ////////////////////////////////////////////////////////////////////////////// |
|
20 //CHECK#1 |
|
21 try{ |
|
22 if(myObj.p1() === 0){ |
|
23 $ERROR('#1: myObj.p1() !== 0 '); |
|
24 } |
|
25 }catch(e){var x=1}; |
|
26 if(x !== 1){ |
|
27 $ERROR('#1: x === 1. Actual: x ==='+ x ); |
|
28 } |
|
29 // |
|
30 ////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
32 ////////////////////////////////////////////////////////////////////////////// |
|
33 //CHECK#2 |
|
34 if(myObj.p1 !== undefined){ |
|
35 $ERROR('#2: myObj.p1 === undefined . Actual: myObj.p1 ==='+ myObj.p1 ); |
|
36 } |
|
37 // |
|
38 ////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
40 ////////////////////////////////////////////////////////////////////////////// |
|
41 //CHECK#3 |
|
42 if(myObj.del !== true){ |
|
43 $ERROR('#3: myObj.del === true . Actual: myObj.del ==='+ myObj.del ); |
|
44 } |
|
45 // |
|
46 ////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
48 ////////////////////////////////////////////////////////////////////////////// |
|
49 //CHECK#4 |
|
50 if(myObj.p1 === 'a'){ |
|
51 $ERROR('#4: myObj.p1 !== \'a\''); |
|
52 } |
|
53 // |
|
54 ////////////////////////////////////////////////////////////////////////////// |
|
55 |