js/src/tests/js1_5/extensions/regress-350312-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/extensions/regress-350312-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +//-----------------------------------------------------------------------------
    1.10 +var BUGNUMBER = 350312;
    1.11 +var summary = 'Accessing wrong stack slot with nested catch/finally';
    1.12 +var actual = '';
    1.13 +var expect = '';
    1.14 +
    1.15 +
    1.16 +//-----------------------------------------------------------------------------
    1.17 +test();
    1.18 +//-----------------------------------------------------------------------------
    1.19 +
    1.20 +function test()
    1.21 +{
    1.22 +  enterFunc ('test');
    1.23 +  printBugNumber(BUGNUMBER);
    1.24 +  printStatus (summary);
    1.25 +
    1.26 +  function createPrint(obj)
    1.27 +  {
    1.28 +    return new Function("actual += " + obj + " + ','; " +
    1.29 +			"print(" + obj + ");");
    1.30 +  }
    1.31 +
    1.32 +  function createThrow(obj)
    1.33 +  {
    1.34 +    return new Function("throw " + obj + "; ");
    1.35 +  }
    1.36 +
    1.37 +
    1.38 +  function f(a, b, c)
    1.39 +  {
    1.40 +    try {
    1.41 +      a();
    1.42 +    } catch (e if e == null) {
    1.43 +      b();
    1.44 +    } finally {
    1.45 +      c();
    1.46 +    }
    1.47 +  }
    1.48 +
    1.49 +  print('test 1');
    1.50 +  expect = 'a,c,';
    1.51 +  actual = '';
    1.52 +  try
    1.53 +  {
    1.54 +    f(createPrint("'a'"), createPrint("'b'"), createPrint("'c'"));
    1.55 +  }
    1.56 +  catch(ex)
    1.57 +  {
    1.58 +    actual += 'caught ' + ex;
    1.59 +  }
    1.60 +  reportCompare(expect, actual, summary + ': 1');
    1.61 +
    1.62 +  print('test 2');
    1.63 +  expect = 'c,caught a';
    1.64 +  actual = '';
    1.65 +  try
    1.66 +  {
    1.67 +    f(createThrow("'a'"), createPrint("'b'"), createPrint("'c'"));
    1.68 +  }
    1.69 +  catch(ex)
    1.70 +  {
    1.71 +    actual += 'caught ' + ex;
    1.72 +  }
    1.73 +  reportCompare(expect, actual, summary + ': 2');
    1.74 +
    1.75 +  print('test 3');
    1.76 +  expect = 'b,c,';
    1.77 +  actual = '';
    1.78 +  try
    1.79 +  {
    1.80 +    f(createThrow("null"), createPrint("'b'"), createPrint("'c'"));
    1.81 +  }
    1.82 +  catch(ex)
    1.83 +  {
    1.84 +    actual += 'caught ' + ex;
    1.85 +  }
    1.86 +  reportCompare(expect, actual, summary + ': 3');
    1.87 +
    1.88 +  print('test 4');
    1.89 +  expect = 'a,c,';
    1.90 +  actual = '';
    1.91 +  try
    1.92 +  {
    1.93 +    f(createPrint("'a'"), createThrow("'b'"), createPrint("'c'"));
    1.94 +  }
    1.95 +  catch(ex)
    1.96 +  {
    1.97 +    actual += 'caught ' + ex;
    1.98 +  }
    1.99 +  reportCompare(expect, actual, summary + ': 4');
   1.100 +
   1.101 +  print('test 5');
   1.102 +  expect = 'c,caught b';
   1.103 +  actual = '';
   1.104 +  try
   1.105 +  {
   1.106 +    f(createThrow("null"), createThrow("'b'"), createPrint("'c'"));
   1.107 +  }
   1.108 +  catch(ex)
   1.109 +  {
   1.110 +    actual += 'caught ' + ex;
   1.111 +  }
   1.112 +  reportCompare(expect, actual, summary + ': 5');
   1.113 +
   1.114 +  exitFunc ('test');
   1.115 +}

mercurial