js/src/tests/js1_7/block/regress-343765.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 = 343765;
     8 var summary = 'Function defined in a let statement/expression does not work correctly outside the let scope';
     9 var actual = '';
    10 var expect = '';
    13 //-----------------------------------------------------------------------------
    14 test();
    15 //-----------------------------------------------------------------------------
    17 function test()
    18 {
    19   enterFunc ('test');
    20   printBugNumber(BUGNUMBER);
    21   printStatus (summary);
    23   print("SECTION 1");
    24   try {
    25     let (a = 2, b = 3) { function f() { return String([a,b]); } f(); throw 42; }
    26   } catch (e) {
    27     f();
    28   }
    30   reportCompare(expect, actual, summary);
    32   print("SECTION 2");
    33   try {
    34     with ({a:2,b:3}) { function f() { return String([a,b]); } f(); throw 42; }
    35   } catch (e) {
    36     f();
    37   }
    39   print("SECTION 3");
    40   function g3() {
    41     print("Here!");
    42     with ({a:2,b:3}) {
    43       function f() {
    44         return String([a,b]);
    45       }
    47       f();
    48       return f;
    49     }
    50   }
    52   k = g3();
    53   k();
    55   print("SECTION 4");
    56   function g4() {
    57     print("Here!");
    58     let (a=2,b=3) {
    59       function f() {
    60         return String([a,b]);
    61       }
    63       f();
    64       return f;
    65     }
    66   }
    68   k = g4();
    69   k();
    71   print("SECTION 5");
    72   function g5() {
    73     print("Here!");
    74     let (a=2,b=3) {
    75       function f() {
    76         return String([a,b]);
    77       }
    79       f();
    80       yield f;
    81     }
    82   }
    84   k = g5().next();
    85   k();
    87   reportCompare(expect, actual, summary);
    89   exitFunc ('test');
    90 }
    92 function returnResult(a)
    93 {
    94   return a + '';
    95 }

mercurial