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