Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * The with statement adds a computed object to the front of the
6 * scope chain of the current execution context
7 *
8 * @path ch12/12.10/S12.10_A1.10_T5.js
9 * @description Using iteration statement within "with" statement leading to completion by break
10 * @noStrict
11 */
13 this.p1 = 1;
14 this.p2 = 2;
15 this.p3 = 3;
16 var result = "result";
17 var myObj = {p1: 'a',
18 p2: 'b',
19 p3: 'c',
20 value: 'myObj_value',
21 valueOf : function(){return 'obj_valueOf';},
22 parseInt : function(){return 'obj_parseInt';},
23 NaN : 'obj_NaN',
24 Infinity : 'obj_Infinity',
25 eval : function(){return 'obj_eval';},
26 parseFloat : function(){return 'obj_parseFloat';},
27 isNaN : function(){return 'obj_isNaN';},
28 isFinite : function(){return 'obj_isFinite';}
29 }
30 var del;
31 var st_p1 = "p1";
32 var st_p2 = "p2";
33 var st_p3 = "p3";
34 var st_parseInt = "parseInt";
35 var st_NaN = "NaN";
36 var st_Infinity = "Infinity";
37 var st_eval = "eval";
38 var st_parseFloat = "parseFloat";
39 var st_isNaN = "isNaN";
40 var st_isFinite = "isFinite";
42 with(myObj){
43 do{
44 break;
45 st_p1 = p1;
46 st_p2 = p2;
47 st_p3 = p3;
48 st_parseInt = parseInt;
49 st_NaN = NaN;
50 st_Infinity = Infinity;
51 st_eval = eval;
52 st_parseFloat = parseFloat;
53 st_isNaN = isNaN;
54 st_isFinite = isFinite;
55 p1 = 'x1';
56 this.p2 = 'x2';
57 del = delete p3;
58 var p4 = 'x4';
59 p5 = 'x5';
60 var value = 'value';
61 }
62 while(false);
63 }
65 if(!(p1 === 1)){
66 $ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
67 }
69 if(!(p2 === 2)){
70 $ERROR('#2: p2 === 2. Actual: p2 ==='+ p2 );
71 }
73 if(!(p3 === 3)){
74 $ERROR('#3: p3 === 3. Actual: p3 ==='+ p3 );
75 }
77 if(!(p4 === undefined)){
78 $ERROR('#4: p4 === undefined. Actual: p4 ==='+ p4 );
79 }
81 try {
82 p5;
83 $ERROR('#5: p5 is not defined');
84 } catch(e) {
85 }
87 if(!(myObj.p1 === "a")){
88 $ERROR('#6: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
89 }
91 if(!(myObj.p2 === "b")){
92 $ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 );
93 }
95 if(!(myObj.p3 === "c")){
96 $ERROR('#8: myObj.p3 === "c". Actual: myObj.p3 ==='+ myObj.p3 );
97 }
99 if(!(myObj.p4 === undefined)){
100 $ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 );
101 }
103 if(!(myObj.p5 === undefined)){
104 $ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 );
105 }
107 if(!(st_parseInt === "parseInt")){
108 $ERROR('#11: myObj.parseInt === "parseInt". Actual: myObj.parseInt ==='+ myObj.parseInt );
109 }
111 if(!(st_NaN === "NaN")){
112 $ERROR('#12: st_NaN === "NaN". Actual: st_NaN ==='+ st_NaN );
113 }
115 if(!(st_Infinity === "Infinity")){
116 $ERROR('#13: st_Infinity === "Infinity". Actual: st_Infinity ==='+ st_Infinity );
117 }
119 if(!(st_eval === "eval")){
120 $ERROR('#14: st_eval === "eval". Actual: st_eval ==='+ st_eval );
121 }
123 if(!(st_parseFloat === "parseFloat")){
124 $ERROR('#15: st_parseFloat === "parseFloat". Actual: st_parseFloat ==='+ st_parseFloat );
125 }
127 if(!(st_isNaN === "isNaN")){
128 $ERROR('#16: st_isNaN === "isNaN". Actual: st_isNaN ==='+ st_isNaN );
129 }
131 if(!(st_isFinite === "isFinite")){
132 $ERROR('#17: st_isFinite === "isFinite". Actual: st_isFinite ==='+ st_isFinite );
133 }
135 if(!(value === undefined)){
136 $ERROR('#18: value === undefined. Actual: value ==='+ value );
137 }
139 if(!(myObj.value === "myObj_value")){
140 $ERROR('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value );
141 }