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