[coverage] Support for-of and for-in loops
Bug: v8:6000 Change-Id: Ia50108ebbf838e210d95cb268858394e6a66c88d Reviewed-on: https://chromium-review.googlesource.com/567990 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#46658}
This commit is contained in:
parent
31471c5d05
commit
5162488ae1
@ -5584,7 +5584,11 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
|
||||
BlockState block_state(zone(), &scope_);
|
||||
scope()->set_start_position(scanner()->location().beg_pos);
|
||||
|
||||
SourceRange body_range;
|
||||
SourceRangeScope range_scope(scanner(), &body_range);
|
||||
|
||||
StatementT body = ParseStatement(nullptr, CHECK_OK);
|
||||
impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
|
||||
|
||||
BlockT body_block = impl()->NullBlock();
|
||||
ExpressionT each_variable = impl()->EmptyExpression();
|
||||
@ -5645,10 +5649,14 @@ ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
|
||||
BlockState block_state(zone(), &scope_);
|
||||
scope()->set_start_position(scanner()->location().beg_pos);
|
||||
|
||||
SourceRange body_range;
|
||||
SourceRangeScope range_scope(scanner(), &body_range);
|
||||
|
||||
StatementT body = ParseStatement(nullptr, CHECK_OK);
|
||||
scope()->set_end_position(scanner()->location().end_pos);
|
||||
StatementT final_loop =
|
||||
impl()->InitializeForEachStatement(loop, expression, enumerable, body);
|
||||
impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
|
||||
|
||||
for_scope = for_scope->FinalizeBlockScope();
|
||||
USE(for_scope);
|
||||
@ -5850,8 +5858,12 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
|
||||
BlockState block_state(zone(), &scope_);
|
||||
scope()->set_start_position(scanner()->location().beg_pos);
|
||||
|
||||
SourceRange body_range;
|
||||
SourceRangeScope range_scope(scanner(), &body_range);
|
||||
|
||||
StatementT body = ParseStatement(nullptr, CHECK_OK);
|
||||
scope()->set_end_position(scanner()->location().end_pos);
|
||||
impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
|
||||
|
||||
if (has_declarations) {
|
||||
BlockT body_block = impl()->NullBlock();
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --allow-natives-syntax --no-always-opt --ignition --block-coverage
|
||||
// Flags: --allow-natives-syntax --no-always-opt --ignition --block-coverage --harmony-async-iteration
|
||||
// Flags: --no-stress-fullcodegen
|
||||
|
||||
// Test precise code coverage.
|
||||
@ -204,6 +204,44 @@ TestCoverage(
|
||||
{"start":761,"end":951,"count":0}]
|
||||
);
|
||||
|
||||
TestCoverage(
|
||||
"for-of and for-in statements",
|
||||
`
|
||||
!function() { // 0000
|
||||
var i; // 0050
|
||||
for (i of [0,1,2,3]) { nop(); } // 0100
|
||||
for (let j of [0,1,2,3]) { nop(); } // 0150
|
||||
for (i in [0,1,2,3]) { nop(); } // 0200
|
||||
for (let j in [0,1,2,3]) { nop(); } // 0250
|
||||
var xs = [{a:0, b:1}, {a:1,b:0}]; // 0300
|
||||
for (var {a: x, b: y} of xs) { nop(); } // 0350
|
||||
}(); // 0400
|
||||
`,
|
||||
[{"start":0,"end":449,"count":1},
|
||||
{"start":1,"end":401,"count":1},
|
||||
{"start":123,"end":133,"count":4},
|
||||
{"start":177,"end":187,"count":4},
|
||||
{"start":223,"end":233,"count":4},
|
||||
{"start":277,"end":287,"count":4},
|
||||
{"start":381,"end":391,"count":2}]
|
||||
);
|
||||
|
||||
TestCoverage(
|
||||
"for-await-of statements",
|
||||
`
|
||||
!async function() { // 0000
|
||||
for await (var x of [0,1,2,3]) { // 0050
|
||||
nop(); // 0100
|
||||
} // 0150
|
||||
}(); // 0200
|
||||
%RunMicrotasks(); // 0250
|
||||
`,
|
||||
[{"start":0,"end":299,"count":1},
|
||||
{"start":1,"end":201,"count":6}, // TODO(jgruber): Invocation count is off.
|
||||
{"start":83,"end":153,"count":4},
|
||||
{"start":153,"end":201,"count":1}]
|
||||
);
|
||||
|
||||
TestCoverage(
|
||||
"while and do-while statements",
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user