[parser] Skipping inner funcs: Add a simple mjsunit test.
Unfortunately, this test cannot test that a function was really skipped (i.e., not parsed). BUG=v8:5516 Change-Id: I8db5027d2216a95cc012ceae8e17554095cc1d4f Reviewed-on: https://chromium-review.googlesource.com/457037 Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#44615}
This commit is contained in:
parent
d3f1d5c50c
commit
7079bdb830
37
test/mjsunit/skipping-inner-functions.js
Normal file
37
test/mjsunit/skipping-inner-functions.js
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2017 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.
|
||||
|
||||
// Flags: --preparser-scope-analysis
|
||||
|
||||
(function TestBasicSkipping() {
|
||||
var result = 0;
|
||||
|
||||
function lazy(ctxt_alloc_param) {
|
||||
var ctxt_alloc_var = 10;
|
||||
function skip_me() {
|
||||
result = ctxt_alloc_param + ctxt_alloc_var;
|
||||
}
|
||||
return skip_me;
|
||||
}
|
||||
// Test that parameters and variables of the outer function get context
|
||||
// allocated even if we skip the inner function.
|
||||
lazy(9)();
|
||||
assertEquals(19, result);
|
||||
})();
|
||||
|
||||
(function TestSkippingFunctionWithEval() {
|
||||
var result = 0;
|
||||
|
||||
function lazy(ctxt_alloc_param) {
|
||||
var ctxt_alloc_var = 10;
|
||||
function skip_me() {
|
||||
eval('result = ctxt_alloc_param + ctxt_alloc_var');
|
||||
}
|
||||
return skip_me;
|
||||
}
|
||||
// Test that parameters and variables of the outer function get context
|
||||
// allocated even if we skip the inner function.
|
||||
lazy(9)();
|
||||
assertEquals(19, result);
|
||||
})();
|
Loading…
Reference in New Issue
Block a user