S12.10_A1.7_T5.js (4080B)
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.7_T5 9 description: > 10 Calling a function within "with" statement declared within the 11 statement, leading to completion by exception 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 try { 45 with(myObj){ 46 var f = function(){ 47 throw 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 f(); 66 } 67 } catch(e){ 68 result = e; 69 } 70 71 if(!(result === undefined)){ 72 throw new Test262Error('#0: result === undefined. Actual: result ==='+ result ); 73 } 74 75 if(!(p1 === 1)){ 76 throw new Test262Error('#1: p1 === 1. Actual: p1 ==='+ p1 ); 77 } 78 79 if(!(p2 === 2)){ 80 throw new Test262Error('#2: p2 === 2. Actual: p2 ==='+ p2 ); 81 } 82 83 if(!(p3 === 3)){ 84 throw new Test262Error('#3: p3 === 3. Actual: p3 ==='+ p3 ); 85 } 86 87 try { 88 p4; 89 throw new Test262Error('#4: p4 is not defined'); 90 } catch(e) { 91 } 92 93 try { 94 p5; 95 throw new Test262Error('#5: p5 is not defined'); 96 } catch(e) { 97 } 98 99 if(!(myObj.p1 === "a")){ 100 throw new Test262Error('#6: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 ); 101 } 102 103 if(!(myObj.p2 === "b")){ 104 throw new Test262Error('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 ); 105 } 106 107 if(!(myObj.p3 === "c")){ 108 throw new Test262Error('#8: myObj.p3 === "c". Actual: myObj.p3 ==='+ myObj.p3 ); 109 } 110 111 if(!(myObj.p4 === undefined)){ 112 throw new Test262Error('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 ); 113 } 114 115 if(!(myObj.p5 === undefined)){ 116 throw new Test262Error('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 ); 117 } 118 119 if(!(st_parseInt === "parseInt")){ 120 throw new Test262Error('#11: myObj.parseInt === "parseInt". Actual: myObj.parseInt ==='+ myObj.parseInt ); 121 } 122 123 if(!(st_NaN === "NaN")){ 124 throw new Test262Error('#12: st_NaN === "NaN". Actual: st_NaN ==='+ st_NaN ); 125 } 126 127 if(!(st_Infinity === "Infinity")){ 128 throw new Test262Error('#13: st_Infinity === "Infinity". Actual: st_Infinity ==='+ st_Infinity ); 129 } 130 131 if(!(st_eval === "eval")){ 132 throw new Test262Error('#14: st_eval === "eval". Actual: st_eval ==='+ st_eval ); 133 } 134 135 if(!(st_parseFloat === "parseFloat")){ 136 throw new Test262Error('#15: st_parseFloat === "parseFloat". Actual: st_parseFloat ==='+ st_parseFloat ); 137 } 138 139 if(!(st_isNaN === "isNaN")){ 140 throw new Test262Error('#16: st_isNaN === "isNaN". Actual: st_isNaN ==='+ st_isNaN ); 141 } 142 143 if(!(st_isFinite === "isFinite")){ 144 throw new Test262Error('#17: st_isFinite === "isFinite". Actual: st_isFinite ==='+ st_isFinite ); 145 } 146 147 try{ 148 value; 149 throw new Test262Error('#18: value is not defined'); 150 } 151 catch(e){ 152 } 153 154 if(!(myObj.value === "myObj_value")){ 155 throw new Test262Error('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value ); 156 } 157 158 reportCompare(0, 0);