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

mercurial