js/src/tests/js1_5/extensions/regress-350312-02.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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 350312;
     8 var summary = 'Accessing wrong stack slot with nested catch/finally';
     9 var actual = '';
    10 var expect = '';
    13 //-----------------------------------------------------------------------------
    14 test();
    15 //-----------------------------------------------------------------------------
    17 function test()
    18 {
    19   enterFunc ('test');
    20   printBugNumber(BUGNUMBER);
    21   printStatus (summary);
    23   function createPrint(obj)
    24   {
    25     return new Function("actual += " + obj + " + ','; " +
    26 			"print(" + obj + ");");
    27   }
    29   function createThrow(obj)
    30   {
    31     return new Function("throw " + obj + "; ");
    32   }
    35   function f(a, b, c)
    36   {
    37     try {
    38       a();
    39     } catch (e if e == null) {
    40       b();
    41     } finally {
    42       c();
    43     }
    44   }
    46   print('test 1');
    47   expect = 'a,c,';
    48   actual = '';
    49   try
    50   {
    51     f(createPrint("'a'"), createPrint("'b'"), createPrint("'c'"));
    52   }
    53   catch(ex)
    54   {
    55     actual += 'caught ' + ex;
    56   }
    57   reportCompare(expect, actual, summary + ': 1');
    59   print('test 2');
    60   expect = 'c,caught a';
    61   actual = '';
    62   try
    63   {
    64     f(createThrow("'a'"), createPrint("'b'"), createPrint("'c'"));
    65   }
    66   catch(ex)
    67   {
    68     actual += 'caught ' + ex;
    69   }
    70   reportCompare(expect, actual, summary + ': 2');
    72   print('test 3');
    73   expect = 'b,c,';
    74   actual = '';
    75   try
    76   {
    77     f(createThrow("null"), createPrint("'b'"), createPrint("'c'"));
    78   }
    79   catch(ex)
    80   {
    81     actual += 'caught ' + ex;
    82   }
    83   reportCompare(expect, actual, summary + ': 3');
    85   print('test 4');
    86   expect = 'a,c,';
    87   actual = '';
    88   try
    89   {
    90     f(createPrint("'a'"), createThrow("'b'"), createPrint("'c'"));
    91   }
    92   catch(ex)
    93   {
    94     actual += 'caught ' + ex;
    95   }
    96   reportCompare(expect, actual, summary + ': 4');
    98   print('test 5');
    99   expect = 'c,caught b';
   100   actual = '';
   101   try
   102   {
   103     f(createThrow("null"), createThrow("'b'"), createPrint("'c'"));
   104   }
   105   catch(ex)
   106   {
   107     actual += 'caught ' + ex;
   108   }
   109   reportCompare(expect, actual, summary + ': 5');
   111   exitFunc ('test');
   112 }

mercurial