Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
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.5_T3.js
9 * @description Using "with" statement within "for-in" statement, leading to completion by exception
10 * @noStrict
11 */
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";
42 try {
43 for(var prop in myObj){
44 with(myObj){
45 throw value;
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 } catch(e){
71 result = e;
72 }
74 if(!(result === "myObj_value")){
75 $ERROR('#0: result === "myObj_value". Actual: result ==='+ result );
76 }
78 if(!(p1 === 1)){
79 $ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
80 }
82 if(!(p2 === 2)){
83 $ERROR('#2: p2 === 2. Actual: p2 ==='+ p2 );
84 }
86 if(!(p3 === 3)){
87 $ERROR('#3: p3 === 3. Actual: p3 ==='+ p3 );
88 }
90 if(!(p4 === undefined)){
91 $ERROR('#4: p4 === undefined. Actual: p4 ==='+ p4 );
92 }
94 try {
95 p5;
96 $ERROR('#5: p5 is not defined');
97 } catch(e) {
98 }
100 if(!(myObj.p1 === "a")){
101 $ERROR('#6: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
102 }
104 if(!(myObj.p2 === "b")){
105 $ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 );
106 }
108 if(!(myObj.p3 === "c")){
109 $ERROR('#8: myObj.p3 === "c". Actual: myObj.p3 ==='+ myObj.p3 );
110 }
112 if(!(myObj.p4 === undefined)){
113 $ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 );
114 }
116 if(!(myObj.p5 === undefined)){
117 $ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 );
118 }
120 if(!(st_parseInt === "parseInt")){
121 $ERROR('#11: myObj.parseInt === "parseInt". Actual: myObj.parseInt ==='+ myObj.parseInt );
122 }
124 if(!(st_NaN === "NaN")){
125 $ERROR('#12: st_NaN === "NaN". Actual: st_NaN ==='+ st_NaN );
126 }
128 if(!(st_Infinity === "Infinity")){
129 $ERROR('#13: st_Infinity === "Infinity". Actual: st_Infinity ==='+ st_Infinity );
130 }
132 if(!(st_eval === "eval")){
133 $ERROR('#14: st_eval === "eval". Actual: st_eval ==='+ st_eval );
134 }
136 if(!(st_parseFloat === "parseFloat")){
137 $ERROR('#15: st_parseFloat === "parseFloat". Actual: st_parseFloat ==='+ st_parseFloat );
138 }
140 if(!(st_isNaN === "isNaN")){
141 $ERROR('#16: st_isNaN === "isNaN". Actual: st_isNaN ==='+ st_isNaN );
142 }
144 if(!(st_isFinite === "isFinite")){
145 $ERROR('#17: st_isFinite === "isFinite". Actual: st_isFinite ==='+ st_isFinite );
146 }
148 if(!(value === undefined)){
149 $ERROR('#18: value === undefined. Actual: value ==='+ value );
150 }
152 if(!(myObj.value === "myObj_value")){
153 $ERROR('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value );
154 }