test262/test/language
Mike Pennisi 4273ad1fa7 Module semantics: declaration instantiation
Files whose name ends in `_.js` are not themselves valid Test262 tests
and should not be interpreted as such by test runners.

---

Because the tests in this patch concern declaration *instantiation*,
care has been taken to avoid asserting binding values following
evaluation. Because a given module's dependencies are evaluated prior to
the module itself, this is only observable in modules which import their
own bindings.

A separate patch dedicated to the evaluation of module code asserts the
behavior of bindings following evaluation.

---

For tests that concern the creation of a module namespace object, this
patch relies on the semantics of the `in` operator. The `in` operator
uses the [[HasProperty]] internal method and avoids testing unrelated
semantics concerning binding resolution. Those semantics should be
explicitly asserted with a separate set of tests dedicated to that
purpose.

---

One test case which is notably missing is error resulting from a cycle
due to an `import` declaration (under the current file naming scheme,
such a test might be named `instn-named-err-circular.js`). Due to the
recursive nature of ModuleDeclarationInstantiation, it is not
technically possible for a circular request to be found in step 12.c.i.
Cycles rely on at least 2 `export` declarations, and because these are
resolved *before* imports, any cycle would trigger failure prior to step
12.c.

---

One aspect of *module* resolution that makes ordering observable is the
fact that resolution can fail in two distinct ways (i.e. with a
SyntaxError or with a ReferenceError). This patch includes tests that
leverage this detail in order to assert that modules are resolved in the
correct sequence.

However, from the perspective of the ECMA-262 specification, the
ordering of *export* (e.g. binding) resolution is not observable. This
is due to restrictions on the grammar, where each export is independent.
When *export* resolution fails, it does so with instances of SyntaxError
alone, precluding the above strategy.

So while ModuleDeclarationInstantiation resolves the exports of the
module's dependencies in the following order:

1. "Indirect" exports, e.g.
   - `export { x } from './y.js';`
   - `export { x as z } from './y.js';`
   - `import { x } from './y.js'; export { x };`
2. "Star" imports
   - `import * as ns from './y.js';`
3. "Named" (my word) imports
   - `import x from './y.js';`
   - `import { x } from './y.js';`
   - `import { x as z } from './y.js';`

Intentional failures cannot be used to discern resolution ordering.
2016-03-29 12:33:42 -04:00
..
arguments-object Improve compatibility for engines without support for Annex B 2015-09-07 20:40:09 +02:00
asi Remove a blank line to stop confusing YAML parsers 2016-03-04 15:01:01 -05:00
block-scope Invalid language tests 2015-04-27 16:56:19 +02:00
comments Reorganize ./test 2014-12-07 15:33:09 -08:00
computed-property-names Invalid language tests 2015-04-27 16:56:19 +02:00
default-parameters Add tests for default parameters 2015-09-02 18:01:51 -04:00
destructuring/binding ObjectBindingPatterns can't end with multiple commas 2015-12-29 16:50:23 -05:00
directive-prologue Replace runTestCase with assert helpers [test/language/directive-prologue] 2015-08-13 17:35:04 +02:00
eval-code Update meta data: `id` to `esid` 2016-03-10 19:46:46 -05:00
expressions Convert "info" to "description" 2016-02-23 14:24:08 -08:00
function-code s/id/esid 2016-02-22 09:47:42 -05:00
future-reserved-words Replace runTestCase with assert.throws [test/language/] 2015-08-11 17:43:21 +02:00
global-code Update meta data: `id` to `esid` 2016-03-10 19:46:46 -05:00
identifier-resolution Add tests for well-known Symbol: @@unscopables 2015-10-05 11:57:31 -04:00
identifiers Remove extraneous indent in header, for consistency 2015-08-24 15:24:10 -07:00
import - Remove inline license 2015-07-17 19:55:00 +02:00
keywords Reorganize ./test 2014-12-07 15:33:09 -08:00
line-terminators Replace runTestCase with assert.throws [test/language/] 2015-08-11 17:43:21 +02:00
literals Convert binary integers to octal in octal integer tests 2015-09-30 08:54:45 -07:00
module-code Module semantics: declaration instantiation 2016-03-29 12:33:42 -04:00
punctuators Fix strict mode errors in language 2015-05-08 17:27:52 +02:00
reserved-words Update meta data: `id` to `esid` 2016-03-10 19:46:46 -05:00
rest-parameters s/id/esid 2016-02-22 09:47:42 -05:00
source-text Remove links to hg.ecmascript.org 2015-07-17 17:43:09 +02:00
statements Merge pull request #541 from bocoup/statement-decl 2016-03-18 15:48:44 -04:00
types Remove unused harness file 2016-02-12 13:44:18 -05:00
white-space Fix strict mode errors in language/{identifiers, line-terminators, white-space} 2015-05-08 17:33:33 +02:00