| 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_T2 |
| 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 |
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 |
return value; |
| 64 |
} |
| 65 |
} |
| 66 |
result = f(); |
| 67 |
|
| 68 |
if(!(result === "value")){ |
| 69 |
throw new Test262Error('#0: result === "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 === "x2")){ |
| 77 |
throw new Test262Error('#2: p2 === "x2". 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 |
if(!(p5 === "x5")){ |
| 91 |
throw new Test262Error('#5: p5 === "x5". Actual: p5 ==='+ p5 ); |
| 92 |
} |
| 93 |
|
| 94 |
if(!(myObj.p1 === "x1")){ |
| 95 |
throw new Test262Error('#6: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 ); |
| 96 |
} |
| 97 |
|
| 98 |
if(!(myObj.p2 === "b")){ |
| 99 |
throw new Test262Error('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 ); |
| 100 |
} |
| 101 |
|
| 102 |
if(!(myObj.p3 === undefined)){ |
| 103 |
throw new Test262Error('#8: myObj.p3 === undefined. Actual: myObj.p3 ==='+ myObj.p3 ); |
| 104 |
} |
| 105 |
|
| 106 |
if(!(myObj.p4 === undefined)){ |
| 107 |
throw new Test262Error('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 ); |
| 108 |
} |
| 109 |
|
| 110 |
if(!(myObj.p5 === undefined)){ |
| 111 |
throw new Test262Error('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 ); |
| 112 |
} |
| 113 |
|
| 114 |
if(!(st_parseInt !== parseInt)){ |
| 115 |
throw new Test262Error('#11: myObj.parseInt !== parseInt'); |
| 116 |
} |
| 117 |
|
| 118 |
if(!(st_NaN === "obj_NaN")){ |
| 119 |
throw new Test262Error('#12: myObj.NaN !== NaN'); |
| 120 |
} |
| 121 |
|
| 122 |
if(!(st_Infinity !== Infinity)){ |
| 123 |
throw new Test262Error('#13: myObj.Infinity !== Infinity'); |
| 124 |
} |
| 125 |
|
| 126 |
if(!(st_eval !== eval)){ |
| 127 |
throw new Test262Error('#14: myObj.eval !== eval'); |
| 128 |
} |
| 129 |
|
| 130 |
if(!(st_parseFloat !== parseFloat)){ |
| 131 |
throw new Test262Error('#15: myObj.parseFloat !== parseFloat'); |
| 132 |
} |
| 133 |
|
| 134 |
if(!(st_isNaN !== isNaN)){ |
| 135 |
throw new Test262Error('#16: myObj.isNaN !== isNaN'); |
| 136 |
} |
| 137 |
|
| 138 |
if(!(st_isFinite !== isFinite)){ |
| 139 |
throw new Test262Error('#17: myObj.isFinite !== isFinite'); |
| 140 |
} |
| 141 |
|
| 142 |
try{ |
| 143 |
value; |
| 144 |
throw new Test262Error('#18: value is not defined'); |
| 145 |
} |
| 146 |
catch(e){ |
| 147 |
} |
| 148 |
|
| 149 |
if(!(myObj.value === "value")){ |
| 150 |
throw new Test262Error('#19: myObj.value === "value". Actual: myObj.value ==='+ myObj.value ); |
| 151 |
} |
| 152 |
|
| 153 |
reportCompare(0, 0); |