diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/block | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/block')
25 files changed, 586 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/block/12.1-1.js b/js/src/tests/test262/language/statements/block/12.1-1.js new file mode 100644 index 0000000000..41e088cd1a --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-1.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-1 +description: "12.1 - block '{ StatementListopt };' is not allowed: try-catch" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +try{};catch(){} diff --git a/js/src/tests/test262/language/statements/block/12.1-2.js b/js/src/tests/test262/language/statements/block/12.1-2.js new file mode 100644 index 0000000000..de0ee99cb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-2.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-2 +description: > + 12.1 - block '{ StatementListopt };' is not allowed: + try-catch-finally +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +try{};catch{};finally{} diff --git a/js/src/tests/test262/language/statements/block/12.1-3.js b/js/src/tests/test262/language/statements/block/12.1-3.js new file mode 100644 index 0000000000..95386a3023 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-3.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-3 +description: "12.1 - block '{ StatementListopt };' is not allowed: try-finally" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +try{};finally{} diff --git a/js/src/tests/test262/language/statements/block/12.1-4.js b/js/src/tests/test262/language/statements/block/12.1-4.js new file mode 100644 index 0000000000..764b3e15a5 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-4.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-4 +description: "12.1 - block '{ StatementListopt };' is not allowed: if-else" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if{};else{} diff --git a/js/src/tests/test262/language/statements/block/12.1-5.js b/js/src/tests/test262/language/statements/block/12.1-5.js new file mode 100644 index 0000000000..1953b0dce2 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-5.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-5 +description: "12.1 - block '{ StatementListopt };' is not allowed: if-else-if" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if{};else if{} diff --git a/js/src/tests/test262/language/statements/block/12.1-6.js b/js/src/tests/test262/language/statements/block/12.1-6.js new file mode 100644 index 0000000000..a8de62d4f7 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-6.js @@ -0,0 +1,17 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-6 +description: > + 12.1 - block '{ StatementListopt };' is not allowed: + if-else-if-else +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +if{};else if{};else{} diff --git a/js/src/tests/test262/language/statements/block/12.1-7.js b/js/src/tests/test262/language/statements/block/12.1-7.js new file mode 100644 index 0000000000..513a24b3cc --- /dev/null +++ b/js/src/tests/test262/language/statements/block/12.1-7.js @@ -0,0 +1,15 @@ +// |reftest| error:SyntaxError +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.1-7 +description: "12.1 - block '{ StatementListopt };' is not allowed: do-while" +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +do{};while() diff --git a/js/src/tests/test262/language/statements/block/S12.1_A2.js b/js/src/tests/test262/language/statements/block/S12.1_A2.js new file mode 100644 index 0000000000..39fb4edb96 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/S12.1_A2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The production StatementList Statement is evaluated as follows + 1. Evaluate Statement. + 2. If an exception was thrown, return (throw, V, empty) where V is the exception +es5id: 12.1_A2 +description: Throwing exception within a Block +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +assert.throws(ReferenceError, function() { + { + x(); + } +}); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + throw "catchme"; + throw new Test262Error('#2: throw "catchme" lead to throwing exception'); +} catch (e) { + if (e!=="catchme") { + throw new Test262Error('#2.1: Exception === "catchme". Actual: Exception ==='+ e ); + } +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/S12.1_A4_T1.js b/js/src/tests/test262/language/statements/block/S12.1_A4_T1.js new file mode 100644 index 0000000000..8d1cd42e44 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/S12.1_A4_T1.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The production Block can't be inside of expression +es5id: 12.1_A4_T1 +description: Checking if execution of "y={__func}()" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function __func(){}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +y={__func;}(); +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/block/S12.1_A4_T2.js b/js/src/tests/test262/language/statements/block/S12.1_A4_T2.js new file mode 100644 index 0000000000..8783c5b76c --- /dev/null +++ b/js/src/tests/test262/language/statements/block/S12.1_A4_T2.js @@ -0,0 +1,22 @@ +// |reftest| error:SyntaxError +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The production Block can't be inside of expression +es5id: 12.1_A4_T2 +description: Checking if execution of "y={x;}" fails +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +x=1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +y={x;}; +// +////////////////////////////////////////////////////////////////////////////// diff --git a/js/src/tests/test262/language/statements/block/S12.1_A5.js b/js/src/tests/test262/language/statements/block/S12.1_A5.js new file mode 100644 index 0000000000..97a625bedc --- /dev/null +++ b/js/src/tests/test262/language/statements/block/S12.1_A5.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + StatementList: StatementList Statement inside the Block is evaluated from + left to right +es5id: 12.1_A5 +description: Throwing exceptions within embedded/sequence Blocks +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + throw 1; + throw 2; + throw 3; + throw new Test262Error('1.1: throw 1 lead to throwing exception'); +} catch (e) { + if (e!==1) { + throw new Test262Error('#1.2: Exception === 1. Actual: Exception ==='+ e); + } +} +//////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + { + throw 1; + throw 2; + } + throw 3; + throw new Test262Error('#2.1: throw 1 lead to throwing exception'); +} catch (e) { + if (e!==1) { + throw new Test262Error('#2.2: Exception === 1. Actual: Exception ==='+ e); + } +} +//////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +try { + throw 1; + { + throw 2; + throw 3; + } + throw new Test262Error('#3.1: throw 1 lead to throwing exception'); +} catch (e) { + if (e!==1) { + throw new Test262Error('#3.2: Exception === 1. Actual: Exception ==='+ e); + } +} +//////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/browser.js b/js/src/tests/test262/language/statements/block/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/browser.js diff --git a/js/src/tests/test262/language/statements/block/early-errors/browser.js b/js/src/tests/test262/language/statements/block/early-errors/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/browser.js diff --git a/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-bad-reference.js b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-bad-reference.js new file mode 100644 index 0000000000..b58f2e02d0 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-bad-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-bad-reference.case +// - src/invalid-private-names/default/block.template +/*--- +description: bad reference in call expression (Invalid private names should throw a SyntaxError, block statement) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +{ (() => {})().#x } diff --git a/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-this.js b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-this.js new file mode 100644 index 0000000000..be675df8cc --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-call-expression-this.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/call-expression-this.case +// - src/invalid-private-names/default/block.template +/*--- +description: this evaluated in call expression (Invalid private names should throw a SyntaxError, block statement) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +{ (() => this)().#x } diff --git a/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-bad-reference.js b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-bad-reference.js new file mode 100644 index 0000000000..78adc1a2ab --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-bad-reference.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-bad-reference.case +// - src/invalid-private-names/default/block.template +/*--- +description: bad reference in member expression (Invalid private names should throw a SyntaxError, block statement) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +{ something.#x } diff --git a/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-this.js b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-this.js new file mode 100644 index 0000000000..c587936244 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/invalid-names-member-expression-this.js @@ -0,0 +1,41 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/invalid-private-names/member-expression-this.case +// - src/invalid-private-names/default/block.template +/*--- +description: this reference in member expression (Invalid private names should throw a SyntaxError, block statement) +esid: sec-static-semantics-early-errors +features: [class-fields-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + +---*/ + + +$DONOTEVALUATE(); + +{ this.#x } diff --git a/js/src/tests/test262/language/statements/block/early-errors/shell.js b/js/src/tests/test262/language/statements/block/early-errors/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/early-errors/shell.js diff --git a/js/src/tests/test262/language/statements/block/labeled-continue.js b/js/src/tests/test262/language/statements/block/labeled-continue.js new file mode 100644 index 0000000000..dc08215409 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/labeled-continue.js @@ -0,0 +1,25 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-static-semantics-containsundefinedcontinuetarget +description: Clears label set in check for undefined `continue` target +info: | + With arguments iterationSet and labelSet. + + Statement : BlockStatement + + 1. Return ContainsUndefinedContinueTarget of |BlockStatement| with arguments + _iterationSet_ and « ». +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +label: { + for ( ;; ) { + continue label; + } +} diff --git a/js/src/tests/test262/language/statements/block/scope-lex-close.js b/js/src/tests/test262/language/statements/block/scope-lex-close.js new file mode 100644 index 0000000000..42818aa30a --- /dev/null +++ b/js/src/tests/test262/language/statements/block/scope-lex-close.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-block-runtime-semantics-evaluation +description: Removal of lexical environment for BlockStatement +info: | + 1. Let oldEnv be the running execution context's LexicalEnvironment. + 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv). + 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv). + 4. Set the running execution context's LexicalEnvironment to blockEnv. + 5. Let blockValue be the result of evaluating StatementList. + 6. Set the running execution context's LexicalEnvironment to oldEnv. + 7. Return blockValue. +features: [let] +---*/ + +var probe; + +{ + let x = 'inside'; + probe = function() { return x; }; +} + +let x = 'outside'; + +assert.sameValue(x, 'outside'); +assert.sameValue(probe(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/scope-lex-open.js b/js/src/tests/test262/language/statements/block/scope-lex-open.js new file mode 100644 index 0000000000..5d711ea573 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/scope-lex-open.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-block-runtime-semantics-evaluation +description: Creation of new lexical environment for BlockStatement +info: | + 1. Let oldEnv be the running execution context's LexicalEnvironment. + 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv). + 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv). + 4. Set the running execution context's LexicalEnvironment to blockEnv. + 5. Let blockValue be the result of evaluating StatementList. + [...] +features: [let] +---*/ + +let x = 'outside'; +var probeBefore = function() { return x; }; +var probeInside; + +{ + let x = 'inside'; + probeInside = function() { return x; }; +} + +assert.sameValue(probeBefore(), 'outside'); +assert.sameValue(probeInside(), 'inside'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/scope-var-none.js b/js/src/tests/test262/language/statements/block/scope-var-none.js new file mode 100644 index 0000000000..9e94d7b58a --- /dev/null +++ b/js/src/tests/test262/language/statements/block/scope-var-none.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-block-runtime-semantics-evaluation +description: Retainment of existing variable environment for BlockStatement +info: | + 1. Let oldEnv be the running execution context's LexicalEnvironment. + 2. Let blockEnv be NewDeclarativeEnvironment(oldEnv). + 3. Perform BlockDeclarationInstantiation(StatementList, blockEnv). + 4. Set the running execution context's LexicalEnvironment to blockEnv. + 5. Let blockValue be the result of evaluating StatementList. + 6. Set the running execution context's LexicalEnvironment to oldEnv. + 7. Return blockValue. +---*/ + +var x = 'outside'; +var probeBefore = function() { return x; }; +var probeInside; + +{ + var x = 'inside'; + probeInside = function() { return x; }; +} + +assert.sameValue(probeBefore(), 'inside', 'reference preceding statement'); +assert.sameValue(probeInside(), 'inside', 'reference within statement'); +assert.sameValue(x, 'inside', 'reference following statement'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/shell.js b/js/src/tests/test262/language/statements/block/shell.js new file mode 100644 index 0000000000..43295587f4 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/shell.js @@ -0,0 +1,16 @@ +// GENERATED, DO NOT EDIT +// file: tcoHelper.js +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/js/src/tests/test262/language/statements/block/tco-stmt-list-strict.js b/js/src/tests/test262/language/statements/block/tco-stmt-list-strict.js new file mode 100644 index 0000000000..f8bae6ce7d --- /dev/null +++ b/js/src/tests/test262/language/statements/block/tco-stmt-list-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Statement within statement is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + { void 0; return f(n - 1); } +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/block/tco-stmt-strict.js b/js/src/tests/test262/language/statements/block/tco-stmt-strict.js new file mode 100644 index 0000000000..308d5cff42 --- /dev/null +++ b/js/src/tests/test262/language/statements/block/tco-stmt-strict.js @@ -0,0 +1,23 @@ +// |reftest| skip -- tail-call-optimization is not supported +'use strict'; +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Statement within statement is a candidate for tail-call optimization. +esid: sec-static-semantics-hascallintailposition +flags: [onlyStrict] +features: [tail-call-optimization] +includes: [tcoHelper.js] +---*/ + +var callCount = 0; +(function f(n) { + if (n === 0) { + callCount += 1 + return; + } + { return f(n - 1); } +}($MAX_ITERATIONS)); +assert.sameValue(callCount, 1); + +reportCompare(0, 0); |