js/src/tests/test262/ch12/12.13/S12.13_A2_T6.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.13/S12.13_A2_T6.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     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 + * "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 evaluates Expression
     1.9 + *
    1.10 + * @path ch12/12.13/S12.13_A2_T6.js
    1.11 + * @description Throwing object
    1.12 + */
    1.13 +
    1.14 +var myObj = {p1: 'a', 
    1.15 +             p2: 'b', 
    1.16 +             p3: 'c',
    1.17 +             value: 'myObj_value',
    1.18 +             valueOf : function(){return 'obj_valueOf';},
    1.19 +             parseInt : function(){return 'obj_parseInt';},
    1.20 +             NaN : 'obj_NaN',
    1.21 +             Infinity : 'obj_Infinity',
    1.22 +             eval     : function(){return 'obj_eval';},
    1.23 +             parseFloat : function(){return 'obj_parseFloat';},
    1.24 +             isNaN      : function(){return 'obj_isNaN';},
    1.25 +             isFinite   : function(){return 'obj_isFinite';},
    1.26 +             i:7
    1.27 +}
    1.28 +
    1.29 +try{
    1.30 +  throw myObj;
    1.31 +}
    1.32 +catch(e){	
    1.33 +// CHECK#1
    1.34 +  if (e.p1!=="a") $ERROR('#1: e.p1 === "a". Actual:  e.p1 ==='+ e.p1  );
    1.35 +// CHECK#2
    1.36 +  if (e.value!=='myObj_value') $ERROR('#2: e.p1 === \'myObj_value\'. Actual:  e.p1 ==='+ e.p1  );
    1.37 +// CHECK#3
    1.38 +  if (e.eval()!=='obj_eval') $ERROR('#3: e.p1 === \'obj_eval\'. Actual:  e.p1 ==='+ e.p1  );
    1.39 +}
    1.40 +
    1.41 +// CHECK#4
    1.42 +myObj.i=6
    1.43 +try{
    1.44 +  throw myObj;
    1.45 +}
    1.46 +catch(e){}
    1.47 +if (myObj.i!==6) $ERROR('#4: Handling of catch must be correct');
    1.48 +

mercurial