js/src/tests/test262/ch12/12.10/S12.10_A1.12_T2.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:a422386f8442
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 * The with statement adds a computed object to the front of the
6 * scope chain of the current execution context
7 *
8 * @path ch12/12.10/S12.10_A1.12_T2.js
9 * @description Calling a function without "with" statement declared within the statement, leading to normal completion by "return"
10 * @noStrict
11 */
12
13 this.p1 = 1;
14 this.p2 = 2;
15 this.p3 = 3;
16 var result = "result";
17 var myObj = {p1: 'a',
18 p2: 'b',
19 p3: 'c',
20 value: 'myObj_value',
21 valueOf : function(){return 'obj_valueOf';},
22 parseInt : function(){return 'obj_parseInt';},
23 NaN : 'obj_NaN',
24 Infinity : 'obj_Infinity',
25 eval : function(){return 'obj_eval';},
26 parseFloat : function(){return 'obj_parseFloat';},
27 isNaN : function(){return 'obj_isNaN';},
28 isFinite : function(){return 'obj_isFinite';}
29 }
30 var del;
31 var st_p1 = "p1";
32 var st_p2 = "p2";
33 var st_p3 = "p3";
34 var st_parseInt = "parseInt";
35 var st_NaN = "NaN";
36 var st_Infinity = "Infinity";
37 var st_eval = "eval";
38 var st_parseFloat = "parseFloat";
39 var st_isNaN = "isNaN";
40 var st_isFinite = "isFinite";
41
42 with(myObj){
43 var f = function(){
44 st_p1 = p1;
45 st_p2 = p2;
46 st_p3 = p3;
47 st_parseInt = parseInt;
48 st_NaN = NaN;
49 st_Infinity = Infinity;
50 st_eval = eval;
51 st_parseFloat = parseFloat;
52 st_isNaN = isNaN;
53 st_isFinite = isFinite;
54 p1 = 'x1';
55 this.p2 = 'x2';
56 del = delete p3;
57 var p4 = 'x4';
58 p5 = 'x5';
59 var value = 'value';
60 return value;
61 }
62 }
63 result = f();
64
65 if(!(result === "value")){
66 $ERROR('#0: result === "value". Actual: result ==='+ result );
67 }
68
69 if(!(p1 === 1)){
70 $ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
71 }
72
73 if(!(p2 === "x2")){
74 $ERROR('#2: p2 === "x2". Actual: p2 ==='+ p2 );
75 }
76
77 if(!(p3 === 3)){
78 $ERROR('#3: p3 === 3. Actual: p3 ==='+ p3 );
79 }
80
81 try{
82 p4;
83 $ERROR('#4: p4 doesn\'t exists');
84 }
85 catch(e){
86 }
87
88 if(!(p5 === "x5")){
89 $ERROR('#5: p5 === "x5". Actual: p5 ==='+ p5 );
90 }
91
92 if(!(myObj.p1 === "x1")){
93 $ERROR('#6: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 );
94 }
95
96 if(!(myObj.p2 === "b")){
97 $ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 );
98 }
99
100 if(!(myObj.p3 === undefined)){
101 $ERROR('#8: myObj.p3 === undefined. Actual: myObj.p3 ==='+ myObj.p3 );
102 }
103
104 if(!(myObj.p4 === undefined)){
105 $ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 );
106 }
107
108 if(!(myObj.p5 === undefined)){
109 $ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 );
110 }
111
112 if(!(st_parseInt !== parseInt)){
113 $ERROR('#11: myObj.parseInt !== parseInt');
114 }
115
116 if(!(st_NaN === "obj_NaN")){
117 $ERROR('#12: myObj.NaN !== NaN');
118 }
119
120 if(!(st_Infinity !== Infinity)){
121 $ERROR('#13: myObj.Infinity !== Infinity');
122 }
123
124 if(!(st_eval !== eval)){
125 $ERROR('#14: myObj.eval !== eval');
126 }
127
128 if(!(st_parseFloat !== parseFloat)){
129 $ERROR('#15: myObj.parseFloat !== parseFloat');
130 }
131
132 if(!(st_isNaN !== isNaN)){
133 $ERROR('#16: myObj.isNaN !== isNaN');
134 }
135
136 if(!(st_isFinite !== isFinite)){
137 $ERROR('#17: myObj.isFinite !== isFinite');
138 }
139
140 try{
141 value;
142 $ERROR('#18: value is not defined');
143 }
144 catch(e){
145 }
146
147 if(!(myObj.value === "myObj_value")){
148 $ERROR('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value );
149 }
150

mercurial