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