From 7764f522989f914d9c16bc5bf544bcd0560ff8f2 Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Thu, 24 Nov 2022 09:12:45 +0000 Subject: [PATCH 1/2] Fix loop implementation of es2abc Issue:I62YS7 Signed-off-by: ctw-ian Change-Id: I943f0a275b321f47a71d36f74c518e75a8e32ca9 --- es2panda/binder/binder.cpp | 15 ++--- es2panda/binder/scope.cpp | 57 +++++-------------- es2panda/binder/scope.h | 53 ++--------------- es2panda/compiler/core/envScope.cpp | 18 +----- es2panda/compiler/core/envScope.h | 14 ++--- es2panda/ir/statements/doWhileStatement.cpp | 3 +- es2panda/ir/statements/forInStatement.cpp | 22 ++++--- es2panda/ir/statements/forOfStatement.cpp | 19 ++++--- es2panda/ir/statements/forUpdateStatement.cpp | 16 ++---- es2panda/ir/statements/whileStatement.cpp | 3 +- es2panda/parser/statementParser.cpp | 6 +- .../lexEnv/forIn-loopEnv-test-1-expected.txt | 3 + .../js/lexEnv/forIn-loopEnv-test-1.js | 12 ++++ .../lexEnv/forIn-loopEnv-test-2-expected.txt | 3 + .../js/lexEnv/forIn-loopEnv-test-2.js | 13 +++++ .../lexEnv/forIn-loopEnv-test-3-expected.txt | 3 + .../js/lexEnv/forIn-loopEnv-test-3.js | 13 +++++ .../lexEnv/forOf-loopEnv-test-1-expected.txt | 3 + .../js/lexEnv/forOf-loopEnv-test-1.js | 12 ++++ .../lexEnv/forOf-loopEnv-test-2-expected.txt | 3 + .../js/lexEnv/forOf-loopEnv-test-2.js | 13 +++++ .../lexEnv/forOf-loopEnv-test-3-expected.txt | 3 + .../js/lexEnv/forOf-loopEnv-test-3.js | 13 +++++ .../forUpdate-loopEnv-test-1-expected.txt | 3 + .../js/lexEnv/forUpdate-loopEnv-test-1.js | 12 ++++ .../forUpdate-loopEnv-test-2-expected.txt | 3 + .../js/lexEnv/forUpdate-loopEnv-test-2.js | 13 +++++ .../forUpdate-loopEnv-test-3-expected.txt | 3 + .../js/lexEnv/forUpdate-loopEnv-test-3.js | 13 +++++ 29 files changed, 207 insertions(+), 160 deletions(-) create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index e9369fa834..3f48313e3c 100644 --- a/es2panda/binder/binder.cpp +++ b/es2panda/binder/binder.cpp @@ -402,7 +402,7 @@ void Binder::BuildForUpdateLoop(ir::ForUpdateStatement *forUpdateStmt) { auto *loopScope = forUpdateStmt->Scope(); - auto declScopeCtx = LexicalScope::Enter(this, loopScope->DeclScope()); + auto loopCtx = LexicalScope::Enter(this, loopScope); if (forUpdateStmt->Init()) { ResolveReference(forUpdateStmt, forUpdateStmt->Init()); @@ -412,29 +412,25 @@ void Binder::BuildForUpdateLoop(ir::ForUpdateStatement *forUpdateStmt) ResolveReference(forUpdateStmt, forUpdateStmt->Update()); } - auto loopCtx = LexicalScope::Enter(this, loopScope); - if (forUpdateStmt->Test()) { ResolveReference(forUpdateStmt, forUpdateStmt->Test()); } ResolveReference(forUpdateStmt, forUpdateStmt->Body()); - loopCtx.GetScope()->ConvertToVariableScope(Allocator()); + loopCtx.GetScope()->InitVariable(); } void Binder::BuildForInOfLoop(const ir::Statement *parent, binder::LoopScope *loopScope, ir::AstNode *left, ir::Expression *right, ir::Statement *body) { - auto declScopeCtx = LexicalScope::Enter(this, loopScope->DeclScope()); + auto loopCtx = LexicalScope::Enter(this, loopScope); ResolveReference(parent, right); ResolveReference(parent, left); - auto loopCtx = LexicalScope::Enter(this, loopScope); - ResolveReference(parent, body); - loopCtx.GetScope()->ConvertToVariableScope(Allocator()); + loopCtx.GetScope()->InitVariable(); } void Binder::BuildCatchClause(ir::CatchClause *catchClauseStmt) @@ -541,6 +537,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) { auto loopScopeCtx = LexicalScope::Enter(this, doWhileStatement->Scope()); ResolveReference(doWhileStatement, doWhileStatement->Body()); + loopScopeCtx.GetScope()->InitVariable(); } ResolveReference(doWhileStatement, doWhileStatement->Test()); @@ -552,7 +549,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) auto loopScopeCtx = LexicalScope::Enter(this, whileStatement->Scope()); ResolveReference(whileStatement, whileStatement->Body()); - + loopScopeCtx.GetScope()->InitVariable(); break; } case ir::AstNodeType::FOR_UPDATE_STATEMENT: { diff --git a/es2panda/binder/scope.cpp b/es2panda/binder/scope.cpp index f88131722c..380c31773f 100644 --- a/es2panda/binder/scope.cpp +++ b/es2panda/binder/scope.cpp @@ -113,6 +113,8 @@ ScopeFindResult Scope::Find(const util::StringView &name, ResolveBindingOptions iter = iter->Parent(); } + bool lexical = false; + while (iter != nullptr) { Variable *v = iter->FindLocal(name, options); @@ -120,8 +122,14 @@ ScopeFindResult Scope::Find(const util::StringView &name, ResolveBindingOptions return {name, const_cast(iter), level, lexLevel, v, crossConcurrent}; } + if (iter->IsFunctionVariableScope() && !lexical) { + lexical = true; + } + if (iter->IsVariableScope()) { - level++; + if (lexical) { + level++; + } if (iter->IsFunctionScope() && !crossConcurrent) { crossConcurrent = iter->Node()->AsScriptFunction()->IsConcurrent() ? true : false; @@ -443,53 +451,18 @@ bool LocalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable return AddLocal(allocator, currentVariable, newDecl, extension); } -void LoopDeclarationScope::ConvertToVariableScope(ArenaAllocator *allocator) +void LoopScope::InitVariable() { - if (NeedLexEnv()) { - return; - } - - for (auto &[name, var] : bindings_) { - if (!var->LexicalBound() || !var->Declaration()->IsLetOrConstOrClassDecl()) { + for (const auto &[name, var] : bindings_) { + if (!var->Declaration()->IsLetOrConstOrClassDecl()) { continue; } - slotIndex_++; - loopType_ = ScopeType::LOOP_DECL; - auto *copiedVar = var->AsLocalVariable()->Copy(allocator, var->Declaration()); - copiedVar->AddFlag(VariableFlags::INITIALIZED | VariableFlags::PER_ITERATION); - var->AddFlag(VariableFlags::LOOP_DECL); - loopScope_->Bindings().insert({name, copiedVar}); - } - - if (loopType_ == ScopeType::LOOP_DECL) { - slotIndex_ = std::max(slotIndex_, parent_->EnclosingVariableScope()->LexicalSlots()); - initScope_ = allocator->New(allocator, parent_); - initScope_->BindNode(node_); - initScope_->Bindings() = bindings_; - } -} - -void LoopScope::ConvertToVariableScope(ArenaAllocator *allocator) -{ - declScope_->ConvertToVariableScope(allocator); - - if (loopType_ != ScopeType::LOCAL) { - return; - } - - for (const auto &[_, var] : bindings_) { - (void)_; - if (var->LexicalBound() && var->Declaration()->IsLetDecl()) { - ASSERT(declScope_->NeedLexEnv()); - loopType_ = ScopeType::LOOP; - break; + var->AddFlag(VariableFlags::INITIALIZED); + if (var->LexicalBound()) { + var->AddFlag(VariableFlags::PER_ITERATION); } } - - if (loopType_ == ScopeType::LOOP) { - slotIndex_ = std::max(slotIndex_, declScope_->LexicalSlots()); - } } bool CatchParamScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, diff --git a/es2panda/binder/scope.h b/es2panda/binder/scope.h index 6bb538234c..1b6024dfca 100644 --- a/es2panda/binder/scope.h +++ b/es2panda/binder/scope.h @@ -636,62 +636,18 @@ public: [[maybe_unused]] ScriptExtension extension) override; }; -class LoopScope; - -class LoopDeclarationScope : public VariableScope { -public: - explicit LoopDeclarationScope(ArenaAllocator *allocator, Scope *parent) : VariableScope(allocator, parent) {} - - ScopeType Type() const override - { - return loopType_; - } - - bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, - [[maybe_unused]] ScriptExtension extension) override - { - return AddLocal(allocator, currentVariable, newDecl, extension); - } - - Scope *InitScope() - { - if (NeedLexEnv()) { - return initScope_; - } - - return this; - } - - void ConvertToVariableScope(ArenaAllocator *allocator); - -private: - friend class LoopScope; - LoopScope *loopScope_ {}; - LocalScope *initScope_ {}; - ScopeType loopType_ {ScopeType::LOCAL}; -}; - class LoopScope : public VariableScope { public: explicit LoopScope(ArenaAllocator *allocator, Scope *parent) : VariableScope(allocator, parent) {} - LoopDeclarationScope *DeclScope() - { - return declScope_; - } - - void BindDecls(LoopDeclarationScope *declScope) - { - declScope_ = declScope; - declScope_->loopScope_ = this; - } - ScopeType Type() const override { return loopType_; } - void ConvertToVariableScope(ArenaAllocator *allocator); + void ConvertToVariableScope([[maybe_unused]] ArenaAllocator *allocator); + + void InitVariable(); bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, [[maybe_unused]] ScriptExtension extension) override @@ -700,8 +656,7 @@ public: } protected: - LoopDeclarationScope *declScope_ {}; - ScopeType loopType_ {ScopeType::LOCAL}; + ScopeType loopType_ {ScopeType::LOOP}; }; class GlobalScope : public FunctionScope { diff --git a/es2panda/compiler/core/envScope.cpp b/es2panda/compiler/core/envScope.cpp index 6cb007c87e..aa3e98344a 100644 --- a/es2panda/compiler/core/envScope.cpp +++ b/es2panda/compiler/core/envScope.cpp @@ -46,30 +46,18 @@ EnvScope::~EnvScope() pg_->envScope_ = prev_; } -void LoopEnvScope::CopyBindings(PandaGen *pg, binder::VariableScope *scope, binder::VariableFlags flag) +void LoopEnvScope::InitLoopContext(PandaGen *pg, binder::VariableScope *scope) { if (!HasEnv()) { return; } Initialize(pg); - - pg_->NewLexicalEnv(scope_->Node(), scope->LexicalSlots(), scope_); - ASSERT(scope->NeedLexEnv()); - - for (const auto &[_, variable] : scope_->Bindings()) { - (void)_; - if (!variable->HasFlag(flag)) { - continue; - } - - pg->LoadLexicalVar(scope_->Node(), 1, variable->AsLocalVariable()->LexIdx()); - pg->StoreLexicalVar(scope_->Parent()->Node(), 0, variable->AsLocalVariable()->LexIdx()); - } + pg_->NewLexicalEnv(scope_->Node(), scope->LexicalSlots(), scope_); } -void LoopEnvScope::CopyPetIterationCtx() +void LoopEnvScope::CopyPerIterationCtx() { if (!HasEnv()) { return; diff --git a/es2panda/compiler/core/envScope.h b/es2panda/compiler/core/envScope.h index a21c2a3e52..29faecfc9f 100644 --- a/es2panda/compiler/core/envScope.h +++ b/es2panda/compiler/core/envScope.h @@ -71,19 +71,13 @@ public: explicit LoopEnvScope(PandaGen *pg, binder::LoopScope *scope, LabelTarget target) : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg, scope), lexEnvCtx_(this, pg, target) { - CopyBindings(pg, scope, binder::VariableFlags::PER_ITERATION); + InitLoopContext(pg, scope); } explicit LoopEnvScope(PandaGen *pg, LabelTarget target, binder::LoopScope *scope) : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg), lexEnvCtx_(this, pg, target) { - CopyBindings(pg, scope, binder::VariableFlags::PER_ITERATION); - } - - explicit LoopEnvScope(PandaGen *pg, binder::LoopDeclarationScope *scope) - : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg), lexEnvCtx_(this, pg, {}) - { - CopyBindings(pg, scope, binder::VariableFlags::LOOP_DECL); + InitLoopContext(pg, scope); } binder::VariableScope *Scope() const @@ -97,7 +91,7 @@ public: return scope_ != nullptr; } - void CopyPetIterationCtx(); + void CopyPerIterationCtx(); private: static bool NeedEnv(binder::VariableScope *scope) @@ -107,6 +101,8 @@ private: void CopyBindings(PandaGen *pg, binder::VariableScope *scope, binder::VariableFlags flag); + void InitLoopContext(PandaGen *pg, binder::VariableScope *scope); + binder::VariableScope *scope_ {}; LocalRegScope regScope_; LexEnvContext lexEnvCtx_; diff --git a/es2panda/ir/statements/doWhileStatement.cpp b/es2panda/ir/statements/doWhileStatement.cpp index 83078b77ef..cc862254b6 100644 --- a/es2panda/ir/statements/doWhileStatement.cpp +++ b/es2panda/ir/statements/doWhileStatement.cpp @@ -45,8 +45,7 @@ void DoWhileStatement::Compile(compiler::PandaGen *pg) const pg->SetLabel(this, startLabel); { - compiler::LocalRegScope regScope(pg, scope_); - compiler::LabelContext labelCtx(pg, labelTarget); + compiler::LoopEnvScope envScope(pg, labelTarget, scope_); body_->Compile(pg); } diff --git a/es2panda/ir/statements/forInStatement.cpp b/es2panda/ir/statements/forInStatement.cpp index 2ccad0cb65..512f9ca8f2 100644 --- a/es2panda/ir/statements/forInStatement.cpp +++ b/es2panda/ir/statements/forInStatement.cpp @@ -41,9 +41,11 @@ void ForInStatement::Dump(ir::AstDumper *dumper) const void ForInStatement::Compile(compiler::PandaGen *pg) const { - compiler::LabelTarget labelTarget(pg); + if (scope_->NeedLexEnv()) { + pg->NewLexEnv(this, scope_->LexicalSlots()); + } - compiler::RegScope rs(pg); + compiler::LocalRegScope loopRegScope(pg, scope_); compiler::VReg iter = pg->AllocReg(); compiler::VReg propName = pg->AllocReg(); @@ -52,6 +54,12 @@ void ForInStatement::Compile(compiler::PandaGen *pg) const pg->GetPropIterator(this); pg->StoreAccumulator(this, iter); + if (scope_->NeedLexEnv()) { + pg->PopLexEnv(this); + } + + compiler::LabelTarget labelTarget(pg); + // loop start pg->SetLabel(this, labelTarget.ContinueTarget()); // get next prop of enumerator @@ -59,14 +67,11 @@ void ForInStatement::Compile(compiler::PandaGen *pg) const pg->StoreAccumulator(this, propName); pg->BranchIfUndefined(this, labelTarget.BreakTarget()); - compiler::LocalRegScope declRegScope(pg, scope_->DeclScope()->InitScope()); auto lref = compiler::LReference::CreateLRef(pg, left_, false); - pg->LoadAccumulator(this, propName); - lref.SetValue(); - { - compiler::LoopEnvScope declEnvScope(pg, scope_->DeclScope()); compiler::LoopEnvScope envScope(pg, scope_, labelTarget); + pg->LoadAccumulator(this, propName); + lref.SetValue(); body_->Compile(pg); } @@ -82,11 +87,10 @@ checker::Type *ForInStatement::Check([[maybe_unused]] checker::Checker *checker) void ForInStatement::UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) { auto *loopScope = Scope(); - auto declScopeCtx = binder::LexicalScope::Enter(binder, loopScope->DeclScope()); + auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); left_ = std::get(cb(left_)); right_ = std::get(cb(right_))->AsExpression(); - auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); body_ = std::get(cb(body_))->AsStatement(); } diff --git a/es2panda/ir/statements/forOfStatement.cpp b/es2panda/ir/statements/forOfStatement.cpp index f653ce3108..d492fb48cc 100644 --- a/es2panda/ir/statements/forOfStatement.cpp +++ b/es2panda/ir/statements/forOfStatement.cpp @@ -41,9 +41,17 @@ void ForOfStatement::Dump(ir::AstDumper *dumper) const void ForOfStatement::Compile(compiler::PandaGen *pg) const { - compiler::LocalRegScope declRegScope(pg, scope_->DeclScope()->InitScope()); + compiler::LocalRegScope regScope(pg, scope_); - right_->Compile(pg); + if (scope_->NeedLexEnv()) { + pg->NewLexEnv(this, scope_->LexicalSlots()); + } + + right_->Compile(pg); // if poplexenv next, acc will not be affected, no need to store the value to a vreg + + if (scope_->NeedLexEnv()) { + pg->PopLexEnv(this); + } compiler::LabelTarget labelTarget(pg); auto iterator_type = isAwait_ ? compiler::IteratorType::ASYNC : compiler::IteratorType::SYNC; @@ -60,14 +68,12 @@ void ForOfStatement::Compile(compiler::PandaGen *pg) const pg->StoreAccumulator(this, value); auto lref = compiler::LReference::CreateLRef(pg, left_, false); - { compiler::IteratorContext forOfCtx(pg, iterator, labelTarget); + compiler::LoopEnvScope envScope(pg, scope_, {}); pg->LoadAccumulator(this, value); lref.SetValue(); - compiler::LoopEnvScope declEnvScope(pg, scope_->DeclScope()); - compiler::LoopEnvScope envScope(pg, scope_, {}); body_->Compile(pg); } @@ -83,11 +89,10 @@ checker::Type *ForOfStatement::Check([[maybe_unused]] checker::Checker *checker) void ForOfStatement::UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) { auto *loopScope = Scope(); - auto declScopeCtx = binder::LexicalScope::Enter(binder, loopScope->DeclScope()); + auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); left_ = std::get(cb(left_)); right_ = std::get(cb(right_))->AsExpression(); - auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); body_ = std::get(cb(body_))->AsStatement(); } diff --git a/es2panda/ir/statements/forUpdateStatement.cpp b/es2panda/ir/statements/forUpdateStatement.cpp index d6275d9817..278cf6a1e2 100644 --- a/es2panda/ir/statements/forUpdateStatement.cpp +++ b/es2panda/ir/statements/forUpdateStatement.cpp @@ -54,7 +54,9 @@ void ForUpdateStatement::Dump(ir::AstDumper *dumper) const void ForUpdateStatement::Compile(compiler::PandaGen *pg) const { - compiler::LocalRegScope declRegScope(pg, scope_->DeclScope()->InitScope()); + compiler::LocalRegScope loopRegScope(pg, scope_); + compiler::LabelTarget labelTarget(pg); + compiler::LoopEnvScope envScope(pg, labelTarget, scope_); if (init_) { ASSERT(init_->IsVariableDeclaration() || init_->IsExpression()); @@ -62,22 +64,16 @@ void ForUpdateStatement::Compile(compiler::PandaGen *pg) const } auto *startLabel = pg->AllocLabel(); - compiler::LabelTarget labelTarget(pg); - - compiler::LoopEnvScope declEnvScope(pg, scope_->DeclScope()); - compiler::LoopEnvScope envScope(pg, labelTarget, scope_); pg->SetLabel(this, startLabel); { - compiler::LocalRegScope regScope(pg, scope_); - if (test_) { compiler::Condition::Compile(pg, test_, labelTarget.BreakTarget()); } body_->Compile(pg); pg->SetLabel(this, labelTarget.ContinueTarget()); - envScope.CopyPetIterationCtx(); + envScope.CopyPerIterationCtx(); } if (update_) { @@ -113,7 +109,7 @@ checker::Type *ForUpdateStatement::Check(checker::Checker *checker) const void ForUpdateStatement::UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) { auto *loopScope = Scope(); - auto declScopeCtx = binder::LexicalScope::Enter(binder, loopScope->DeclScope()); + auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); if (init_) { init_ = std::get(cb(init_)); @@ -123,8 +119,6 @@ void ForUpdateStatement::UpdateSelf(const NodeUpdater &cb, binder::Binder *binde test_ = std::get(cb(test_))->AsExpression(); } - auto loopCtx = binder::LexicalScope::Enter(binder, loopScope); - if (update_) { update_ = std::get(cb(update_))->AsExpression(); } diff --git a/es2panda/ir/statements/whileStatement.cpp b/es2panda/ir/statements/whileStatement.cpp index 0c5a09fb34..45d3d061a0 100644 --- a/es2panda/ir/statements/whileStatement.cpp +++ b/es2panda/ir/statements/whileStatement.cpp @@ -46,8 +46,7 @@ void WhileStatement::Compile(compiler::PandaGen *pg) const compiler::Condition::Compile(pg, test_, labelTarget.BreakTarget()); { - compiler::LocalRegScope regScope(pg, scope_); - compiler::LabelContext labelCtx(pg, labelTarget); + compiler::LoopEnvScope envScope(pg, labelTarget, scope_); body_->Compile(pg); } diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index f5c91da85a..3d8befe641 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -1356,7 +1356,7 @@ ir::Statement *ParserImpl::ParseForStatement() } lexer_->NextToken(); - auto declCtx = binder::LexicalScope(Binder()); + IterationContext iterCtx(&context_, Binder()); switch (lexer_->GetToken().Type()) { case lexer::TokenType::KEYW_VAR: { @@ -1388,9 +1388,6 @@ ir::Statement *ParserImpl::ParseForStatement() } } - IterationContext iterCtx(&context_, Binder()); - iterCtx.LexicalScope().GetScope()->BindDecls(declCtx.GetScope()); - if (initNode != nullptr) { if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_SEMI_COLON) { lexer_->NextToken(); @@ -1435,7 +1432,6 @@ ir::Statement *ParserImpl::ParseForStatement() forStatement->SetRange({startLoc, endLoc}); loopScope->BindNode(forStatement); - loopScope->DeclScope()->BindNode(forStatement); return forStatement; } diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt new file mode 100644 index 0000000000..41fc385ca1 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt @@ -0,0 +1,3 @@ +0 1,2,3 +1 1,2,3 +2 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js new file mode 100644 index 0000000000..361a247c80 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js @@ -0,0 +1,12 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i in a) { + b.push(() => { + print(i, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt new file mode 100644 index 0000000000..1daca51094 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt @@ -0,0 +1,3 @@ +1 1,2,3 +2 1,2,3 +3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js new file mode 100644 index 0000000000..d798a1468e --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js @@ -0,0 +1,13 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i in a) { + let j = a[i]; + b.push(() => { + print(j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt new file mode 100644 index 0000000000..fa374f0149 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt @@ -0,0 +1,3 @@ +0 1 1,2,3 +1 2 1,2,3 +2 3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js new file mode 100644 index 0000000000..fe18a4a31f --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js @@ -0,0 +1,13 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i in a) { + let j = a[i]; + b.push(() => { + print(i, j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt new file mode 100644 index 0000000000..1daca51094 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt @@ -0,0 +1,3 @@ +1 1,2,3 +2 1,2,3 +3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js new file mode 100644 index 0000000000..f115fa7c68 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js @@ -0,0 +1,12 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i of a) { + b.push(() => { + print(i, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt new file mode 100644 index 0000000000..1daca51094 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt @@ -0,0 +1,3 @@ +1 1,2,3 +2 1,2,3 +3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js new file mode 100644 index 0000000000..694cf733a9 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js @@ -0,0 +1,13 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i of a) { + let j = i; + b.push(() => { + print(j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt new file mode 100644 index 0000000000..d6d13b293e --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt @@ -0,0 +1,3 @@ +1 1 1,2,3 +2 2 1,2,3 +3 3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js new file mode 100644 index 0000000000..880231faf4 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js @@ -0,0 +1,13 @@ +{ + let a = [1, 2, 3]; + let b = []; + + for (let i of a) { + let j = i; + b.push(() => { + print(i, j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt new file mode 100644 index 0000000000..8aad39b4fa --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt @@ -0,0 +1,3 @@ +0 3 +1 3 +2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js new file mode 100644 index 0000000000..1ecaa67f07 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js @@ -0,0 +1,12 @@ +{ + let a = 3; + let b = []; + + for (let i = 0; i < a; i++) { + b.push(() => { + print(i, a); + }); + } + + b.forEach(f => f()); +} diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt new file mode 100644 index 0000000000..8aad39b4fa --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt @@ -0,0 +1,3 @@ +0 3 +1 3 +2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js new file mode 100644 index 0000000000..300d614298 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js @@ -0,0 +1,13 @@ +{ + let a = 3; + let b = []; + + for (let i = 0; i < a; i++) { + let j = i; + b.push(() => { + print(j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt new file mode 100644 index 0000000000..50297f767d --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt @@ -0,0 +1,3 @@ +0 0 3 +1 1 3 +2 2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js new file mode 100644 index 0000000000..3900005c58 --- /dev/null +++ b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js @@ -0,0 +1,13 @@ +{ + let a = 3; + let b = []; + + for (let i = 0; i < a; i++) { + let j = i; + b.push(() => { + print(i, j, a); + }); + } + + b.forEach(f => f()); +} \ No newline at end of file -- Gitee From 4b25f06df72b20e880e65d18feff06c9ea05d118 Mon Sep 17 00:00:00 2001 From: ctw-ian Date: Thu, 8 Dec 2022 10:26:17 +0800 Subject: [PATCH 2/2] Add test cases for lexical env Issue:I62YS7 Signed-off-by: ctw-ian Change-Id: I82be360d2ea3fb572c25be7cb77dc4df69c23a27 --- es2panda/compiler/core/dynamicContext.cpp | 4 ++ .../lexEnv/forIn-loopEnv-test-1-expected.txt | 3 -- .../js/lexEnv/forIn-loopEnv-test-1.js | 12 ----- .../lexEnv/forIn-loopEnv-test-2-expected.txt | 3 -- .../js/lexEnv/forIn-loopEnv-test-2.js | 13 ----- .../lexEnv/forIn-loopEnv-test-3-expected.txt | 3 -- .../js/lexEnv/forIn-loopEnv-test-3.js | 13 ----- .../lexEnv/forOf-loopEnv-test-1-expected.txt | 3 -- .../js/lexEnv/forOf-loopEnv-test-1.js | 12 ----- .../lexEnv/forOf-loopEnv-test-2-expected.txt | 3 -- .../js/lexEnv/forOf-loopEnv-test-2.js | 13 ----- .../lexEnv/forOf-loopEnv-test-3-expected.txt | 3 -- .../js/lexEnv/forOf-loopEnv-test-3.js | 13 ----- .../forUpdate-loopEnv-test-1-expected.txt | 3 -- .../js/lexEnv/forUpdate-loopEnv-test-1.js | 12 ----- .../forUpdate-loopEnv-test-2-expected.txt | 3 -- .../js/lexEnv/forUpdate-loopEnv-test-2.js | 13 ----- .../forUpdate-loopEnv-test-3-expected.txt | 3 -- .../js/lexEnv/forUpdate-loopEnv-test-3.js | 13 ----- ...ross-one-and-several-function-expected.txt | 2 + ...out-loop-cross-one-and-several-function.js | 34 +++++++++++++ ...thout-loop-cross-one-function-expected.txt | 1 + .../env-without-loop-cross-one-function.js | 25 ++++++++++ ...t-loop-cross-several-function-expected.txt | 1 + ...env-without-loop-cross-several-function.js | 33 ++++++++++++ ...r-update-body-decl-body-outer-expected.txt | 8 +++ .../for-update-body-decl-body-outer.js | 39 +++++++++++++++ .../for-update-body-decl-expected.txt | 4 ++ ...ate-body-decl-head-body-outer-expected.txt | 8 +++ .../for-update-body-decl-head-body-outer.js | 39 +++++++++++++++ ...r-update-body-decl-head-outer-expected.txt | 4 ++ .../for-update-body-decl-head-outer.js | 38 ++++++++++++++ .../js/lexicalEnv/for-update-body-decl.js | 30 +++++++++++ ...te-break-body-decl-body-outer-expected.txt | 6 +++ .../for-update-break-body-decl-body-outer.js | 44 ++++++++++++++++ .../for-update-break-body-decl-expected.txt | 2 + ...eak-body-decl-head-body-outer-expected.txt | 6 +++ ...-update-break-body-decl-head-body-outer.js | 44 ++++++++++++++++ ...te-break-body-decl-head-outer-expected.txt | 3 ++ .../for-update-break-body-decl-head-outer.js | 43 ++++++++++++++++ .../lexicalEnv/for-update-break-body-decl.js | 33 ++++++++++++ ...eak-head-body-decl-body-outer-expected.txt | 6 +++ ...-update-break-head-body-decl-body-outer.js | 44 ++++++++++++++++ ...r-update-break-head-body-decl-expected.txt | 2 + ...ead-body-decl-head-body-outer-expected.txt | 6 +++ ...te-break-head-body-decl-head-body-outer.js | 44 ++++++++++++++++ ...eak-head-body-decl-head-outer-expected.txt | 3 ++ ...-update-break-head-body-decl-head-outer.js | 43 ++++++++++++++++ .../for-update-break-head-body-decl.js | 33 ++++++++++++ ...te-break-head-decl-body-outer-expected.txt | 6 +++ .../for-update-break-head-decl-body-outer.js | 43 ++++++++++++++++ .../for-update-break-head-decl-expected.txt | 2 + ...eak-head-decl-head-body-outer-expected.txt | 6 +++ ...-update-break-head-decl-head-body-outer.js | 43 ++++++++++++++++ ...te-break-head-decl-head-outer-expected.txt | 3 ++ .../for-update-break-head-decl-head-outer.js | 42 ++++++++++++++++ .../lexicalEnv/for-update-break-head-decl.js | 33 ++++++++++++ ...date-break-return-body-decl-1-expected.txt | 2 + .../for-update-break-return-body-decl-1.js | 43 ++++++++++++++++ ...date-break-return-body-decl-2-expected.txt | 2 + .../for-update-break-return-body-decl-2.js | 43 ++++++++++++++++ ...return-body-decl-body-outer-1-expected.txt | 5 ++ ...ate-break-return-body-decl-body-outer-1.js | 47 +++++++++++++++++ ...return-body-decl-body-outer-2-expected.txt | 5 ++ ...ate-break-return-body-decl-body-outer-2.js | 47 +++++++++++++++++ ...n-body-decl-head-body-outer-1-expected.txt | 5 ++ ...reak-return-body-decl-head-body-outer-1.js | 46 +++++++++++++++++ ...n-body-decl-head-body-outer-2-expected.txt | 6 +++ ...reak-return-body-decl-head-body-outer-2.js | 48 ++++++++++++++++++ ...return-body-decl-head-outer-1-expected.txt | 3 ++ ...ate-break-return-body-decl-head-outer-1.js | 48 ++++++++++++++++++ ...return-body-decl-head-outer-2-expected.txt | 2 + ...ate-break-return-body-decl-head-outer-2.js | 46 +++++++++++++++++ ...break-return-head-body-decl-1-expected.txt | 2 + ...or-update-break-return-head-body-decl-1.js | 43 ++++++++++++++++ ...break-return-head-body-decl-2-expected.txt | 2 + ...or-update-break-return-head-body-decl-2.js | 43 ++++++++++++++++ ...n-head-body-decl-body-outer-1-expected.txt | 5 ++ ...reak-return-head-body-decl-body-outer-1.js | 47 +++++++++++++++++ ...n-head-body-decl-body-outer-2-expected.txt | 6 +++ ...reak-return-head-body-decl-body-outer-2.js | 49 ++++++++++++++++++ ...d-body-decl-head-body-outer-1-expected.txt | 5 ++ ...return-head-body-decl-head-body-outer-1.js | 46 +++++++++++++++++ ...d-body-decl-head-body-outer-2-expected.txt | 6 +++ ...return-head-body-decl-head-body-outer-2.js | 48 ++++++++++++++++++ ...n-head-body-decl-head-outer-1-expected.txt | 3 ++ ...reak-return-head-body-decl-head-outer-1.js | 48 ++++++++++++++++++ ...n-head-body-decl-head-outer-2-expected.txt | 3 ++ ...reak-return-head-body-decl-head-outer-2.js | 48 ++++++++++++++++++ ...date-break-return-head-decl-1-expected.txt | 2 + .../for-update-break-return-head-decl-1.js | 42 ++++++++++++++++ ...date-break-return-head-decl-2-expected.txt | 2 + .../for-update-break-return-head-decl-2.js | 42 ++++++++++++++++ ...return-head-decl-body-outer-1-expected.txt | 6 +++ ...ate-break-return-head-decl-body-outer-1.js | 48 ++++++++++++++++++ ...return-head-decl-body-outer-2-expected.txt | 5 ++ ...ate-break-return-head-decl-body-outer-2.js | 46 +++++++++++++++++ ...n-head-decl-head-body-outer-1-expected.txt | 5 ++ ...reak-return-head-decl-head-body-outer-1.js | 46 +++++++++++++++++ ...n-head-decl-head-body-outer-2-expected.txt | 5 ++ ...reak-return-head-decl-head-body-outer-2.js | 46 +++++++++++++++++ ...return-head-decl-head-outer-1-expected.txt | 3 ++ ...ate-break-return-head-decl-head-outer-1.js | 47 +++++++++++++++++ ...return-head-decl-head-outer-2-expected.txt | 2 + ...ate-break-return-head-decl-head-outer-2.js | 45 +++++++++++++++++ ...continue-body-decl-body-outer-expected.txt | 8 +++ ...or-update-continue-body-decl-body-outer.js | 44 ++++++++++++++++ ...for-update-continue-body-decl-expected.txt | 3 ++ ...nue-body-decl-head-body-outer-expected.txt | 8 +++ ...date-continue-body-decl-head-body-outer.js | 44 ++++++++++++++++ ...continue-body-decl-head-outer-expected.txt | 4 ++ ...or-update-continue-body-decl-head-outer.js | 43 ++++++++++++++++ .../for-update-continue-body-decl.js | 33 ++++++++++++ ...ue-break-body-decl-body-outer-expected.txt | 9 ++++ ...ate-continue-break-body-decl-body-outer.js | 49 ++++++++++++++++++ ...date-continue-break-body-decl-expected.txt | 3 ++ ...eak-body-decl-head-body-outer-expected.txt | 9 ++++ ...ontinue-break-body-decl-head-body-outer.js | 49 ++++++++++++++++++ ...ue-break-body-decl-head-outer-expected.txt | 4 ++ ...ate-continue-break-body-decl-head-outer.js | 48 ++++++++++++++++++ .../for-update-continue-break-body-decl.js | 38 ++++++++++++++ ...eak-head-body-decl-body-outer-expected.txt | 9 ++++ ...ontinue-break-head-body-decl-body-outer.js | 49 ++++++++++++++++++ ...continue-break-head-body-decl-expected.txt | 3 ++ ...ead-body-decl-head-body-outer-expected.txt | 9 ++++ ...ue-break-head-body-decl-head-body-outer.js | 49 ++++++++++++++++++ ...eak-head-body-decl-head-outer-expected.txt | 4 ++ ...ontinue-break-head-body-decl-head-outer.js | 48 ++++++++++++++++++ ...or-update-continue-break-head-body-decl.js | 38 ++++++++++++++ ...ue-break-head-decl-body-outer-expected.txt | 9 ++++ ...ate-continue-break-head-decl-body-outer.js | 48 ++++++++++++++++++ ...date-continue-break-head-decl-expected.txt | 3 ++ ...eak-head-decl-head-body-outer-expected.txt | 9 ++++ ...ontinue-break-head-decl-head-body-outer.js | 48 ++++++++++++++++++ ...ue-break-head-decl-head-outer-expected.txt | 4 ++ ...ate-continue-break-head-decl-head-outer.js | 47 +++++++++++++++++ .../for-update-continue-break-head-decl.js | 37 ++++++++++++++ ...inue-break-return-body-decl-1-expected.txt | 2 + ...pdate-continue-break-return-body-decl-1.js | 48 ++++++++++++++++++ ...inue-break-return-body-decl-2-expected.txt | 2 + ...pdate-continue-break-return-body-decl-2.js | 48 ++++++++++++++++++ ...inue-break-return-body-decl-3-expected.txt | 1 + ...pdate-continue-break-return-body-decl-3.js | 48 ++++++++++++++++++ ...inue-break-return-body-decl-4-expected.txt | 1 + ...pdate-continue-break-return-body-decl-4.js | 48 ++++++++++++++++++ ...inue-break-return-body-decl-5-expected.txt | 1 + ...pdate-continue-break-return-body-decl-5.js | 48 ++++++++++++++++++ ...inue-break-return-body-decl-6-expected.txt | 1 + ...pdate-continue-break-return-body-decl-6.js | 48 ++++++++++++++++++ ...return-body-decl-body-outer-1-expected.txt | 6 +++ ...nue-break-return-body-decl-body-outer-1.js | 50 +++++++++++++++++++ ...return-body-decl-body-outer-2-expected.txt | 6 +++ ...nue-break-return-body-decl-body-outer-2.js | 50 +++++++++++++++++++ ...return-body-decl-body-outer-3-expected.txt | 3 ++ ...nue-break-return-body-decl-body-outer-3.js | 50 +++++++++++++++++++ ...return-body-decl-body-outer-4-expected.txt | 3 ++ ...nue-break-return-body-decl-body-outer-4.js | 50 +++++++++++++++++++ ...return-body-decl-body-outer-5-expected.txt | 3 ++ ...nue-break-return-body-decl-body-outer-5.js | 50 +++++++++++++++++++ ...return-body-decl-body-outer-6-expected.txt | 3 ++ ...nue-break-return-body-decl-body-outer-6.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-1-expected.txt | 6 +++ ...reak-return-body-decl-head-body-outer-1.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-2-expected.txt | 6 +++ ...reak-return-body-decl-head-body-outer-2.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-3-expected.txt | 3 ++ ...reak-return-body-decl-head-body-outer-3.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-4-expected.txt | 3 ++ ...reak-return-body-decl-head-body-outer-4.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-5-expected.txt | 3 ++ ...reak-return-body-decl-head-body-outer-5.js | 50 +++++++++++++++++++ ...n-body-decl-head-body-outer-6-expected.txt | 3 ++ ...reak-return-body-decl-head-body-outer-6.js | 50 +++++++++++++++++++ ...return-body-decl-head-outer-1-expected.txt | 2 + ...nue-break-return-body-decl-head-outer-1.js | 49 ++++++++++++++++++ ...return-body-decl-head-outer-2-expected.txt | 2 + ...nue-break-return-body-decl-head-outer-2.js | 49 ++++++++++++++++++ ...return-body-decl-head-outer-3-expected.txt | 1 + ...nue-break-return-body-decl-head-outer-3.js | 49 ++++++++++++++++++ ...return-body-decl-head-outer-4-expected.txt | 1 + ...nue-break-return-body-decl-head-outer-4.js | 49 ++++++++++++++++++ ...return-body-decl-head-outer-5-expected.txt | 1 + ...nue-break-return-body-decl-head-outer-5.js | 49 ++++++++++++++++++ ...return-body-decl-head-outer-6-expected.txt | 1 + ...nue-break-return-body-decl-head-outer-6.js | 49 ++++++++++++++++++ ...break-return-head-body-decl-1-expected.txt | 2 + ...-continue-break-return-head-body-decl-1.js | 48 ++++++++++++++++++ ...break-return-head-body-decl-2-expected.txt | 2 + ...-continue-break-return-head-body-decl-2.js | 48 ++++++++++++++++++ ...break-return-head-body-decl-3-expected.txt | 1 + ...-continue-break-return-head-body-decl-3.js | 48 ++++++++++++++++++ ...break-return-head-body-decl-4-expected.txt | 1 + ...-continue-break-return-head-body-decl-4.js | 48 ++++++++++++++++++ ...break-return-head-body-decl-5-expected.txt | 1 + ...-continue-break-return-head-body-decl-5.js | 48 ++++++++++++++++++ ...break-return-head-body-decl-6-expected.txt | 1 + ...-continue-break-return-head-body-decl-6.js | 48 ++++++++++++++++++ ...n-head-body-decl-body-outer-1-expected.txt | 6 +++ ...reak-return-head-body-decl-body-outer-1.js | 50 +++++++++++++++++++ ...n-head-body-decl-body-outer-2-expected.txt | 6 +++ ...reak-return-head-body-decl-body-outer-2.js | 50 +++++++++++++++++++ ...n-head-body-decl-body-outer-3-expected.txt | 3 ++ ...reak-return-head-body-decl-body-outer-3.js | 50 +++++++++++++++++++ ...n-head-body-decl-body-outer-4-expected.txt | 3 ++ ...reak-return-head-body-decl-body-outer-4.js | 50 +++++++++++++++++++ ...n-head-body-decl-body-outer-5-expected.txt | 3 ++ ...reak-return-head-body-decl-body-outer-5.js | 50 +++++++++++++++++++ ...n-head-body-decl-body-outer-6-expected.txt | 3 ++ ...reak-return-head-body-decl-body-outer-6.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-1-expected.txt | 6 +++ ...return-head-body-decl-head-body-outer-1.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-2-expected.txt | 6 +++ ...return-head-body-decl-head-body-outer-2.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-3-expected.txt | 3 ++ ...return-head-body-decl-head-body-outer-3.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-4-expected.txt | 3 ++ ...return-head-body-decl-head-body-outer-4.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-5-expected.txt | 3 ++ ...return-head-body-decl-head-body-outer-5.js | 50 +++++++++++++++++++ ...d-body-decl-head-body-outer-6-expected.txt | 3 ++ ...return-head-body-decl-head-body-outer-6.js | 50 +++++++++++++++++++ ...n-head-body-decl-head-outer-1-expected.txt | 2 + ...reak-return-head-body-decl-head-outer-1.js | 49 ++++++++++++++++++ ...n-head-body-decl-head-outer-2-expected.txt | 2 + ...reak-return-head-body-decl-head-outer-2.js | 49 ++++++++++++++++++ ...n-head-body-decl-head-outer-3-expected.txt | 1 + ...reak-return-head-body-decl-head-outer-3.js | 49 ++++++++++++++++++ ...n-head-body-decl-head-outer-4-expected.txt | 1 + ...reak-return-head-body-decl-head-outer-4.js | 49 ++++++++++++++++++ ...n-head-body-decl-head-outer-5-expected.txt | 1 + ...reak-return-head-body-decl-head-outer-5.js | 49 ++++++++++++++++++ ...n-head-body-decl-head-outer-6-expected.txt | 1 + ...reak-return-head-body-decl-head-outer-6.js | 49 ++++++++++++++++++ ...inue-break-return-head-decl-1-expected.txt | 2 + ...pdate-continue-break-return-head-decl-1.js | 47 +++++++++++++++++ ...inue-break-return-head-decl-2-expected.txt | 2 + ...pdate-continue-break-return-head-decl-2.js | 47 +++++++++++++++++ ...inue-break-return-head-decl-3-expected.txt | 1 + ...pdate-continue-break-return-head-decl-3.js | 47 +++++++++++++++++ ...inue-break-return-head-decl-4-expected.txt | 1 + ...pdate-continue-break-return-head-decl-4.js | 47 +++++++++++++++++ ...inue-break-return-head-decl-5-expected.txt | 1 + ...pdate-continue-break-return-head-decl-5.js | 47 +++++++++++++++++ ...inue-break-return-head-decl-6-expected.txt | 1 + ...pdate-continue-break-return-head-decl-6.js | 47 +++++++++++++++++ ...return-head-decl-body-outer-1-expected.txt | 6 +++ ...nue-break-return-head-decl-body-outer-1.js | 49 ++++++++++++++++++ ...return-head-decl-body-outer-2-expected.txt | 6 +++ ...nue-break-return-head-decl-body-outer-2.js | 49 ++++++++++++++++++ ...return-head-decl-body-outer-3-expected.txt | 3 ++ ...nue-break-return-head-decl-body-outer-3.js | 49 ++++++++++++++++++ ...return-head-decl-body-outer-4-expected.txt | 3 ++ ...nue-break-return-head-decl-body-outer-4.js | 49 ++++++++++++++++++ ...return-head-decl-body-outer-5-expected.txt | 3 ++ ...nue-break-return-head-decl-body-outer-5.js | 49 ++++++++++++++++++ ...return-head-decl-body-outer-6-expected.txt | 3 ++ ...nue-break-return-head-decl-body-outer-6.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-1-expected.txt | 6 +++ ...reak-return-head-decl-head-body-outer-1.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-2-expected.txt | 6 +++ ...reak-return-head-decl-head-body-outer-2.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-3-expected.txt | 3 ++ ...reak-return-head-decl-head-body-outer-3.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-4-expected.txt | 3 ++ ...reak-return-head-decl-head-body-outer-4.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-5-expected.txt | 3 ++ ...reak-return-head-decl-head-body-outer-5.js | 49 ++++++++++++++++++ ...n-head-decl-head-body-outer-6-expected.txt | 3 ++ ...reak-return-head-decl-head-body-outer-6.js | 49 ++++++++++++++++++ ...return-head-decl-head-outer-1-expected.txt | 2 + ...nue-break-return-head-decl-head-outer-1.js | 48 ++++++++++++++++++ ...return-head-decl-head-outer-2-expected.txt | 2 + ...nue-break-return-head-decl-head-outer-2.js | 48 ++++++++++++++++++ ...return-head-decl-head-outer-3-expected.txt | 1 + ...nue-break-return-head-decl-head-outer-3.js | 48 ++++++++++++++++++ ...return-head-decl-head-outer-4-expected.txt | 1 + ...nue-break-return-head-decl-head-outer-4.js | 48 ++++++++++++++++++ ...return-head-decl-head-outer-5-expected.txt | 1 + ...nue-break-return-head-decl-head-outer-5.js | 48 ++++++++++++++++++ ...return-head-decl-head-outer-6-expected.txt | 1 + ...nue-break-return-head-decl-head-outer-6.js | 48 ++++++++++++++++++ ...nue-head-body-decl-body-outer-expected.txt | 8 +++ ...date-continue-head-body-decl-body-outer.js | 44 ++++++++++++++++ ...pdate-continue-head-body-decl-expected.txt | 3 ++ ...nue-head-body-decl-head-outer-expected.txt | 4 ++ ...date-continue-head-body-decl-head-outer.js | 43 ++++++++++++++++ .../for-update-continue-head-body-decl.js | 33 ++++++++++++ ...continue-head-decl-body-outer-expected.txt | 8 +++ ...or-update-continue-head-decl-body-outer.js | 43 ++++++++++++++++ ...for-update-continue-head-decl-expected.txt | 3 ++ ...nue-head-decl-head-body-outer-expected.txt | 8 +++ ...date-continue-head-decl-head-body-outer.js | 43 ++++++++++++++++ ...continue-head-decl-head-outer-expected.txt | 4 ++ ...or-update-continue-head-decl-head-outer.js | 42 ++++++++++++++++ .../for-update-continue-head-decl.js | 33 ++++++++++++ ...e-return-body-decl-body-outer-expected.txt | 8 +++ ...te-continue-return-body-decl-body-outer.js | 46 +++++++++++++++++ ...ate-continue-return-body-decl-expected.txt | 3 ++ ...urn-body-decl-head-body-outer-expected.txt | 8 +++ ...ntinue-return-body-decl-head-body-outer.js | 46 +++++++++++++++++ ...e-return-body-decl-head-outer-expected.txt | 3 ++ ...te-continue-return-body-decl-head-outer.js | 43 ++++++++++++++++ .../for-update-continue-return-body-decl.js | 43 ++++++++++++++++ ...urn-head-body-decl-body-outer-expected.txt | 8 +++ ...ntinue-return-head-body-decl-body-outer.js | 46 +++++++++++++++++ ...ontinue-return-head-body-decl-expected.txt | 3 ++ ...ead-body-decl-head-body-outer-expected.txt | 8 +++ ...e-return-head-body-decl-head-body-outer.js | 46 +++++++++++++++++ ...urn-head-body-decl-head-outer-expected.txt | 3 ++ ...ntinue-return-head-body-decl-head-outer.js | 43 ++++++++++++++++ ...r-update-continue-return-head-body-decl.js | 43 ++++++++++++++++ ...e-return-head-decl-body-outer-expected.txt | 8 +++ ...te-continue-return-head-decl-body-outer.js | 45 +++++++++++++++++ ...ate-continue-return-head-decl-expected.txt | 3 ++ ...urn-head-decl-head-body-outer-expected.txt | 8 +++ ...ntinue-return-head-decl-head-body-outer.js | 45 +++++++++++++++++ ...e-return-head-decl-head-outer-expected.txt | 3 ++ ...te-continue-return-head-decl-head-outer.js | 44 ++++++++++++++++ .../for-update-continue-return-head-decl.js | 42 ++++++++++++++++ ...ate-head-body-decl-body-outer-expected.txt | 8 +++ .../for-update-head-body-decl-body-outer.js | 39 +++++++++++++++ .../for-update-head-body-decl-expected.txt | 4 ++ ...ead-body-decl-head-body-outer-expected.txt | 8 +++ ...r-update-head-body-decl-head-body-outer.js | 39 +++++++++++++++ ...ate-head-body-decl-head-outer-expected.txt | 4 ++ .../for-update-head-body-decl-head-outer.js | 38 ++++++++++++++ .../lexicalEnv/for-update-head-body-decl.js | 30 +++++++++++ ...nue-body-decl-head-body-outer-expected.txt | 8 +++ ...head-continue-body-decl-head-body-outer.js | 44 ++++++++++++++++ ...r-update-head-decl-body-outer-expected.txt | 8 +++ .../for-update-head-decl-body-outer.js | 38 ++++++++++++++ .../for-update-head-decl-expected.txt | 4 ++ ...ate-head-decl-head-body-outer-expected.txt | 8 +++ .../for-update-head-decl-head-body-outer.js | 38 ++++++++++++++ ...r-update-head-decl-head-outer-expected.txt | 4 ++ .../for-update-head-decl-head-outer.js | 37 ++++++++++++++ .../js/lexicalEnv/for-update-head-decl.js | 29 +++++++++++ ...e-return-body-decl-body-outer-expected.txt | 5 ++ .../for-update-return-body-decl-body-outer.js | 42 ++++++++++++++++ .../for-update-return-body-decl-expected.txt | 2 + ...urn-body-decl-head-body-outer-expected.txt | 5 ++ ...update-return-body-decl-head-body-outer.js | 42 ++++++++++++++++ ...e-return-body-decl-head-outer-expected.txt | 2 + .../for-update-return-body-decl-head-outer.js | 41 +++++++++++++++ .../lexicalEnv/for-update-return-body-decl.js | 38 ++++++++++++++ ...urn-head-body-decl-body-outer-expected.txt | 5 ++ ...update-return-head-body-decl-body-outer.js | 42 ++++++++++++++++ ...-update-return-head-body-decl-expected.txt | 2 + ...ead-body-decl-head-body-outer-expected.txt | 5 ++ ...e-return-head-body-decl-head-body-outer.js | 42 ++++++++++++++++ ...urn-head-body-decl-head-outer-expected.txt | 2 + ...update-return-head-body-decl-head-outer.js | 41 +++++++++++++++ .../for-update-return-head-body-decl.js | 38 ++++++++++++++ ...e-return-head-decl-body-outer-expected.txt | 5 ++ .../for-update-return-head-decl-body-outer.js | 41 +++++++++++++++ .../for-update-return-head-decl-expected.txt | 2 + ...urn-head-decl-head-body-outer-expected.txt | 5 ++ ...update-return-head-decl-head-body-outer.js | 41 +++++++++++++++ ...e-return-head-decl-head-outer-expected.txt | 2 + .../for-update-return-head-decl-head-outer.js | 40 +++++++++++++++ .../lexicalEnv/for-update-return-head-decl.js | 37 ++++++++++++++ 361 files changed, 8360 insertions(+), 141 deletions(-) delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt delete mode 100644 es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-head-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer-expected.txt create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer.js create mode 100644 es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl.js diff --git a/es2panda/compiler/core/dynamicContext.cpp b/es2panda/compiler/core/dynamicContext.cpp index 1dab58cece..d6319c6a15 100644 --- a/es2panda/compiler/core/dynamicContext.cpp +++ b/es2panda/compiler/core/dynamicContext.cpp @@ -99,6 +99,10 @@ void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, } const auto *node = envScope_->Scope()->Node(); + if (node->IsForUpdateStatement()) { + return; + } + pg_->PopLexEnv(node); } diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt deleted file mode 100644 index 41fc385ca1..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 1,2,3 -1 1,2,3 -2 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js deleted file mode 100644 index 361a247c80..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-1.js +++ /dev/null @@ -1,12 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i in a) { - b.push(() => { - print(i, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt deleted file mode 100644 index 1daca51094..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 1,2,3 -2 1,2,3 -3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js deleted file mode 100644 index d798a1468e..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-2.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i in a) { - let j = a[i]; - b.push(() => { - print(j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt deleted file mode 100644 index fa374f0149..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 1 1,2,3 -1 2 1,2,3 -2 3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js deleted file mode 100644 index fe18a4a31f..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forIn-loopEnv-test-3.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i in a) { - let j = a[i]; - b.push(() => { - print(i, j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt deleted file mode 100644 index 1daca51094..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 1,2,3 -2 1,2,3 -3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js deleted file mode 100644 index f115fa7c68..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-1.js +++ /dev/null @@ -1,12 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i of a) { - b.push(() => { - print(i, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt deleted file mode 100644 index 1daca51094..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 1,2,3 -2 1,2,3 -3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js deleted file mode 100644 index 694cf733a9..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-2.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i of a) { - let j = i; - b.push(() => { - print(j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt deleted file mode 100644 index d6d13b293e..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 1 1,2,3 -2 2 1,2,3 -3 3 1,2,3 diff --git a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js deleted file mode 100644 index 880231faf4..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forOf-loopEnv-test-3.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = [1, 2, 3]; - let b = []; - - for (let i of a) { - let j = i; - b.push(() => { - print(i, j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt deleted file mode 100644 index 8aad39b4fa..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 3 -1 3 -2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js deleted file mode 100644 index 1ecaa67f07..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-1.js +++ /dev/null @@ -1,12 +0,0 @@ -{ - let a = 3; - let b = []; - - for (let i = 0; i < a; i++) { - b.push(() => { - print(i, a); - }); - } - - b.forEach(f => f()); -} diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt deleted file mode 100644 index 8aad39b4fa..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 3 -1 3 -2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js deleted file mode 100644 index 300d614298..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-2.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = 3; - let b = []; - - for (let i = 0; i < a; i++) { - let j = i; - b.push(() => { - print(j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt deleted file mode 100644 index 50297f767d..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -0 0 3 -1 1 3 -2 2 3 diff --git a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js b/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js deleted file mode 100644 index 3900005c58..0000000000 --- a/es2panda/test/compiler/js/lexEnv/forUpdate-loopEnv-test-3.js +++ /dev/null @@ -1,13 +0,0 @@ -{ - let a = 3; - let b = []; - - for (let i = 0; i < a; i++) { - let j = i; - b.push(() => { - print(i, j, a); - }); - } - - b.forEach(f => f()); -} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function-expected.txt b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function-expected.txt new file mode 100644 index 0000000000..6ed281c757 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function-expected.txt @@ -0,0 +1,2 @@ +1 +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function.js b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function.js new file mode 100644 index 0000000000..22cd25225b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-and-several-function.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// a is function lexical +{ + let a = 1; + + function b() { + print(a); + function c() { + function d() { + print(a); + } + + d(); + } + + c(); + } + + b(); +} diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function-expected.txt b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function.js b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function.js new file mode 100644 index 0000000000..d663411961 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-one-function.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// a is function lexical +{ + let a = 1; + + function b() { + print(a); + } + + b(); +} diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function-expected.txt b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function.js b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function.js new file mode 100644 index 0000000000..13107c6f97 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/env-without-loop-cross-several-function.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// a is function lexical +{ + let a = 1; + + function b() { + function c() { + function d() { + print(a); + } + + d(); + } + + c(); + } + + b(); +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..e280c527f6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer.js new file mode 100644 index 0000000000..6b194b46ca --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-body-outer.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-expected.txt new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..e280c527f6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer.js new file mode 100644 index 0000000000..c9a67812fb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-body-outer.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer.js new file mode 100644 index 0000000000..ccb1f199d0 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl-head-outer.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl.js new file mode 100644 index 0000000000..1cad6f9cd2 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-body-decl.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..ce6a369b50 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer.js new file mode 100644 index 0000000000..7a0e9364af --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..ce6a369b50 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer.js new file mode 100644 index 0000000000..d84a9be94b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..671e48f1f4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer.js new file mode 100644 index 0000000000..a92953ce2b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl.js new file mode 100644 index 0000000000..dca0810884 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-body-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..ac28118444 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer.js new file mode 100644 index 0000000000..eec15190e7 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-expected.txt new file mode 100644 index 0000000000..534fb831b5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-expected.txt @@ -0,0 +1,2 @@ +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..ac28118444 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer.js new file mode 100644 index 0000000000..3e970ea8c1 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..ac2fc4bf0c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 5: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer.js new file mode 100644 index 0000000000..36d0ababb5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl.js new file mode 100644 index 0000000000..0807cb1666 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-body-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..ce6a369b50 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer.js new file mode 100644 index 0000000000..447fe66ee8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-body-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..ce6a369b50 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer.js new file mode 100644 index 0000000000..06a0ddaaec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-body-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ + { + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + break; + } + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..671e48f1f4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer.js new file mode 100644 index 0000000000..80d5f71b40 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl-head-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ + { + let a = []; + let len = 5; + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl.js new file mode 100644 index 0000000000..47c34a75a3 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-head-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1.js new file mode 100644 index 0000000000..d9fca4e80f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2.js new file mode 100644 index 0000000000..863f8b677b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-2.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1.js new file mode 100644 index 0000000000..3f0fbcef83 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2.js new file mode 100644 index 0000000000..a825df1fe2 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-body-outer-2.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ + { + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1.js new file mode 100644 index 0000000000..04acdfd227 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ + { + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..912274f45b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2.js new file mode 100644 index 0000000000..dde53b6474 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-body-outer-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..7947443deb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1.js new file mode 100644 index 0000000000..fa40363ce4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ + { + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2.js new file mode 100644 index 0000000000..823e60b314 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-body-decl-head-outer-2.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ + { + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1-expected.txt new file mode 100644 index 0000000000..534fb831b5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1.js new file mode 100644 index 0000000000..ae57cb37ba --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2-expected.txt new file mode 100644 index 0000000000..534fb831b5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2.js new file mode 100644 index 0000000000..d6e2319fbd --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-2.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..e3bf9bc425 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1.js new file mode 100644 index 0000000000..eb221e9243 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..0ca7a62673 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2.js new file mode 100644 index 0000000000..8a7fcb62b6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-body-outer-2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..e3bf9bc425 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1.js new file mode 100644 index 0000000000..191cf8e4c7 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..0ca7a62673 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2.js new file mode 100644 index 0000000000..df28c43cc5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-body-outer-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..f6beed8606 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1.js new file mode 100644 index 0000000000..ee08c3f588 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..f6beed8606 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 6: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2.js new file mode 100644 index 0000000000..91356a65b8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-body-decl-head-outer-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + print("check exit loop, len == 6: ", len == 6); + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1.js new file mode 100644 index 0000000000..b0427c12f2 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-1.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2.js new file mode 100644 index 0000000000..bf028d9a5f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-2.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..912274f45b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1.js new file mode 100644 index 0000000000..b027c4b56a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2.js new file mode 100644 index 0000000000..6ac8c32540 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-body-outer-2.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1.js new file mode 100644 index 0000000000..a82095f568 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..d9c07d9071 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2.js new file mode 100644 index 0000000000..e0f686312f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-body-outer-2.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..7947443deb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1-expected.txt @@ -0,0 +1,3 @@ +check exit loop, len == 6: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1.js new file mode 100644 index 0000000000..7b01cbf4de --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 3) { + break; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2.js new file mode 100644 index 0000000000..000c21eaf4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-break-return-head-decl-head-outer-2.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 3) { + return a; + } + + if (i == 5) { + break; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..045ccf37ce --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer.js new file mode 100644 index 0000000000..ab954b0795 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..045ccf37ce --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer.js new file mode 100644 index 0000000000..3c33209a8d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..0f2e5bfb0c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer.js new file mode 100644 index 0000000000..276f16ed2f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl.js new file mode 100644 index 0000000000..92155d019c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-body-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..c7bd6e9afb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer.js new file mode 100644 index 0000000000..ccf429d616 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-body-outer.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..c7bd6e9afb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer.js new file mode 100644 index 0000000000..0bf2cfbdd5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-body-outer.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..5bebbfe3d4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer.js new file mode 100644 index 0000000000..da3bae26e8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl-head-outer.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl.js new file mode 100644 index 0000000000..1e74b8d1cf --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-body-decl.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..02f12392d5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer.js new file mode 100644 index 0000000000..d78e862811 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-body-outer.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-expected.txt new file mode 100644 index 0000000000..7a56ba29c0 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..02f12392d5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer.js new file mode 100644 index 0000000000..093a380583 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-body-outer.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..c6752cbe12 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 6: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer.js new file mode 100644 index 0000000000..f89f1d7be9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl-head-outer.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ + { + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl.js new file mode 100644 index 0000000000..eefb3370b4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-body-decl.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..c7bd6e9afb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer.js new file mode 100644 index 0000000000..912541fe4b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-body-outer.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..c7bd6e9afb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer-expected.txt @@ -0,0 +1,9 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer.js new file mode 100644 index 0000000000..be566a397b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-body-outer.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..5bebbfe3d4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer.js new file mode 100644 index 0000000000..55264468fc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl-head-outer.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 6; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 6: ", len == 6); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl.js new file mode 100644 index 0000000000..4e561112f5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-head-decl.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + if (i == 5) { + break; + } + + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1.js new file mode 100644 index 0000000000..06c1545059 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2.js new file mode 100644 index 0000000000..170d2fea4b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3.js new file mode 100644 index 0000000000..aac61eab3e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-3.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4.js new file mode 100644 index 0000000000..da30094e9f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-4.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5.js new file mode 100644 index 0000000000..8f61a3b85a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-5.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6.js new file mode 100644 index 0000000000..159fd803d3 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-6.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1.js new file mode 100644 index 0000000000..26b8b3eb59 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-1.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2.js new file mode 100644 index 0000000000..d704c3283d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-2.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3.js new file mode 100644 index 0000000000..0a292fc8a2 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-3.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4.js new file mode 100644 index 0000000000..daaf469cff --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-4.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5.js new file mode 100644 index 0000000000..63011b8328 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-5.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6.js new file mode 100644 index 0000000000..3cedf5d460 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-body-outer-6.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1.js new file mode 100644 index 0000000000..7d7e85b94d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-1.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2.js new file mode 100644 index 0000000000..cee0c161db --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-2.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3.js new file mode 100644 index 0000000000..04dda537f5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-3.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4.js new file mode 100644 index 0000000000..7a8f1e3290 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-4.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5.js new file mode 100644 index 0000000000..865765137a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-5.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6.js new file mode 100644 index 0000000000..74939d7b3a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-body-outer-6.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1.js new file mode 100644 index 0000000000..400c5d3323 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-1.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2.js new file mode 100644 index 0000000000..137a1190bb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3.js new file mode 100644 index 0000000000..2196b59f00 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-3.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4.js new file mode 100644 index 0000000000..916faf692a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-4.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5.js new file mode 100644 index 0000000000..ffc2b0e750 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-5.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6.js new file mode 100644 index 0000000000..5b56e5f050 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-body-decl-head-outer-6.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1-expected.txt new file mode 100644 index 0000000000..656ae9041f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1.js new file mode 100644 index 0000000000..d0848e01fe --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2-expected.txt new file mode 100644 index 0000000000..656ae9041f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2.js new file mode 100644 index 0000000000..1600feb5c6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3.js new file mode 100644 index 0000000000..3628998885 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-3.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4.js new file mode 100644 index 0000000000..4db6aa0cf9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-4.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5.js new file mode 100644 index 0000000000..59349985bf --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-5.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6.js new file mode 100644 index 0000000000..3936ef1fd8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-6.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..4c09a4bd9f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1.js new file mode 100644 index 0000000000..6d978db458 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-1.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..4c09a4bd9f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2.js new file mode 100644 index 0000000000..4453d4efe8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-2.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3.js new file mode 100644 index 0000000000..4436f81b21 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-3.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4.js new file mode 100644 index 0000000000..bebf48b8eb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-4.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5.js new file mode 100644 index 0000000000..60406bb2f2 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-5.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6.js new file mode 100644 index 0000000000..be55ab931a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-body-outer-6.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..4c09a4bd9f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1.js new file mode 100644 index 0000000000..f97f74c358 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-1.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..4c09a4bd9f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2.js new file mode 100644 index 0000000000..3a2a0df09d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-2.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3.js new file mode 100644 index 0000000000..3a42a45448 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-3.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4.js new file mode 100644 index 0000000000..ab7f76a425 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-4.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5.js new file mode 100644 index 0000000000..d7b66f65f8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-5.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6-expected.txt new file mode 100644 index 0000000000..e761ae95a8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6.js new file mode 100644 index 0000000000..7bbdcb3196 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-body-outer-6.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..656ae9041f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1-expected.txt @@ -0,0 +1,2 @@ +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1.js new file mode 100644 index 0000000000..1a00a09d05 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-1.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..656ae9041f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2-expected.txt @@ -0,0 +1,2 @@ +1 1 +3 3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2.js new file mode 100644 index 0000000000..5bd5899cc4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3.js new file mode 100644 index 0000000000..80b0028c5b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-3.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4.js new file mode 100644 index 0000000000..b78121dc40 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-4.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5.js new file mode 100644 index 0000000000..ac11b30d8f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-5.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6-expected.txt new file mode 100644 index 0000000000..2fb73a07ec --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6-expected.txt @@ -0,0 +1 @@ +1 1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6.js new file mode 100644 index 0000000000..cfd6a420de --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-body-decl-head-outer-6.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j && i are loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1.js new file mode 100644 index 0000000000..e1f4815aa5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2.js new file mode 100644 index 0000000000..626e41a70f --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-2.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3.js new file mode 100644 index 0000000000..1333d1902e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-3.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4.js new file mode 100644 index 0000000000..4efb0b4e24 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-4.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5.js new file mode 100644 index 0000000000..4d1e192cc4 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-5.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6.js new file mode 100644 index 0000000000..0ef287b218 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-6.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + */ +{ + function x() { + let a = []; + let len = 7; + for (let i = 1; i < len; i++) { + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1.js new file mode 100644 index 0000000000..b36314ed7b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-1.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2.js new file mode 100644 index 0000000000..5af0519034 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3.js new file mode 100644 index 0000000000..7e86fe4d05 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-3.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4.js new file mode 100644 index 0000000000..b5249d8da8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-4.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ + { + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5.js new file mode 100644 index 0000000000..dc1452f824 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-5.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ + { + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6.js new file mode 100644 index 0000000000..2b14054947 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-body-outer-6.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < 7; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1.js new file mode 100644 index 0000000000..027db81269 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-1.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2-expected.txt new file mode 100644 index 0000000000..c311fd39dc --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2-expected.txt @@ -0,0 +1,6 @@ +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +check enter loop len == 7: true +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2.js new file mode 100644 index 0000000000..f64dd3a4f7 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3.js new file mode 100644 index 0000000000..4f814a7415 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-3.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4.js new file mode 100644 index 0000000000..366b5e8afe --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-4.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5.js new file mode 100644 index 0000000000..57c37f94a7 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-5.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6-expected.txt new file mode 100644 index 0000000000..bf6b4becee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6-expected.txt @@ -0,0 +1,3 @@ +check enter loop len == 7: true +check enter loop len == 7: true +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6.js new file mode 100644 index 0000000000..adb9626069 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-body-outer-6.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop len == 7: ", len == 7); + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1.js new file mode 100644 index 0000000000..8677f50115 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + continue; + } + + if (i == 4) { + break; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2-expected.txt new file mode 100644 index 0000000000..2b2f2e1b92 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2-expected.txt @@ -0,0 +1,2 @@ +1 +3 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2.js new file mode 100644 index 0000000000..4782050984 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-2.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + continue; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3.js new file mode 100644 index 0000000000..8b2ba353da --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-3.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + break; + } + + if (i == 4) { + return a; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4.js new file mode 100644 index 0000000000..0d62dc8c50 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-4.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + break; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5.js new file mode 100644 index 0000000000..85585cfb98 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-5.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + return a; + } + + if (i == 4) { + continue; + } + + if (i == 6) { + break; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6-expected.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6-expected.txt @@ -0,0 +1 @@ +1 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6.js new file mode 100644 index 0000000000..a2215b2947 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-break-return-head-decl-head-outer-6.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 7; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 2) { + return a; + } + + if (i == 4) { + break; + } + + if (i == 6) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..ccebeb23a9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer.js new file mode 100644 index 0000000000..cc50768164 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-expected.txt new file mode 100644 index 0000000000..7a56ba29c0 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..b36399f9c9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 5: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer.js new file mode 100644 index 0000000000..c68d859b2d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl.js new file mode 100644 index 0000000000..d850a279cf --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-body-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..045ccf37ce --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer.js new file mode 100644 index 0000000000..f7dfb59897 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-body-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..045ccf37ce --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer.js new file mode 100644 index 0000000000..14febf7c6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-body-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..0f2e5bfb0c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +check exit loop, len == 5: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer.js new file mode 100644 index 0000000000..775f874bdb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl-head-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl.js new file mode 100644 index 0000000000..d4fa724172 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-head-decl.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..d1f6964a49 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer.js new file mode 100644 index 0000000000..e515cc88ee --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-body-outer.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..d1f6964a49 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer.js new file mode 100644 index 0000000000..055270bd23 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-body-outer.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer.js new file mode 100644 index 0000000000..44157331a3 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl.js new file mode 100644 index 0000000000..cdb0ed17d6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-body-decl.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..faed05e73e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer.js new file mode 100644 index 0000000000..f6b502c467 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-body-outer.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-expected.txt new file mode 100644 index 0000000000..7a56ba29c0 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-expected.txt @@ -0,0 +1,3 @@ +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..faed05e73e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer.js new file mode 100644 index 0000000000..b91e9105ae --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-body-outer.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..7a56ba29c0 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer.js new file mode 100644 index 0000000000..09ccb8d441 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl-head-outer.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl.js new file mode 100644 index 0000000000..229779b1c9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-body-decl.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..d1f6964a49 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer.js new file mode 100644 index 0000000000..1e6be4d415 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-body-outer.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < 6; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..d1f6964a49 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +check enter loop, len == 6: true +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer.js new file mode 100644 index 0000000000..89ddaf5dce --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-body-outer.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 6: ", len == 6); + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..e8a01cd985 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer-expected.txt @@ -0,0 +1,3 @@ +1 +2 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer.js new file mode 100644 index 0000000000..faa7efdc03 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl-head-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 6; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl.js new file mode 100644 index 0000000000..024f602d20 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-continue-return-head-decl.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + function x() { + let a = []; + let len = 6; + for (let i = 1; i < len; i++) { + if (i == 3) { + continue; + } + + if (i == 5) { + return a; + } + + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..70fa1fde06 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 1 +2 2 +3 3 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer.js new file mode 100644 index 0000000000..a805c13cdb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-body-outer.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-expected.txt new file mode 100644 index 0000000000..f0389411bd --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-expected.txt @@ -0,0 +1,4 @@ +1 1 +2 2 +3 3 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..70fa1fde06 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 1 +2 2 +3 3 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer.js new file mode 100644 index 0000000000..43b8f5e6fb --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-body-outer.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..f0389411bd --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +1 1 +2 2 +3 3 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer.js new file mode 100644 index 0000000000..4c654ab2c8 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl-head-outer.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl.js new file mode 100644 index 0000000000..deecc86720 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-body-decl.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + let j = i; + a.push(function b() { + print(i, j); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..ccebeb23a9 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check exit loop, len == 5: true +1 1 +2 2 +4 4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer.js new file mode 100644 index 0000000000..1be779996b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-continue-body-decl-head-body-outer.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + continue; + } + let j = i; + a.push(function b() { + print(i, j); + }); + } + + print("check exit loop, len == 5: ", len == 5); + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..e280c527f6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer.js new file mode 100644 index 0000000000..759e9ece00 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-body-outer.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-expected.txt new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..e280c527f6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer-expected.txt @@ -0,0 +1,8 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer.js new file mode 100644 index 0000000000..aae076e718 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-body-outer.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..94ebaf9001 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer-expected.txt @@ -0,0 +1,4 @@ +1 +2 +3 +4 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer.js new file mode 100644 index 0000000000..39be53226a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl-head-outer.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let a = []; + let len = 5; + + function x() { + return len; + } + + for (let i = 1; i < len; i++) { + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl.js new file mode 100644 index 0000000000..332fc17a5b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-head-decl.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + a.push(function b() { + print(i); + }); + } + + a.forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..d488ba6885 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer.js new file mode 100644 index 0000000000..0acadd0bef --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-body-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..d488ba6885 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer.js new file mode 100644 index 0000000000..82fcf92582 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-body-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer.js new file mode 100644 index 0000000000..62863c0968 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl-head-outer.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * j is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl.js new file mode 100644 index 0000000000..ba096c948a --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-body-decl.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// j is loop lexical +{ + function x() { + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer-expected.txt new file mode 100644 index 0000000000..80672b645c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer.js new file mode 100644 index 0000000000..bcf0237c93 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-body-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-expected.txt new file mode 100644 index 0000000000..534fb831b5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-expected.txt @@ -0,0 +1,2 @@ +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..80672b645c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer.js new file mode 100644 index 0000000000..bffc9c3bd6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-body-outer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer-expected.txt new file mode 100644 index 0000000000..534fb831b5 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer-expected.txt @@ -0,0 +1,2 @@ +1 1 +2 2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer.js new file mode 100644 index 0000000000..cf6d32bac6 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl-head-outer.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i && j are loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl.js new file mode 100644 index 0000000000..895c30de2c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-body-decl.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i && j are loop lexical +{ + function x() { + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + let j = i; + if (i == 3) { + return a; + } + + a.push(function b() { + print(i, j); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer-expected.txt new file mode 100644 index 0000000000..d488ba6885 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer.js new file mode 100644 index 0000000000..ed39f8fdb7 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-body-outer.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < 5; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer-expected.txt new file mode 100644 index 0000000000..d488ba6885 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer-expected.txt @@ -0,0 +1,5 @@ +check enter loop, len == 5: true +check enter loop, len == 5: true +check enter loop, len == 5: true +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer.js new file mode 100644 index 0000000000..b687a5374c --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-body-outer.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + print("check enter loop, len == 5: ", len == 5); + if (i == 3) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer-expected.txt b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer-expected.txt new file mode 100644 index 0000000000..1191247b6d --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer-expected.txt @@ -0,0 +1,2 @@ +1 +2 diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer.js new file mode 100644 index 0000000000..983c8b4e4b --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl-head-outer.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * i is loop lexical + * len is function lexical + */ +{ + let len = 5; + function x() { + let a = []; + for (let i = 1; i < len; i++) { + if (i == 3) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} diff --git a/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl.js b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl.js new file mode 100644 index 0000000000..27c333c303 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/for-update-return-head-decl.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// i is loop lexical +{ + function x() { + let a = []; + let len = 5; + for (let i = 1; i < len; i++) { + if (i == 3) { + return a; + } + + a.push(function b() { + print(i); + }); + } + + return a; + } + + x().forEach(f => { + f(); + }) +} -- Gitee