tc39 / test262

Official ECMAScript Conformance Test Suite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add coverage for dynamic import

leobalter opened this issue · comments

currently on stage 3.

https://github.com/tc39/proposal-dynamic-import

Coverage Checklist for import()

Default Templates

general places it can be found as a CallExpression

  • top level
  • consise body of an ArrowFunction
  • function body of an ArrowFunction
  • consise body of an Async ArrowFunction
  • function body of an Async ArrowFunction
  • Used in async generators
  • await position of an async function
  • return await position of an async function
  • nested in an async function
  • labeled blocks
  • blocks
  • do while
  • else braceless
  • else block
  • if braceless
  • if block
  • while block
  • inside with

Cases

Syntax

  • assignment expression is not optional assignment-expr-not-optional.case
  • empty string is a valid assignment expression (not a syntax error) empty-str-is-valid-assign-expr.case
  • Forbidden Extensions: ImportCall must not be extended. (Only one assignment expression allowed)
    • no trailing comma, it's not an arguments list (#1832)
    • no other expressions (#1832)

Common usage

  • indirect update default binding eval-gtbndng-indirect-update-dflt.case
  • indirect update named binding eval-gtbndng-indirect-update-dflt.case
  • Assignment Expression evaluations. Most can be used as syntax tests only, e.g. exprs evaluating to a boolean value) or error catching
    • ConditionalExpression
      • Primary Expressions on the import Assign. Expr. position (?)
      • Cover Parenthesis expressions
      • ...
    • YieldExpression
      • Check yield usage
    • ArrowFunction
    • AsyncArrowFunction
    • LeftHandSideExpression = AssignmentExpression
    • LeftHandSideExpression AssignmentOperator AssignmentExpression
  • ToString on the AssignmentExpression value Let specifierString be ToString(specifier).
    • If AbruptRejectPromise(specifierString, promiseCapability).
  • nest import() in CallExpressions
    • import(import(...)) (#1832)
    • ... (other CallExpressions here)
  • Goal target can be a script code (not module code)
    • in this case, it should not export anything (and it's not a SyntaxError like in static imports)
    • indirect updates
  • Goal target can be a module code (having module specific syntax)
  • module code on host syntax
  • Multiple imports on the same imported module
    • verify indirect updates
    • Imported module is only evaluated once. test/language/module-code/dynamic-import/eval-rqstd-once.js
    • Self loading module only evaluates once. test/language/module-code/dynamic-import/eval-self-once-module.js
    • Self loading script evaluates again once for import(). test/language/module-code/dynamic-import/eval-self-once-script.js
  • ImportCall in runtime returns a Promise
    • Verify ctor
    • Use in Promise.all?
    • await resolving (include failures)
    • Use Promise.prototype
    • Promise.resolve
  • Captures exported operations of .. in .. in exported values. test/language/module-code/dynamic-import/eval-export-dflt-expr-in.js
  • Does not create a default property if default export is not given
  • imported value is an object with the exported names, including default
  • Returns abrupt completion from GetValue on AssignmentExpression (not a promise reject)
  • ToString on specifier
    • Abrupt completions should reject the promise

Resolve Moduled Namespace object

  • Symbol.toStringTag
  • no Symbol.iterator
  • prop desc of imported names
  • imported symbols on own property keys internals
  • internals https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects
  • setting custom immutable prototype
  • prototype is null
  • References observe the mutation of initialized bindings ([[Get]] on bindings after changing their values)
  • The [[OwnPropertyKeys]] internal method includes entries for all binding types

Non generated tests

  • Self importing test files
    • default name binding test/language/module-code/dynamic-import/eval-export-dflt-cls-anon.js
    • test/language/module-code/dynamic-import/eval-export-dflt-cls-name-meth.js
    • test/language/module-code/dynamic-import/eval-export-dflt-cls-named.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-cls-anon.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-cls-name-meth.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-cls-named.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-fn-anon.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-fn-named.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-gen-anon.js
    • test/language/module-code/dynamic-import/eval-export-dflt-expr-gen-named.js

Error catching

  • resolved runtime error (TypeError) eval-rqstd-abrupt-typeerror.case
  • resolved runtime error (URIError) eval-rqstd-abrupt-urierror.case
  • ambiguous import
  • circular import error
  • File does not exist (#1832)

This has found a sufficient amount of tests. Test262 is still welcoming to further coverage if any is observed.