js/src/tests/test262/ch12/12.10/S12.10_A1.1_T3.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.1_T3.js
michael@0 9 * @description Using "with" inside of global context leading to completion by exception
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 try {
michael@0 43 with(myObj){
michael@0 44 throw value;
michael@0 45 st_p1 = p1;
michael@0 46 st_p2 = p2;
michael@0 47 st_p3 = p3;
michael@0 48 st_parseInt = parseInt;
michael@0 49 st_NaN = NaN;
michael@0 50 st_Infinity = Infinity;
michael@0 51 st_eval = eval;
michael@0 52 st_parseFloat = parseFloat;
michael@0 53 st_isNaN = isNaN;
michael@0 54 st_isFinite = isFinite;
michael@0 55 p1 = 'x1';
michael@0 56 this.p2 = 'x2';
michael@0 57 del = delete p3;
michael@0 58 var p4 = 'x4';
michael@0 59 p5 = 'x5';
michael@0 60 var value = 'value';
michael@0 61 }
michael@0 62 } catch(e){
michael@0 63 result = e;
michael@0 64 }
michael@0 65
michael@0 66 if(!(result === "myObj_value")){
michael@0 67 $ERROR('#0: result === "myObj_value". Actual: result ==='+ result );
michael@0 68 }
michael@0 69
michael@0 70 if(!(p1 === 1)){
michael@0 71 $ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
michael@0 72 }
michael@0 73
michael@0 74 if(!(p2 === 2)){
michael@0 75 $ERROR('#2: p2 === 2. Actual: p2 ==='+ p2 );
michael@0 76 }
michael@0 77
michael@0 78 if(!(p3 === 3)){
michael@0 79 $ERROR('#3: p3 === 3. Actual: p3 ==='+ p3 );
michael@0 80 }
michael@0 81
michael@0 82 if(!(p4 === undefined)){
michael@0 83 $ERROR('#4: p4 === undefined. Actual: p4 ==='+ p4 );
michael@0 84 }
michael@0 85
michael@0 86 try {
michael@0 87 p5;
michael@0 88 $ERROR('#5: p5 is not defined');
michael@0 89 } catch(e) {
michael@0 90 }
michael@0 91
michael@0 92 if(!(myObj.p1 === "a")){
michael@0 93 $ERROR('#6: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
michael@0 94 }
michael@0 95
michael@0 96 if(!(myObj.p2 === "b")){
michael@0 97 $ERROR('#7: myObj.p2 === "b". Actual: myObj.p2 ==='+ myObj.p2 );
michael@0 98 }
michael@0 99
michael@0 100 if(!(myObj.p3 === "c")){
michael@0 101 $ERROR('#8: myObj.p3 === "c". Actual: myObj.p3 ==='+ myObj.p3 );
michael@0 102 }
michael@0 103
michael@0 104 if(!(myObj.p4 === undefined)){
michael@0 105 $ERROR('#9: myObj.p4 === undefined. Actual: myObj.p4 ==='+ myObj.p4 );
michael@0 106 }
michael@0 107
michael@0 108 if(!(myObj.p5 === undefined)){
michael@0 109 $ERROR('#10: myObj.p5 === undefined. Actual: myObj.p5 ==='+ myObj.p5 );
michael@0 110 }
michael@0 111
michael@0 112 if(!(st_parseInt === "parseInt")){
michael@0 113 $ERROR('#11: myObj.parseInt === "parseInt". Actual: myObj.parseInt ==='+ myObj.parseInt );
michael@0 114 }
michael@0 115
michael@0 116 if(!(st_NaN === "NaN")){
michael@0 117 $ERROR('#12: st_NaN === "NaN". Actual: st_NaN ==='+ st_NaN );
michael@0 118 }
michael@0 119
michael@0 120 if(!(st_Infinity === "Infinity")){
michael@0 121 $ERROR('#13: st_Infinity === "Infinity". Actual: st_Infinity ==='+ st_Infinity );
michael@0 122 }
michael@0 123
michael@0 124 if(!(st_eval === "eval")){
michael@0 125 $ERROR('#14: st_eval === "eval". Actual: st_eval ==='+ st_eval );
michael@0 126 }
michael@0 127
michael@0 128 if(!(st_parseFloat === "parseFloat")){
michael@0 129 $ERROR('#15: st_parseFloat === "parseFloat". Actual: st_parseFloat ==='+ st_parseFloat );
michael@0 130 }
michael@0 131
michael@0 132 if(!(st_isNaN === "isNaN")){
michael@0 133 $ERROR('#16: st_isNaN === "isNaN". Actual: st_isNaN ==='+ st_isNaN );
michael@0 134 }
michael@0 135
michael@0 136 if(!(st_isFinite === "isFinite")){
michael@0 137 $ERROR('#17: st_isFinite === "isFinite". Actual: st_isFinite ==='+ st_isFinite );
michael@0 138 }
michael@0 139
michael@0 140 if(!(value === undefined)){
michael@0 141 $ERROR('#18: value === undefined. Actual: value ==='+ value );
michael@0 142 }
michael@0 143
michael@0 144 if(!(myObj.value === "myObj_value")){
michael@0 145 $ERROR('#19: myObj.value === "myObj_value". Actual: myObj.value ==='+ myObj.value );
michael@0 146 }
michael@0 147

mercurial