Home | History | Annotate | Download | only in regress
      1 // Copyright 2016 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Flags: --allow-natives-syntax --harmony-do-expressions
      6 
      7 (function DoTryCatchInsideBinop() {
      8   function f(a, b) {
      9     return a + do { try { throw "boom" } catch(e) { b } }
     10   }
     11   assertEquals(3, f(1, 2));
     12   assertEquals(3, f(1, 2));
     13   %OptimizeFunctionOnNextCall(f);
     14   assertEquals(3, f(1, 2));
     15 })();
     16 
     17 (function DoTryCatchInsideCall() {
     18   function f(a, b) {
     19     return Math.max(a, do { try { throw a } catch(e) { e + b } })
     20   }
     21   assertEquals(3, f(1, 2));
     22   assertEquals(3, f(1, 2));
     23   %OptimizeFunctionOnNextCall(f);
     24   assertEquals(3, f(1, 2));
     25 })();
     26 
     27 (function DoTryCatchInsideTry() {
     28   function f(a, b) {
     29     try { return do { try { throw a } catch(e) { e + b } } } catch(e) {}
     30   }
     31   assertEquals(3, f(1, 2));
     32   assertEquals(3, f(1, 2));
     33   %OptimizeFunctionOnNextCall(f);
     34   assertEquals(3, f(1, 2));
     35 })();
     36 
     37 (function DoTryCatchInsideFinally() {
     38   function f(a, b) {
     39     try {} finally { return do { try { throw a } catch(e) { e + b } } }
     40   }
     41   assertEquals(3, f(1, 2));
     42   assertEquals(3, f(1, 2));
     43   %OptimizeFunctionOnNextCall(f);
     44   assertEquals(3, f(1, 2));
     45 })();
     46