js/src/tests/test262/ch12/12.10/S12.10_A1.8_T4.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     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.8_T4.js
     9  * @description Declaring function constructor within "with" statement, leading to completion by exception
    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 try {
    43   with(myObj){
    44     var f = function(){
    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       throw value;
    62     }
    63     var obj = new f();
    64   }
    65 } catch(e){
    66   result = e;
    67 }
    69 if(!(result === "value")){
    70   $ERROR('#0: result === "value". Actual:  result ==='+ result  );
    71 }
    73 if(!(p1 === 1)){
    74   $ERROR('#1: p1 === 1. Actual:  p1 ==='+ p1  );
    75 }
    77 if(!(p2 === 2)){
    78   $ERROR('#2: p2 === 2. Actual:  p2 ==='+ p2  );
    79 }
    81 if(!(p3 === 3)){
    82   $ERROR('#3: p3 === 3. Actual:  p3 ==='+ p3  );
    83 }
    84 try {
    85   p4;
    86   $ERROR('#4: p4 is not defined');
    87 } catch(e) {    
    88 }
    90 if(!(p5 === "x5")){
    91   $ERROR('#5: p5 === "x5". Actual:  p5 ==='+ p5  );
    92 }
    94 if(!(myObj.p1 === "x1")){
    95   $ERROR('#6: myObj.p1 === "x1". Actual:  myObj.p1 ==='+ myObj.p1  );
    96 }
    98 if(!(myObj.p2 === "b")){
    99   $ERROR('#7: myObj.p2 === "b". Actual:  myObj.p2 ==='+ myObj.p2  );
   100 }
   102 if(!(myObj.p3 === undefined)){
   103   $ERROR('#8: myObj.p3 === undefined. Actual:  myObj.p3 ==='+ myObj.p3  );
   104 }
   106 if(!(myObj.p4 === undefined)){
   107   $ERROR('#9: myObj.p4 === undefined. Actual:  myObj.p4 ==='+ myObj.p4  );
   108 }
   110 if(!(myObj.p5 === undefined)){
   111   $ERROR('#10: myObj.p5 === undefined. Actual:  myObj.p5 ==='+ myObj.p5  );
   112 }
   114 if(!(st_parseInt !== parseInt)){
   115   $ERROR('#11: myObj.parseInt !== parseInt');
   116 }
   118 if(!(st_NaN === "obj_NaN")){
   119   $ERROR('#12: myObj.NaN !== NaN');
   120 }
   122 if(!(st_Infinity !== Infinity)){
   123   $ERROR('#13: myObj.Infinity !== Infinity');
   124 }
   126 if(!(st_eval !== eval)){
   127   $ERROR('#14: myObj.eval !== eval');
   128 }
   130 if(!(st_parseFloat !== parseFloat)){
   131   $ERROR('#15: myObj.parseFloat !== parseFloat');
   132 }
   134 if(!(st_isNaN !== isNaN)){
   135   $ERROR('#16: myObj.isNaN !== isNaN');
   136 }
   138 if(!(st_isFinite !== isFinite)){
   139   $ERROR('#17: myObj.isFinite !== isFinite');
   140 }
   142 try{
   143   value;
   144   $ERROR('#18: value is not defined');
   145 }
   146 catch(e){
   147 }
   149 if(!(myObj.value === "myObj_value")){
   150   $ERROR('#19: myObj.value === "myObj_value". Actual:  myObj.value ==='+ myObj.value  );
   151 }

mercurial