diff options
author | Leonardo Balter <leonardo.balter@gmail.com> | 2017-03-14 14:34:20 -0400 |
---|---|---|
committer | Leonardo Balter <leonardo.balter@gmail.com> | 2017-03-14 14:58:33 -0400 |
commit | 7522a29f3197a8ebba967b1edc125931d6332124 (patch) | |
tree | 4b00150f458053a03626c68835c5e2f997d987dc /test/language/expressions/arrow-function | |
parent | c37a2420570116eec7f5d829e9bc6b948557166a (diff) | |
download | qtdeclarative-testsuites-7522a29f3197a8ebba967b1edc125931d6332124.tar.gz |
Generate tests
Diffstat (limited to 'test/language/expressions/arrow-function')
7 files changed, 245 insertions, 9 deletions
diff --git a/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js b/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js index 6bbd53038..124a1addf 100644 --- a/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js +++ b/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js @@ -60,8 +60,9 @@ var nullCount = 0; var objCount = 0; var callCount = 0; -var f; -f = (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) => { +// Stores a reference `ref` for case evaluation +var ref; +ref = (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) => { assert.sameValue(aFalse, false); assert.sameValue(aString, ''); assert.sameValue(aNaN, NaN); @@ -71,7 +72,7 @@ f = (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, callCount = callCount + 1; }; -f(false, '', NaN, 0, null, obj); +ref(false, '', NaN, 0, null, obj); assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); diff --git a/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js b/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js index d3c55e91b..6de08d0c5 100644 --- a/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js +++ b/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js @@ -53,13 +53,14 @@ info: | ---*/ var callCount = 0; -var f; -f = (fromLiteral = 23, fromExpr = 45, fromHole = 99) => { +// Stores a reference `ref` for case evaluation +var ref; +ref = (fromLiteral = 23, fromExpr = 45, fromHole = 99) => { assert.sameValue(fromLiteral, 23); assert.sameValue(fromExpr, 45); assert.sameValue(fromHole, 99); callCount = callCount + 1; }; -f(undefined, void 0); +ref(undefined, void 0); assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/params-dflt-ref-prior.js b/test/language/expressions/arrow-function/params-dflt-ref-prior.js index 41111ad74..bb39e8686 100644 --- a/test/language/expressions/arrow-function/params-dflt-ref-prior.js +++ b/test/language/expressions/arrow-function/params-dflt-ref-prior.js @@ -50,13 +50,14 @@ info: | var x = 0; var callCount = 0; -var f; -f = (x, y = x, z = y) => { +// Stores a reference `ref` for case evaluation +var ref; +ref = (x, y = x, z = y) => { assert.sameValue(x, 3, 'first argument value'); assert.sameValue(y, 3, 'second argument value'); assert.sameValue(z, 3, 'third argument value'); callCount = callCount + 1; }; -f(3); +ref(3); assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/params-trailing-comma-dflt-param.js b/test/language/expressions/arrow-function/params-trailing-comma-dflt-param.js new file mode 100644 index 000000000..833404965 --- /dev/null +++ b/test/language/expressions/arrow-function/params-trailing-comma-dflt-param.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-dflt-param.case +// - src/params/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using default parameters (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a, b = 39,) => { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, undefined, 1); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); diff --git a/test/language/expressions/arrow-function/params-trailing-comma-multiple-param.js b/test/language/expressions/arrow-function/params-trailing-comma-multiple-param.js new file mode 100644 index 000000000..639dab0f5 --- /dev/null +++ b/test/language/expressions/arrow-function/params-trailing-comma-multiple-param.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-multiple-param.case +// - src/params/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using multiple parameters (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a, b,) => { + assert.sameValue(a, 42); + assert.sameValue(b, 39); + callCount = callCount + 1; +}; + +ref(42, 39, 1); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 2, 'length is properly set'); diff --git a/test/language/expressions/arrow-function/params-trailing-comma-rest-early-error.js b/test/language/expressions/arrow-function/params-trailing-comma-rest-early-error.js new file mode 100644 index 000000000..7c42cae00 --- /dev/null +++ b/test/language/expressions/arrow-function/params-trailing-comma-rest-early-error.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-rest-early-error.case +// - src/params/syntax/arrow-function.template +/*--- +description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +negative: + phase: early + type: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : + [empty] + FunctionRestParameter[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] + FormalParameterList[?Yield, ?Await] , + FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await] +---*/ + +0, (...a,) => { + +}; diff --git a/test/language/expressions/arrow-function/params-trailing-comma-single-param.js b/test/language/expressions/arrow-function/params-trailing-comma-single-param.js new file mode 100644 index 000000000..4ba05c84a --- /dev/null +++ b/test/language/expressions/arrow-function/params-trailing-comma-single-param.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/params/trailing-comma-single-param.case +// - src/params/default/arrow-function.template +/*--- +description: A trailing comma should not increase the respective length, using a single parameter (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Trailing comma in the parameters list + + 14.1 Function Definitions + + FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] , +---*/ + +var callCount = 0; +// Stores a reference `ref` for case evaluation +var ref; +ref = (a,) => { + assert.sameValue(a, 42); + callCount = callCount + 1; +}; + +ref(42, 39); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(ref.length, 1, 'length is properly set'); |