Debian Codegraph @

js/src/tests/test262/language/statements/with/S12.10_A1.9_T1.js

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