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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial