js/src/tests/test262/ch12/12.10/S12.10_A1.9_T2.js

changeset 0
6474c204b198
     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.9_T2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,139 @@
     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.9_T2.js
    1.12 + * @description Using "for-in" statement within "with" statement, leading to completion by break
    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 +with(myObj){
    1.46 +  for(var prop in myObj){
    1.47 +    st_p1 = p1;
    1.48 +    p1 = 'x1';
    1.49 +    st_p2 = p2;
    1.50 +    this.p2 = 'x2';
    1.51 +    st_p3 = p3;
    1.52 +    del = delete p3;
    1.53 +    st_parseInt = parseInt;
    1.54 +    st_NaN = NaN;
    1.55 +    st_Infinity = Infinity;
    1.56 +    st_eval = eval;
    1.57 +    st_parseFloat = parseFloat;
    1.58 +    st_isNaN = isNaN;
    1.59 +    st_isFinite = isFinite;
    1.60 +    var p4 = 'x4';
    1.61 +    p5 = 'x5';
    1.62 +    var value = 'value';
    1.63 +    break;
    1.64 +  }
    1.65 +}
    1.66 +
    1.67 +if(!(p1 === 1)){
    1.68 +  $ERROR('#1: p1 === 1. Actual:  p1 ==='+ p1  );
    1.69 +}
    1.70 +
    1.71 +if(!(p2 === "x2")){
    1.72 +  $ERROR('#2: p2 === "x2". Actual:  p2 ==='+ p2  );
    1.73 +}
    1.74 +
    1.75 +if(!(p3 === 3)){
    1.76 +  $ERROR('#3: p3 === 3. Actual:  p3 ==='+ p3  );
    1.77 +}
    1.78 +
    1.79 +if(!(p4 === "x4")){
    1.80 +  $ERROR('#4: p4 === "x4". Actual:  p4 ==='+ p4  );
    1.81 +}
    1.82 +
    1.83 +if(!(p5 === "x5")){
    1.84 +  $ERROR('#5: p5 === "x5". Actual:  p5 ==='+ p5  );
    1.85 +}
    1.86 +
    1.87 +if(!(myObj.p1 === "x1")){
    1.88 +  $ERROR('#6: myObj.p1 === "x1". Actual:  myObj.p1 ==='+ myObj.p1  );
    1.89 +}
    1.90 +
    1.91 +if(!(myObj.p2 === "b")){
    1.92 +  $ERROR('#7: myObj.p2 === "b". Actual:  myObj.p2 ==='+ myObj.p2  );
    1.93 +}
    1.94 +
    1.95 +if(!(myObj.p3 === undefined)){
    1.96 +  $ERROR('#8: myObj.p3 === undefined. Actual:  myObj.p3 ==='+ myObj.p3  );
    1.97 +}
    1.98 +
    1.99 +if(!(myObj.p4 === undefined)){
   1.100 +  $ERROR('#9: myObj.p4 === undefined. Actual:  myObj.p4 ==='+ myObj.p4  );
   1.101 +}
   1.102 +
   1.103 +if(!(myObj.p5 === undefined)){
   1.104 +  $ERROR('#10: myObj.p5 === undefined. Actual:  myObj.p5 ==='+ myObj.p5  );
   1.105 +}
   1.106 +
   1.107 +if(!(st_parseInt !== parseInt)){
   1.108 +  $ERROR('#11: myObj.parseInt !== parseInt');
   1.109 +}
   1.110 +
   1.111 +if(!(st_NaN === "obj_NaN")){
   1.112 +  $ERROR('#12: myObj.NaN !== NaN');
   1.113 +}
   1.114 +
   1.115 +if(!(st_Infinity !== Infinity)){
   1.116 +  $ERROR('#13: myObj.Infinity !== Infinity');
   1.117 +}
   1.118 +
   1.119 +if(!(st_eval !== eval)){
   1.120 +  $ERROR('#14: myObj.eval !== eval');
   1.121 +}
   1.122 +
   1.123 +if(!(st_parseFloat !== parseFloat)){
   1.124 +  $ERROR('#15: myObj.parseFloat !== parseFloat');
   1.125 +}
   1.126 +
   1.127 +if(!(st_isNaN !== isNaN)){
   1.128 +  $ERROR('#16: myObj.isNaN !== isNaN');
   1.129 +}
   1.130 +
   1.131 +if(!(st_isFinite !== isFinite)){
   1.132 +  $ERROR('#17: myObj.isFinite !== isFinite');
   1.133 +}
   1.134 +
   1.135 +if(!(value === undefined)){
   1.136 +  $ERROR('#18: value === undefined. Actual:  value ==='+ value  );
   1.137 +}
   1.138 +
   1.139 +if(!(myObj.value === "value")){
   1.140 +  $ERROR('#19: myObj.value === "value". Actual:  myObj.value ==='+ myObj.value  );
   1.141 +}
   1.142 +

mercurial