1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.10/S12.10_A1.11_T4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,155 @@ 1.4 +// Copyright 2009 the Sputnik authors. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * The with statement adds a computed object to the front of the 1.9 + * scope chain of the current execution context 1.10 + * 1.11 + * @path ch12/12.10/S12.10_A1.11_T4.js 1.12 + * @description Calling a function within "with" statement declared without the statement, leading to completion by exception 1.13 + * @noStrict 1.14 + */ 1.15 + 1.16 +this.p1 = 1; 1.17 +this.p2 = 2; 1.18 +this.p3 = 3; 1.19 +var result = "result"; 1.20 +var myObj = {p1: 'a', 1.21 + p2: 'b', 1.22 + p3: 'c', 1.23 + value: 'myObj_value', 1.24 + valueOf : function(){return 'obj_valueOf';}, 1.25 + parseInt : function(){return 'obj_parseInt';}, 1.26 + NaN : 'obj_NaN', 1.27 + Infinity : 'obj_Infinity', 1.28 + eval : function(){return 'obj_eval';}, 1.29 + parseFloat : function(){return 'obj_parseFloat';}, 1.30 + isNaN : function(){return 'obj_isNaN';}, 1.31 + isFinite : function(){return 'obj_isFinite';} 1.32 +} 1.33 +var del; 1.34 +var st_p1 = "p1"; 1.35 +var st_p2 = "p2"; 1.36 +var st_p3 = "p3"; 1.37 +var st_parseInt = "parseInt"; 1.38 +var st_NaN = "NaN"; 1.39 +var st_Infinity = "Infinity"; 1.40 +var st_eval = "eval"; 1.41 +var st_parseFloat = "parseFloat"; 1.42 +var st_isNaN = "isNaN"; 1.43 +var st_isFinite = "isFinite"; 1.44 + 1.45 +try { 1.46 + var f = function(){ 1.47 + st_p1 = p1; 1.48 + st_p2 = p2; 1.49 + st_p3 = p3; 1.50 + st_parseInt = parseInt; 1.51 + st_NaN = NaN; 1.52 + st_Infinity = Infinity; 1.53 + st_eval = eval; 1.54 + st_parseFloat = parseFloat; 1.55 + st_isNaN = isNaN; 1.56 + st_isFinite = isFinite; 1.57 + p1 = 'x1'; 1.58 + this.p2 = 'x2'; 1.59 + del = delete p3; 1.60 + var p4 = 'x4'; 1.61 + p5 = 'x5'; 1.62 + var value = 'value'; 1.63 + throw value; 1.64 + } 1.65 + with(myObj){ 1.66 + f(); 1.67 + } 1.68 +} catch(e){ 1.69 + result = e; 1.70 +} 1.71 + 1.72 +if(!(result === "value")){ 1.73 + $ERROR('#0: result === "value". Actual: result ==='+ result ); 1.74 +} 1.75 + 1.76 +if(!(p1 === "x1")){ 1.77 + $ERROR('#1: p1 === "x1". Actual: p1 ==='+ p1 ); 1.78 +} 1.79 + 1.80 +if(!(p2 === "x2")){ 1.81 + $ERROR('#2: p2 === "x2". Actual: p2 ==='+ p2 ); 1.82 +} 1.83 + 1.84 +try{ 1.85 + p3; 1.86 + $ERROR('#3: p3 is nod defined'); 1.87 +} 1.88 +catch(e){ 1.89 +} 1.90 + 1.91 +try { 1.92 + p4; 1.93 + $ERROR('#4: p4 is not defined'); 1.94 +} catch(e) { 1.95 +} 1.96 + 1.97 +if(!(p5 === "x5")){ 1.98 + $ERROR('#5: p5 === "x5". Actual: p5 ==='+ p5 ); 1.99 +} 1.100 + 1.101 +if(!(myObj.p1 === "a")){ 1.102 + $ERROR('#6: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 ); 1.103 +} 1.104 + 1.105 +if(!(myObj.p2 === "b")){ 1.106 + $ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 ); 1.107 +} 1.108 + 1.109 +if(!(myObj.p3 === "c")){ 1.110 + $ERROR('#8: myObj.p3 === "c". Actual: myObj.p3 ==='+ myObj.p3 ); 1.111 +} 1.112 + 1.113 +if(!(myObj.p4 === undefined)){ 1.114 + $ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 ); 1.115 +} 1.116 + 1.117 +if(!(myObj.p5 === undefined)){ 1.118 + $ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 ); 1.119 +} 1.120 + 1.121 +if(!(st_parseInt === parseInt)){ 1.122 + $ERROR('#11: st_parseInt === parseInt. Actual: st_parseInt ==='+ st_parseInt ); 1.123 +} 1.124 + 1.125 +if(!isNaN(st_NaN)){ 1.126 + $ERROR('#12: st_NaN === NaN. Actual: st_NaN ==='+ st_NaN ); 1.127 +} 1.128 + 1.129 +if(!(st_Infinity === Infinity)){ 1.130 + $ERROR('#13: st_Infinity === Infinity. Actual: st_Infinity ==='+ st_Infinity ); 1.131 +} 1.132 + 1.133 +if(!(st_eval === eval)){ 1.134 + $ERROR('#14: st_eval === eval. Actual: st_eval ==='+ st_eval ); 1.135 +} 1.136 + 1.137 +if(!(st_parseFloat === parseFloat)){ 1.138 + $ERROR('#15: st_parseFloat === parseFloat. Actual: st_parseFloat ==='+ st_parseFloat ); 1.139 +} 1.140 + 1.141 +if(!(st_isNaN === isNaN)){ 1.142 + $ERROR('#16: st_isNaN === isNaN. Actual: st_isNaN ==='+ st_isNaN ); 1.143 +} 1.144 + 1.145 +if(!(st_isFinite === isFinite)){ 1.146 + $ERROR('#17: st_isFinite === isFinite. Actual: st_isFinite ==='+ st_isFinite ); 1.147 +} 1.148 + 1.149 +try { 1.150 + value; 1.151 + $ERROR('#18: value is not defined'); 1.152 +} catch(e) { 1.153 +} 1.154 + 1.155 +if(!(myObj.value === "myObj_value")){ 1.156 + $ERROR('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value ); 1.157 +} 1.158 +