From 19eb1d2e02c31ba813fe0ff5d10ea2c09a911fb5 Mon Sep 17 00:00:00 2001 From: Joseph Pecoraro Date: Thu, 4 May 2017 08:22:28 -0700 Subject: [PATCH] Add tests for completion value of function / class declaration statements (#1012) --- .../statements/async-function/cptn-decl.js | 13 +++++++++++++ test/language/statements/class/cptn-decl.js | 14 ++++++++++++++ test/language/statements/function/cptn-decl.js | 13 +++++++++++++ .../language/statements/generators/cptn-decl.js | 17 +++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 test/language/statements/async-function/cptn-decl.js create mode 100644 test/language/statements/class/cptn-decl.js create mode 100644 test/language/statements/function/cptn-decl.js create mode 100644 test/language/statements/generators/cptn-decl.js diff --git a/test/language/statements/async-function/cptn-decl.js b/test/language/statements/async-function/cptn-decl.js new file mode 100644 index 0000000000..1bc375a892 --- /dev/null +++ b/test/language/statements/async-function/cptn-decl.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-async-function-definitions-runtime-semantics-evaluation +description: Async function declaration completion value is empty. +info: > + AsyncFunctionDeclaration : async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + + 1. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('async function f() {}'), undefined); +assert.sameValue(eval('1; async function f() {}'), 1); diff --git a/test/language/statements/class/cptn-decl.js b/test/language/statements/class/cptn-decl.js new file mode 100644 index 0000000000..709b23026f --- /dev/null +++ b/test/language/statements/class/cptn-decl.js @@ -0,0 +1,14 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-class-definitions-runtime-semantics-evaluation +description: Class declaration completion value is empty. +info: > + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Perform ? BindingClassDeclarationEvaluation of this ClassDeclaration. + 2. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('class C {}'), undefined); +assert.sameValue(eval('1; class C {}'), 1); diff --git a/test/language/statements/function/cptn-decl.js b/test/language/statements/function/cptn-decl.js new file mode 100644 index 0000000000..7960fd49fa --- /dev/null +++ b/test/language/statements/function/cptn-decl.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions-runtime-semantics-evaluation +description: Function declaration completion value is empty. +info: > + FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } + + 1. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('function f() {}'), undefined); +assert.sameValue(eval('1; function f() {}'), 1); diff --git a/test/language/statements/generators/cptn-decl.js b/test/language/statements/generators/cptn-decl.js new file mode 100644 index 0000000000..ccf8a92352 --- /dev/null +++ b/test/language/statements/generators/cptn-decl.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Apple Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-statement-semantics-runtime-semantics-evaluation +description: Generator declaration completion value is empty. +info: > + GeneratorDeclaration[Yield, Await, Default]: + + function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody } + + HoistableDeclaration : GeneratorDeclaration + + 1. Return NormalCompletion(empty). +---*/ + +assert.sameValue(eval('function* f() {}'), undefined); +assert.sameValue(eval('1; function* f() {}'), 1);