lazy-inner-functions.js 812 Bytes
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// Flags: --lazy-inner-functions

7 8
(function TestLazyInnerFunctionCallsEval() {
  var i = (function eager_outer() {
9 10 11 12 13 14 15 16 17 18 19 20
    var outer_var = 41; // Should be context-allocated
    function lazy_inner() {
      return eval("outer_var");
    }
    return lazy_inner;
  })();
  assertEquals(41, i());
})();

(function TestLazyInnerFunctionDestructuring() {
  var i = (function eager_outer() {
    var outer_var = 41; // Should be context-allocated
21
    function lazy_inner() {
22 23 24
      // This introduces b and refers to outer_var.
      var {outer_var : b} = {outer_var};
      return b;
25 26 27 28 29
    }
    return lazy_inner;
  })();
  assertEquals(41, i());
})();