diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index e9369fa834ee8c9dde7810fe20acd2308fef023d..3f48313e3cf0d9b79de930df04ce08edd5b1018d 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 f88131722cacb6005a76c9830308f3fbb2e03446..380c31773f046afb8b6933e43d8b0149dd821760 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 6bb538234cb2bebe0af5c51f9e57beb3bee41270..1b6024dfcae84f99adfcbb9671cf49ec95c8791a 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/dynamicContext.cpp b/es2panda/compiler/core/dynamicContext.cpp index 1dab58cece720a45c57f44af53d54192ba17db86..d6319c6a156d5df3176f300e28a3f6ba75d89202 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/compiler/core/envScope.cpp b/es2panda/compiler/core/envScope.cpp index 6cb007c87e5599bda9ef68b52009c49f28edf250..aa3e98344a8b732ed722d99c151615de6372f716 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 a21c2a3e52022a8ec6e51467b395d410cda5f5e8..29faecfc9f3bcee5c5298b16bd8cad66ac4d30d8 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 83078b77efc90c68227879d3712b58ccaafe02d0..cc862254b667159032b24474b06c7c002cf1e99b 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 2ccad0cb65b5ab4b604d5b7d8bebceaf453e9a21..512f9ca8f2a7e815f7ae2e47db6ee595a13c33e3 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 f653ce3108ac2cc371a09d90282e7fe8e5eadf8b..d492fb48cca00dc9662846af65e373c283c16152 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 d6275d9817170a63e6a7ffccbea43dc86a7f47e5..278cf6a1e258f7aa4391e8ea9f8b5720ff2c116c 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 0c5a09fb3427763c6f203c29aabd11f197973d25..45d3d061a075a075abe94d6db0f4ab7b05121a5c 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 f5c91da85a77b1dcf5a77cb39653875b12fee37d..3d8befe6410b6dbada20acebe8a61693de45661f 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/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 0000000000000000000000000000000000000000..6ed281c757a969ffe22f3dcfa5830c532479c726 --- /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 0000000000000000000000000000000000000000..22cd25225bb443e0924f98f845f6ae8efd9f85c6 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..d663411961cc521aec2f9280adb49d0c77d47b36 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..13107c6f973d3abe1c37bfada892c337727814ac --- /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 0000000000000000000000000000000000000000..e280c527f6f9bb2caa1e169380db66230a119a6e --- /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 0000000000000000000000000000000000000000..6b194b46cac96e704ead5da5d203f509527e9f86 --- /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 0000000000000000000000000000000000000000..94ebaf900161394059478fd88aec30e59092a1d7 --- /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 0000000000000000000000000000000000000000..e280c527f6f9bb2caa1e169380db66230a119a6e --- /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 0000000000000000000000000000000000000000..c9a67812fb272e1cf2e6c792eb86a0305c80dc93 --- /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 0000000000000000000000000000000000000000..94ebaf900161394059478fd88aec30e59092a1d7 --- /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 0000000000000000000000000000000000000000..ccb1f199d0a450bdf282a91bbfae7f4122080803 --- /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 0000000000000000000000000000000000000000..1cad6f9cd25e711ac29cbab67d9760f611f92c29 --- /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 0000000000000000000000000000000000000000..ce6a369b50a443501ee11cb4e5e88aa09240def5 --- /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 0000000000000000000000000000000000000000..7a0e9364afb30a5896a27447f6bbabdb09038e4b --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..ce6a369b50a443501ee11cb4e5e88aa09240def5 --- /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 0000000000000000000000000000000000000000..d84a9be94b387a1491216db4051d0e2463748cb7 --- /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 0000000000000000000000000000000000000000..671e48f1f488a4808dabac6b386eea769f797d61 --- /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 0000000000000000000000000000000000000000..a92953ce2b0899d9d6bdb53848dd1e648bcb1538 --- /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 0000000000000000000000000000000000000000..dca081088431f85cbb1eecbbb9e7ed5d88a62bc7 --- /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 0000000000000000000000000000000000000000..ac28118444d63062b18e24b5c1865350f05e468e --- /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 0000000000000000000000000000000000000000..eec15190e7d6623b112ccca00a48bc0e7bc4066b --- /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 0000000000000000000000000000000000000000..534fb831b52dd06eb844551dc8df3424726f91c8 --- /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 0000000000000000000000000000000000000000..ac28118444d63062b18e24b5c1865350f05e468e --- /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 0000000000000000000000000000000000000000..3e970ea8c1838e7c354c5d07a5eade0e7789abc8 --- /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 0000000000000000000000000000000000000000..ac2fc4bf0cd281880d1aab1e85dbad955fcc92b0 --- /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 0000000000000000000000000000000000000000..36d0ababb5d18e3dd40103c39a5711535963eb2f --- /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 0000000000000000000000000000000000000000..0807cb16664c4bc573e3a253ecddaab83214e1ba --- /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 0000000000000000000000000000000000000000..ce6a369b50a443501ee11cb4e5e88aa09240def5 --- /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 0000000000000000000000000000000000000000..447fe66ee85843c71236a0a721a05d5071550e9c --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..ce6a369b50a443501ee11cb4e5e88aa09240def5 --- /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 0000000000000000000000000000000000000000..06a0ddaaec3ca346e5c70d5799d2c533c50d9ff2 --- /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 0000000000000000000000000000000000000000..671e48f1f488a4808dabac6b386eea769f797d61 --- /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 0000000000000000000000000000000000000000..80d5f71b409def1e456353a36610ea194e8d3782 --- /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 0000000000000000000000000000000000000000..47c34a75a3dd61b0fa854623a59b7d9bbdadf161 --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..d9fca4e80f23e887ba56273a4a346397c4c47d3c --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..863f8b677b74d750c1443331fa85b421fb66b31b --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..3f0fbcef834a34654ab5bc95f4ffdf39e53e9156 --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..a825df1fe2a5c7e90ac0f125dfb65c3a1e94dd54 --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..04acdfd2270c1df579783a2838feafc110682853 --- /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 0000000000000000000000000000000000000000..912274f45b9f6830a611f714bba6589564d6f27a --- /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 0000000000000000000000000000000000000000..dde53b64747feab8dc2e306309cd7ad2ef57dfdf --- /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 0000000000000000000000000000000000000000..7947443deb4b8a3150d153f820d9c9de4655857d --- /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 0000000000000000000000000000000000000000..fa40363ce487e9d17b077c9e3c8f6ecfc65dcbe4 --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..823e60b31495fce84f52eba7ad79965966577960 --- /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 0000000000000000000000000000000000000000..534fb831b52dd06eb844551dc8df3424726f91c8 --- /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 0000000000000000000000000000000000000000..ae57cb37babc4fc3c261d13662318a9f45ba0235 --- /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 0000000000000000000000000000000000000000..534fb831b52dd06eb844551dc8df3424726f91c8 --- /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 0000000000000000000000000000000000000000..d6e2319fbd4059ac6d82a739c11ee3e1e896de69 --- /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 0000000000000000000000000000000000000000..e3bf9bc42563c4057788e4ac53b19234df1e960e --- /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 0000000000000000000000000000000000000000..eb221e924369f11b0ab9ccecff2d2718c99aed64 --- /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 0000000000000000000000000000000000000000..0ca7a626734270cde28cd2e8af08ab16d2926806 --- /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 0000000000000000000000000000000000000000..8a7fcb62b6e909b3f7adf98929ffb9354b79939e --- /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 0000000000000000000000000000000000000000..e3bf9bc42563c4057788e4ac53b19234df1e960e --- /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 0000000000000000000000000000000000000000..191cf8e4c77a3e1cd6cbb19eaac9f2da41aca647 --- /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 0000000000000000000000000000000000000000..0ca7a626734270cde28cd2e8af08ab16d2926806 --- /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 0000000000000000000000000000000000000000..df28c43cc528f747f86713f532006457cde806c4 --- /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 0000000000000000000000000000000000000000..f6beed8606425e9ac731aa617c59df53865550a1 --- /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 0000000000000000000000000000000000000000..ee08c3f588298bb704c3cef69df50944e66bb522 --- /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 0000000000000000000000000000000000000000..f6beed8606425e9ac731aa617c59df53865550a1 --- /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 0000000000000000000000000000000000000000..91356a65b899400ba850314c093d3b4ee291857a --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..b0427c12f244d86e5be91fbb0d12c6ca3d19d1aa --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..bf028d9a5fcfccf7201d6b234db140174c6cb294 --- /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 0000000000000000000000000000000000000000..912274f45b9f6830a611f714bba6589564d6f27a --- /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 0000000000000000000000000000000000000000..b027c4b56adba804f2224a3e6057749ec13ab17a --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..6ac8c32540094365992ba6a7dc47512f0e40616e --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..a82095f5687f7cfe726418b55cf27aef97c1a463 --- /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 0000000000000000000000000000000000000000..d9c07d9071129a62a482ba3831e090f47d4506eb --- /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 0000000000000000000000000000000000000000..e0f686312ff9b6790d5b1c150203ef06f924f5b3 --- /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 0000000000000000000000000000000000000000..7947443deb4b8a3150d153f820d9c9de4655857d --- /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 0000000000000000000000000000000000000000..7b01cbf4de9e29dfbe2ca3d51b4ff93888854a45 --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..000c21eaf4ebed0050c6065c1e39ef674e13ee15 --- /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 0000000000000000000000000000000000000000..045ccf37cefc20188130ee6edfdd88e10ffd64a9 --- /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 0000000000000000000000000000000000000000..ab954b07956889ff710492f654375f533d6a7b46 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..045ccf37cefc20188130ee6edfdd88e10ffd64a9 --- /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 0000000000000000000000000000000000000000..3c33209a8df2217255699c293871125234512496 --- /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 0000000000000000000000000000000000000000..0f2e5bfb0cb2a445195a8f94d561695631abec19 --- /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 0000000000000000000000000000000000000000..276f16ed2fea70e90955bbfd086f23240e977b10 --- /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 0000000000000000000000000000000000000000..92155d019c8b9a41bc578d9c2d47cc8b37628613 --- /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 0000000000000000000000000000000000000000..c7bd6e9afbbc1210b83142fedcbd2c36aff6b60c --- /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 0000000000000000000000000000000000000000..ccf429d6166177eefd9e79a53749d3c50a7df807 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..c7bd6e9afbbc1210b83142fedcbd2c36aff6b60c --- /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 0000000000000000000000000000000000000000..0bf2cfbdd52e1e3226d938b7a248f37de301ee1b --- /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 0000000000000000000000000000000000000000..5bebbfe3d40685e4111991eb3f495af2628552ef --- /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 0000000000000000000000000000000000000000..da3bae26e85f931f49be9662617976b4fbc2c169 --- /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 0000000000000000000000000000000000000000..1e74b8d1cf3206ddfc9e9360a3ea348e5663c303 --- /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 0000000000000000000000000000000000000000..02f12392d512395b207039b05e6bf5e5cc79135b --- /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 0000000000000000000000000000000000000000..d78e862811faa3e173647d00ccdbd1c1d6147704 --- /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 0000000000000000000000000000000000000000..7a56ba29c0238a160a432df4e0fe8c38e85f36e4 --- /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 0000000000000000000000000000000000000000..02f12392d512395b207039b05e6bf5e5cc79135b --- /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 0000000000000000000000000000000000000000..093a380583ca2e9040c5200f4cff9e1d36d78490 --- /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 0000000000000000000000000000000000000000..c6752cbe1297e5d8b806a1128262236a59c2c9fc --- /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 0000000000000000000000000000000000000000..f89f1d7be94bcfad229d3468e7c8e6480ae15d84 --- /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 0000000000000000000000000000000000000000..eefb3370b46a3e35c5677395dc77d8e453b8d9af --- /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 0000000000000000000000000000000000000000..c7bd6e9afbbc1210b83142fedcbd2c36aff6b60c --- /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 0000000000000000000000000000000000000000..912541fe4b69a50798c4135097955346c488a826 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..c7bd6e9afbbc1210b83142fedcbd2c36aff6b60c --- /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 0000000000000000000000000000000000000000..be566a397b488996647dcf74467af4b846594282 --- /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 0000000000000000000000000000000000000000..5bebbfe3d40685e4111991eb3f495af2628552ef --- /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 0000000000000000000000000000000000000000..55264468fcd8077111cfa7ed9d0d302194f19424 --- /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 0000000000000000000000000000000000000000..4e561112f527cfc16f97c871141cf1179b850cd8 --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..06c1545059269f46e310eaa4e6907b4d623e5dd4 --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..170d2fea4bc020d2a1bc474abffbdbd3b88b719f --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..aac61eab3edc4f87be620b67e46225796d9ea372 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..da30094e9fb55f118d7d097f6014105016d2e545 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..8f61a3b85a0fcda79922c1daf6a692aefc68f6ab --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..159fd803d32ddd536b47a8e39dfc08a2b75c26ba --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..26b8b3eb59c8ce8ac84e7a24b2bc790cee5a2707 --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..d704c3283d0403cd5cd0ffbd7da85414d194ef13 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..0a292fc8a200561bbb25629e6fb9f2f1738ee53f --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..daaf469cff4d5e2f8154d352d2fc0d3929aeb26d --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..63011b832825ab9099ce6d1ce728e2d8c9d67859 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..3cedf5d4609f0310b2dcdf70e31c3fc2a02f8fba --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..7d7e85b94dc4b67447ec5b348c2ad9b0a5cf86b8 --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..cee0c161db8450db15acd43f1a078702ba046a68 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..04dda537f5dda39ce1392e52838345a2eb293f1c --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..7a8f1e3290c26c7a0cc2a02ba85e4739aff80ca4 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..865765137ae885321751bec3f84fe58ef65ac029 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..74939d7b3ac56e4e785e1d8b04cfb37e9e2eb28c --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..400c5d3323dc0a4d93f63b2e4ebf7b8653fea793 --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..137a1190bb9885de57e0a5448371901980be5e09 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..2196b59f00f059a4ed11d6e8e79c07ef233af6c9 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..916faf692a3abcd016ba8f76cd792de88f1c86e3 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..ffc2b0e750f5e4f56d4b9bfb970d676e6a341588 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..5b56e5f050206339bab4f63bb26d38bdb36a2efc --- /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 0000000000000000000000000000000000000000..656ae9041fbcde75273fbd7cda112e8d356d4c2b --- /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 0000000000000000000000000000000000000000..d0848e01fe22b456d8fddedab5d5d3f2b356d8da --- /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 0000000000000000000000000000000000000000..656ae9041fbcde75273fbd7cda112e8d356d4c2b --- /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 0000000000000000000000000000000000000000..1600feb5c63fa29c0a940e4a27810f514db33779 --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..3628998885640cb7a91a514a3a2cfb77f69403f5 --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..4db6aa0cf9af55fc4373be6c16db792f343449c3 --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..59349985bf49c5ae0c04fa89558f32a17d1a7eaf --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..3936ef1fd85ebd716b26e63d6b699b2003394c14 --- /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 0000000000000000000000000000000000000000..4c09a4bd9f9a5be5f52a600548a100fd139fb710 --- /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 0000000000000000000000000000000000000000..6d978db458ee236f4e6c65344bf7bcf98400ad3b --- /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 0000000000000000000000000000000000000000..4c09a4bd9f9a5be5f52a600548a100fd139fb710 --- /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 0000000000000000000000000000000000000000..4453d4efe8fbe6c08743102d0c08772c287346b2 --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..4436f81b219c9ad9fdb6d28686298139bc66497d --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..bebf48b8eb6e419a5670c47b1f8cede4974ed10b --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..60406bb2f2400bfc4ca448b38ede016505c1ea0c --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..be55ab931aebb4b25a5b73ae62d26cf069adafd0 --- /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 0000000000000000000000000000000000000000..4c09a4bd9f9a5be5f52a600548a100fd139fb710 --- /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 0000000000000000000000000000000000000000..f97f74c358ad0491f1f6b6be57b6be025e9e1851 --- /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 0000000000000000000000000000000000000000..4c09a4bd9f9a5be5f52a600548a100fd139fb710 --- /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 0000000000000000000000000000000000000000..3a2a0df09d2bf542b8332181f935b70401ae33b3 --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..3a42a45448dc426f1af5e27ab3e606a32f692df3 --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..ab7f76a42569d01c1d954092093e8958d6ccf2e4 --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..d7b66f65f80668eb6a06b39aed1abff4267c1d3e --- /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 0000000000000000000000000000000000000000..e761ae95a850c6eb4b830390752b6df73cbe35a2 --- /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 0000000000000000000000000000000000000000..7bbdcb31969ddfb60ffa52e9e2e143d778802da1 --- /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 0000000000000000000000000000000000000000..656ae9041fbcde75273fbd7cda112e8d356d4c2b --- /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 0000000000000000000000000000000000000000..1a00a09d05dc5d5530a665a0ea45f2f3f61fb26f --- /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 0000000000000000000000000000000000000000..656ae9041fbcde75273fbd7cda112e8d356d4c2b --- /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 0000000000000000000000000000000000000000..5bd5899cc45ed669f6204f7eb3c9f71d415efcdd --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..80b0028c5b791f1e9d306d5e96fc717b784e117a --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..b78121dc4089b1447ab5862b2930288d8d458864 --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..ac11b30d8f54b63cbc6b0f2f189f38655847d655 --- /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 0000000000000000000000000000000000000000..2fb73a07ec2d7b737fbb6c160ff8bc78dadb6930 --- /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 0000000000000000000000000000000000000000..cfd6a420de03f92d11482dd4659a383c3e335b44 --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..e1f4815aa5f0605e0d927f3b2b4917ee36e5e30d --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..626e41a70f4f4b793c2d3716e24a7895fa6c3d5e --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..1333d1902ee8f4b3c07f44bb60cfe3ff38cc513f --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..4efb0b4e24f1062c63bc993b3716977be776b39a --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..4d1e192cc4e711bcd13ae326b917ed194ea2efac --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..0ef287b21898d5763d64c025717c7a3d85ced010 --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..b36314ed7b6edccbb510f91ede73fafed67b5519 --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..5af05190349b9e55ee7afcdbab5edbdd11185ae9 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..7e86fe4d053b1626bd3339c1e3f3d6dcc7c33666 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..b5249d8da897edaaf75ff470a7207f2fd006c928 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..dc1452f8244037f8dbf69f55ecb21d8605a959b8 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..2b14054947f7c93e1ccacd1207b43031a0d2561f --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..027db81269ad444ad2f1bedffe99d66d2ea47b3e --- /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 0000000000000000000000000000000000000000..c311fd39dc0e685a619375acc26b8ea220cc9291 --- /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 0000000000000000000000000000000000000000..f64dd3a4f7bac0640c305a97485cf05c6ec7eb89 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..4f814a7415a8c3881d63720ec894c0e528ee7b86 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..366b5e8afe8e22cc87e4b498b7261e11cb36c768 --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..57c37f94a7c41e0825d5b7df4fce6e7a33d6d88c --- /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 0000000000000000000000000000000000000000..bf6b4becee90aa5396b322851ad93c3bc95426fb --- /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 0000000000000000000000000000000000000000..adb9626069d8c11a30b19bf65434d376ae353fa8 --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..8677f50115a691865d1ea3ea2e0050abd17869bd --- /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 0000000000000000000000000000000000000000..2b2f2e1b9261c50c3816610eb3eb140fabf1745a --- /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 0000000000000000000000000000000000000000..47820509843a6e5305790ef4f280b786c0a5031f --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..8b2ba353da6b973ab009322a2cbe4c51e90dc616 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..0d62dc8c509e9afb9abbf59ff6bc6a538d6fbd85 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..85585cfb98bb479ac98fba17fded5c3d00c47fb8 --- /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 0000000000000000000000000000000000000000..d00491fd7e5bb6fa28c517a0bb32b8b506539d4d --- /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 0000000000000000000000000000000000000000..a2215b294771da2922135abe3520063b08e4aaa1 --- /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 0000000000000000000000000000000000000000..ccebeb23a91888e418e57e9011169112ea72e531 --- /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 0000000000000000000000000000000000000000..cc50768164665ad92ea7f3e1caeed2125790f620 --- /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 0000000000000000000000000000000000000000..7a56ba29c0238a160a432df4e0fe8c38e85f36e4 --- /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 0000000000000000000000000000000000000000..b36399f9c93f700b7627da8afd6b89fd5af38ff2 --- /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 0000000000000000000000000000000000000000..c68d859b2da90bec5cb2e1b39aa764107a1371c2 --- /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 0000000000000000000000000000000000000000..d850a279cfd33243423787eb5ad429bc9471d68a --- /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 0000000000000000000000000000000000000000..045ccf37cefc20188130ee6edfdd88e10ffd64a9 --- /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 0000000000000000000000000000000000000000..f7dfb59897a5ba4d806d34d06a9d35c13a664415 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..045ccf37cefc20188130ee6edfdd88e10ffd64a9 --- /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 0000000000000000000000000000000000000000..14febf7c6d58676f2f330ac9ab7f91fcc309e74e --- /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 0000000000000000000000000000000000000000..0f2e5bfb0cb2a445195a8f94d561695631abec19 --- /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 0000000000000000000000000000000000000000..775f874bdb22c46e5754f6922ad4d426b40ea24d --- /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 0000000000000000000000000000000000000000..d4fa7241729df731f88583f29b48590b25bb6c1f --- /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 0000000000000000000000000000000000000000..d1f6964a491fe36e1ab7375f1952de4c8715d1c5 --- /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 0000000000000000000000000000000000000000..e515cc88eecb456053f41a732d0a4710a2d00200 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..d1f6964a491fe36e1ab7375f1952de4c8715d1c5 --- /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 0000000000000000000000000000000000000000..055270bd23fc51ca1864b48b042594ec53afaa2d --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..44157331a329a9c6c7670acb3a0f1aea654cbb0b --- /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 0000000000000000000000000000000000000000..cdb0ed17d61dca67fa1f901490a1137fb52c5f9d --- /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 0000000000000000000000000000000000000000..faed05e73e2ca962695466c9fd39d32a1294da57 --- /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 0000000000000000000000000000000000000000..f6b502c4676763d6a28dda2ef99a72263cd3ef8e --- /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 0000000000000000000000000000000000000000..7a56ba29c0238a160a432df4e0fe8c38e85f36e4 --- /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 0000000000000000000000000000000000000000..faed05e73e2ca962695466c9fd39d32a1294da57 --- /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 0000000000000000000000000000000000000000..b91e9105aea12a446e2886fbce0ec8fa1ce73f73 --- /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 0000000000000000000000000000000000000000..7a56ba29c0238a160a432df4e0fe8c38e85f36e4 --- /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 0000000000000000000000000000000000000000..09ccb8d441d0f7a4e5b43c64b7ba32bc0dfec21c --- /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 0000000000000000000000000000000000000000..229779b1c93cca735bab65dffdbc779ff9e66596 --- /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 0000000000000000000000000000000000000000..d1f6964a491fe36e1ab7375f1952de4c8715d1c5 --- /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 0000000000000000000000000000000000000000..1e6be4d4156ac6b0fe5212c3a99ebd3bf04104b9 --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..d1f6964a491fe36e1ab7375f1952de4c8715d1c5 --- /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 0000000000000000000000000000000000000000..89ddaf5dcecced4c7dee62a54823536c32aa04fe --- /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 0000000000000000000000000000000000000000..e8a01cd985125a824409ef6b2f264c76b54ffe6a --- /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 0000000000000000000000000000000000000000..faa7efdc03e2eb96f51b605ca6becc1d452085a2 --- /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 0000000000000000000000000000000000000000..024f602d2040e094324ffd0299073d38228e0b8b --- /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 0000000000000000000000000000000000000000..70fa1fde066f81c4699a5b79d8415cbdf5225563 --- /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 0000000000000000000000000000000000000000..a805c13cdbf738cb4c0f5ecbca9d7de055275127 --- /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 0000000000000000000000000000000000000000..f0389411bdedb0d2e0a3d0620e3e6abd62b2be57 --- /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 0000000000000000000000000000000000000000..70fa1fde066f81c4699a5b79d8415cbdf5225563 --- /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 0000000000000000000000000000000000000000..43b8f5e6fb329677870f479f5919a0bbf2c2565d --- /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 0000000000000000000000000000000000000000..f0389411bdedb0d2e0a3d0620e3e6abd62b2be57 --- /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 0000000000000000000000000000000000000000..4c654ab2c8afaa7f6409f7a4f0a4bb6f7c1b0850 --- /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 0000000000000000000000000000000000000000..deecc86720c41725807c47fcef802344894607a6 --- /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 0000000000000000000000000000000000000000..ccebeb23a91888e418e57e9011169112ea72e531 --- /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 0000000000000000000000000000000000000000..1be779996b4203a54f10c3459fe53de6f02511cb --- /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 0000000000000000000000000000000000000000..e280c527f6f9bb2caa1e169380db66230a119a6e --- /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 0000000000000000000000000000000000000000..759e9ece00c21c3e8b7d73d46b63512c9c742da3 --- /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 0000000000000000000000000000000000000000..94ebaf900161394059478fd88aec30e59092a1d7 --- /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 0000000000000000000000000000000000000000..e280c527f6f9bb2caa1e169380db66230a119a6e --- /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 0000000000000000000000000000000000000000..aae076e7184344466c547505433d41f7ef0b574c --- /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 0000000000000000000000000000000000000000..94ebaf900161394059478fd88aec30e59092a1d7 --- /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 0000000000000000000000000000000000000000..39be53226a6dd81154f0d47811349c4b0490b1da --- /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 0000000000000000000000000000000000000000..332fc17a5be27a64ac3ec71782cfdbba45d894d2 --- /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 0000000000000000000000000000000000000000..d488ba688522dec837aef0046b73a2e2e96836a4 --- /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 0000000000000000000000000000000000000000..0acadd0bef7e1815032fce4516634321f560c628 --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..d488ba688522dec837aef0046b73a2e2e96836a4 --- /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 0000000000000000000000000000000000000000..82fcf92582815e4ee0fd51d7ef1b796e35bfc9f1 --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..62863c0968b18a6f840125e74f4a471dc5d01f69 --- /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 0000000000000000000000000000000000000000..ba096c948a141dda87ee90d3213e8613f2f8316d --- /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 0000000000000000000000000000000000000000..80672b645c1517fa2e1832f1db01abde3d860102 --- /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 0000000000000000000000000000000000000000..bcf0237c937dd81cb8377c2dca0c06d784e3407e --- /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 0000000000000000000000000000000000000000..534fb831b52dd06eb844551dc8df3424726f91c8 --- /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 0000000000000000000000000000000000000000..80672b645c1517fa2e1832f1db01abde3d860102 --- /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 0000000000000000000000000000000000000000..bffc9c3bd60ff7155f8441990bf48c497c496deb --- /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 0000000000000000000000000000000000000000..534fb831b52dd06eb844551dc8df3424726f91c8 --- /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 0000000000000000000000000000000000000000..cf6d32bac6d1c6069f5f212f502df30861abca01 --- /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 0000000000000000000000000000000000000000..895c30de2c521038a7fe2d5fd4f64efe20ab80b8 --- /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 0000000000000000000000000000000000000000..d488ba688522dec837aef0046b73a2e2e96836a4 --- /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 0000000000000000000000000000000000000000..ed39f8fdb739bd9fa6b229b8ef93f03a88106f7a --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..d488ba688522dec837aef0046b73a2e2e96836a4 --- /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 0000000000000000000000000000000000000000..b687a5374c9fb7f8e6005b84df2d43c32b7019de --- /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 0000000000000000000000000000000000000000..1191247b6d9a206f6ba3d8ac79e26d041dd86941 --- /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 0000000000000000000000000000000000000000..983c8b4e4bf9a290cde1037a71bc4e0b40e6dc26 --- /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 0000000000000000000000000000000000000000..27c333c303b7ba4d30066a5b6bfdd2b1c350ce51 --- /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(); + }) +}