[ES6] Enable ES6 Module in JSC shell by default
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Sep 2015 07:44:35 +0000 (07:44 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Sep 2015 07:44:35 +0000 (07:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148689

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Enable ES6 Modules in JSC shell by default. Compile time flag is left for WebCore.
Since the entry point to evaluate the modules are completely separated from the usual
entry point to evaluate the script, we can safely enable ES6 modules in JSC shell.

And add bunch of tests for ES6 Modules.

* jsc.cpp:
(GlobalObject::finishCreation):
(functionLoadModule):
(runWithScripts):
(printUsageStatement): Deleted.
(CommandLine::parseArguments): Deleted.
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner): Deleted.
* tests/modules.yaml: Added.
* tests/modules/aliasing.js: Added.
* tests/modules/aliasing/drink-2.js: Added.
(export.let.Cappuccino.string_appeared_here.export.changeCappuccino):
* tests/modules/aliasing/drink.js: Added.
(export.changeCocoa):
* tests/modules/cyclic-may-produce-tdz.js: Added.
* tests/modules/cyclic-may-produce-tdz/1.js: Added.
* tests/modules/cyclic-may-produce-tdz/2.js: Added.
* tests/modules/default-error/main.js: Added.
* tests/modules/default-value-case-should-be-copied.js: Added.
* tests/modules/default-value-case-should-be-copied/module.js: Added.
(export.changeValue):
* tests/modules/defaults.js: Added.
* tests/modules/defaults/Cappuccino.js: Added.
* tests/modules/defaults/Cocoa.js: Added.
(export.default.Cocoa):
* tests/modules/defaults/Matcha.js: Added.
* tests/modules/destructuring-export.js: Added.
* tests/modules/destructuring-export/array.js: Added.
* tests/modules/destructuring-export/main.js: Added.
* tests/modules/execution-order-cyclic.js: Added.
* tests/modules/execution-order-cyclic/1.js: Added.
* tests/modules/execution-order-cyclic/10.js: Added.
* tests/modules/execution-order-cyclic/11.js: Added.
* tests/modules/execution-order-cyclic/2.js: Added.
* tests/modules/execution-order-cyclic/3.js: Added.
* tests/modules/execution-order-cyclic/4.js: Added.
* tests/modules/execution-order-cyclic/5.js: Added.
* tests/modules/execution-order-cyclic/6.js: Added.
* tests/modules/execution-order-cyclic/7.js: Added.
* tests/modules/execution-order-cyclic/8.js: Added.
* tests/modules/execution-order-cyclic/9.js: Added.
* tests/modules/execution-order-dag.js: Added.
* tests/modules/execution-order-dag/1.js: Added.
* tests/modules/execution-order-dag/10.js: Added.
* tests/modules/execution-order-dag/2.js: Added.
* tests/modules/execution-order-dag/3.js: Added.
* tests/modules/execution-order-dag/4.js: Added.
* tests/modules/execution-order-dag/5.js: Added.
* tests/modules/execution-order-dag/6.js: Added.
* tests/modules/execution-order-dag/7.js: Added.
* tests/modules/execution-order-dag/8.js: Added.
* tests/modules/execution-order-dag/9.js: Added.
* tests/modules/execution-order-depth.js: Added.
* tests/modules/execution-order-depth/1.js: Added.
* tests/modules/execution-order-depth/2.js: Added.
* tests/modules/execution-order-depth/3.js: Added.
* tests/modules/execution-order-self.js: Added.
* tests/modules/execution-order-sibling.js: Added.
* tests/modules/execution-order-sibling/1.js: Added.
* tests/modules/execution-order-sibling/2.js: Added.
* tests/modules/execution-order-sibling/3.js: Added.
* tests/modules/execution-order-tree.js: Added.
* tests/modules/execution-order-tree/1.js: Added.
* tests/modules/execution-order-tree/10.js: Added.
* tests/modules/execution-order-tree/11.js: Added.
* tests/modules/execution-order-tree/2.js: Added.
* tests/modules/execution-order-tree/3.js: Added.
* tests/modules/execution-order-tree/4.js: Added.
* tests/modules/execution-order-tree/5.js: Added.
* tests/modules/execution-order-tree/6.js: Added.
* tests/modules/execution-order-tree/7.js: Added.
* tests/modules/execution-order-tree/8.js: Added.
* tests/modules/execution-order-tree/9.js: Added.
* tests/modules/export-conflict-ok.js: Added.
* tests/modules/export-conflict-ok/A.js: Added.
* tests/modules/export-conflict-ok/B.js: Added.
* tests/modules/export-conflict-ok/main.js: Added.
* tests/modules/export-from.js: Added.
* tests/modules/export-from/main.js: Added.
* tests/modules/export-from/second.js: Added.
* tests/modules/export-with-declarations-list.js: Added.
* tests/modules/export-with-declarations-list/main.js: Added.
* tests/modules/exported-function-may-be-called-before-module-is-executed.js: Added.
* tests/modules/exported-function-may-be-called-before-module-is-executed/1.js: Added.
* tests/modules/exported-function-may-be-called-before-module-is-executed/2.js: Added.
(export.add):
(export.raise):
* tests/modules/import-error.js: Added.
* tests/modules/import-error/export-ambiguous-1.js: Added.
* tests/modules/import-error/export-ambiguous-2.js: Added.
* tests/modules/import-error/export-ambiguous.js: Added.
* tests/modules/import-error/export-default-from-star-2.js: Added.
(export.default.Cocoa):
* tests/modules/import-error/export-default-from-star.js: Added.
* tests/modules/import-error/export-not-found.js: Added.
* tests/modules/import-error/import-ambiguous.js: Added.
* tests/modules/import-error/import-default-from-star.js: Added.
* tests/modules/import-error/import-not-found.js: Added.
* tests/modules/imported-bindings-are-immutable.js: Added.
* tests/modules/imported-bindings-are-immutable/bindings.js: Added.
(export.functionDeclaration):
(export.classDeclaration):
* tests/modules/imported-bindings-can-be-changed-in-original-module.js: Added.
* tests/modules/imported-bindings-can-be-changed-in-original-module/bindings.js: Added.
* tests/modules/indirect-export-error.js: Added.
* tests/modules/indirect-export-error/indirect-export-ambiguous-2.js: Added.
* tests/modules/indirect-export-error/indirect-export-ambiguous-3.js: Added.
* tests/modules/indirect-export-error/indirect-export-ambiguous-4.js: Added.
* tests/modules/indirect-export-error/indirect-export-ambiguous.js: Added.
* tests/modules/indirect-export-error/indirect-export-default-2.js: Added.
* tests/modules/indirect-export-error/indirect-export-default-3.js: Added.
(export.default.Cocoa):
* tests/modules/indirect-export-error/indirect-export-default.js: Added.
* tests/modules/indirect-export-error/indirect-export-not-found-2.js: Added.
* tests/modules/indirect-export-error/indirect-export-not-found.js: Added.
* tests/modules/module-eval.js: Added.
* tests/modules/module-eval/A.js: Added.
* tests/modules/module-eval/B.js: Added.
* tests/modules/module-eval/drink.js: Added.
* tests/modules/module-is-strict-code.js: Added.
* tests/modules/namespace-ambiguous.js: Added.
* tests/modules/namespace-ambiguous/ambiguous-2.js: Added.
* tests/modules/namespace-ambiguous/ambiguous-3.js: Added.
* tests/modules/namespace-ambiguous/ambiguous-4.js: Added.
* tests/modules/namespace-ambiguous/ambiguous.js: Added.
* tests/modules/namespace-error.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-2.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-3.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-4.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-5.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-6.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-7.js: Added.
* tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity.js: Added.
* tests/modules/namespace-tdz.js: Added.
* tests/modules/namespace-tdz/A.js: Added.
* tests/modules/namespace-tdz/B.js: Added.
(export.later):
* tests/modules/namespace-tdz/main.js: Added.
* tests/modules/namespace.js: Added.
* tests/modules/namespace/additional-drink.js: Added.
* tests/modules/namespace/drink.js: Added.
(export.default.changeCappuccino):
* tests/modules/namespace/more-additional-drink.js: Added.
* tests/modules/resources/assert.js: Added.
(export.shouldBe):
(export.shouldThrow):
* tests/modules/scopes.js: Added.
* tests/modules/scopes/additional-drink.js: Added.
* tests/modules/scopes/drink.js: Added.
(export.default.changeCappuccino):
* tests/modules/scopes/more-additional-drink.js: Added.
* tests/modules/this-should-be-undefined.js: Added.
* tests/stress/modules-syntax-error-with-names.js:
* tests/stress/modules-syntax-error.js:
* tests/stress/modules-syntax.js:

Tools:

* Scripts/run-javascriptcore-tests:
(runJSCStressTests):
* Scripts/run-jsc-stress-tests:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189431 268f45cc-cd09-0410-ab3c-d52691b4dbfc

138 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/tests/modules.yaml [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/aliasing.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/aliasing/drink-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/aliasing/drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/default-error/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied/module.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/defaults.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/defaults/Cappuccino.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/defaults/Cocoa.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/defaults/Matcha.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/destructuring-export.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/destructuring-export/array.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/destructuring-export/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/10.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/11.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/5.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/6.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/7.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/8.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-cyclic/9.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/10.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/5.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/6.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/7.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/8.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-dag/9.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-depth.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-depth/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-depth/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-depth/3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-self.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-sibling.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-sibling/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-sibling/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-sibling/3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/10.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/11.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/5.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/6.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/7.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/8.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/execution-order-tree/9.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-conflict-ok.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-conflict-ok/A.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-conflict-ok/B.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-conflict-ok/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-from.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-from/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-from/second.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-with-declarations-list.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/export-with-declarations-list/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-ambiguous.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-default-from-star-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-default-from-star.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/export-not-found.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/import-ambiguous.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/import-default-from-star.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/import-error/import-not-found.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable/bindings.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module/bindings.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/module-eval.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/module-eval/A.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/module-eval/B.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/module-eval/drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/module-is-strict-code.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-ambiguous.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-5.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-6.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-7.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-tdz.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-tdz/A.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-tdz/B.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace-tdz/main.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace/additional-drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace/drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/namespace/more-additional-drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/resources/assert.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/scopes.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/scopes/additional-drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/scopes/drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/scopes/more-additional-drink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/modules/this-should-be-undefined.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/modules-syntax-error-with-names.js
Source/JavaScriptCore/tests/stress/modules-syntax-error.js
Source/JavaScriptCore/tests/stress/modules-syntax.js
Tools/ChangeLog
Tools/Scripts/run-javascriptcore-tests
Tools/Scripts/run-jsc-stress-tests

index 9851abf..71debeb 100644 (file)
@@ -1,5 +1,174 @@
 2015-09-05  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        [ES6] Enable ES6 Module in JSC shell by default
+        https://bugs.webkit.org/show_bug.cgi?id=148689
+
+        Reviewed by Geoffrey Garen.
+
+        Enable ES6 Modules in JSC shell by default. Compile time flag is left for WebCore.
+        Since the entry point to evaluate the modules are completely separated from the usual
+        entry point to evaluate the script, we can safely enable ES6 modules in JSC shell.
+
+        And add bunch of tests for ES6 Modules.
+
+        * jsc.cpp:
+        (GlobalObject::finishCreation):
+        (functionLoadModule):
+        (runWithScripts):
+        (printUsageStatement): Deleted.
+        (CommandLine::parseArguments): Deleted.
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseInner): Deleted.
+        * tests/modules.yaml: Added.
+        * tests/modules/aliasing.js: Added.
+        * tests/modules/aliasing/drink-2.js: Added.
+        (export.let.Cappuccino.string_appeared_here.export.changeCappuccino):
+        * tests/modules/aliasing/drink.js: Added.
+        (export.changeCocoa):
+        * tests/modules/cyclic-may-produce-tdz.js: Added.
+        * tests/modules/cyclic-may-produce-tdz/1.js: Added.
+        * tests/modules/cyclic-may-produce-tdz/2.js: Added.
+        * tests/modules/default-error/main.js: Added.
+        * tests/modules/default-value-case-should-be-copied.js: Added.
+        * tests/modules/default-value-case-should-be-copied/module.js: Added.
+        (export.changeValue):
+        * tests/modules/defaults.js: Added.
+        * tests/modules/defaults/Cappuccino.js: Added.
+        * tests/modules/defaults/Cocoa.js: Added.
+        (export.default.Cocoa):
+        * tests/modules/defaults/Matcha.js: Added.
+        * tests/modules/destructuring-export.js: Added.
+        * tests/modules/destructuring-export/array.js: Added.
+        * tests/modules/destructuring-export/main.js: Added.
+        * tests/modules/execution-order-cyclic.js: Added.
+        * tests/modules/execution-order-cyclic/1.js: Added.
+        * tests/modules/execution-order-cyclic/10.js: Added.
+        * tests/modules/execution-order-cyclic/11.js: Added.
+        * tests/modules/execution-order-cyclic/2.js: Added.
+        * tests/modules/execution-order-cyclic/3.js: Added.
+        * tests/modules/execution-order-cyclic/4.js: Added.
+        * tests/modules/execution-order-cyclic/5.js: Added.
+        * tests/modules/execution-order-cyclic/6.js: Added.
+        * tests/modules/execution-order-cyclic/7.js: Added.
+        * tests/modules/execution-order-cyclic/8.js: Added.
+        * tests/modules/execution-order-cyclic/9.js: Added.
+        * tests/modules/execution-order-dag.js: Added.
+        * tests/modules/execution-order-dag/1.js: Added.
+        * tests/modules/execution-order-dag/10.js: Added.
+        * tests/modules/execution-order-dag/2.js: Added.
+        * tests/modules/execution-order-dag/3.js: Added.
+        * tests/modules/execution-order-dag/4.js: Added.
+        * tests/modules/execution-order-dag/5.js: Added.
+        * tests/modules/execution-order-dag/6.js: Added.
+        * tests/modules/execution-order-dag/7.js: Added.
+        * tests/modules/execution-order-dag/8.js: Added.
+        * tests/modules/execution-order-dag/9.js: Added.
+        * tests/modules/execution-order-depth.js: Added.
+        * tests/modules/execution-order-depth/1.js: Added.
+        * tests/modules/execution-order-depth/2.js: Added.
+        * tests/modules/execution-order-depth/3.js: Added.
+        * tests/modules/execution-order-self.js: Added.
+        * tests/modules/execution-order-sibling.js: Added.
+        * tests/modules/execution-order-sibling/1.js: Added.
+        * tests/modules/execution-order-sibling/2.js: Added.
+        * tests/modules/execution-order-sibling/3.js: Added.
+        * tests/modules/execution-order-tree.js: Added.
+        * tests/modules/execution-order-tree/1.js: Added.
+        * tests/modules/execution-order-tree/10.js: Added.
+        * tests/modules/execution-order-tree/11.js: Added.
+        * tests/modules/execution-order-tree/2.js: Added.
+        * tests/modules/execution-order-tree/3.js: Added.
+        * tests/modules/execution-order-tree/4.js: Added.
+        * tests/modules/execution-order-tree/5.js: Added.
+        * tests/modules/execution-order-tree/6.js: Added.
+        * tests/modules/execution-order-tree/7.js: Added.
+        * tests/modules/execution-order-tree/8.js: Added.
+        * tests/modules/execution-order-tree/9.js: Added.
+        * tests/modules/export-conflict-ok.js: Added.
+        * tests/modules/export-conflict-ok/A.js: Added.
+        * tests/modules/export-conflict-ok/B.js: Added.
+        * tests/modules/export-conflict-ok/main.js: Added.
+        * tests/modules/export-from.js: Added.
+        * tests/modules/export-from/main.js: Added.
+        * tests/modules/export-from/second.js: Added.
+        * tests/modules/export-with-declarations-list.js: Added.
+        * tests/modules/export-with-declarations-list/main.js: Added.
+        * tests/modules/exported-function-may-be-called-before-module-is-executed.js: Added.
+        * tests/modules/exported-function-may-be-called-before-module-is-executed/1.js: Added.
+        * tests/modules/exported-function-may-be-called-before-module-is-executed/2.js: Added.
+        (export.add):
+        (export.raise):
+        * tests/modules/import-error.js: Added.
+        * tests/modules/import-error/export-ambiguous-1.js: Added.
+        * tests/modules/import-error/export-ambiguous-2.js: Added.
+        * tests/modules/import-error/export-ambiguous.js: Added.
+        * tests/modules/import-error/export-default-from-star-2.js: Added.
+        (export.default.Cocoa):
+        * tests/modules/import-error/export-default-from-star.js: Added.
+        * tests/modules/import-error/export-not-found.js: Added.
+        * tests/modules/import-error/import-ambiguous.js: Added.
+        * tests/modules/import-error/import-default-from-star.js: Added.
+        * tests/modules/import-error/import-not-found.js: Added.
+        * tests/modules/imported-bindings-are-immutable.js: Added.
+        * tests/modules/imported-bindings-are-immutable/bindings.js: Added.
+        (export.functionDeclaration):
+        (export.classDeclaration):
+        * tests/modules/imported-bindings-can-be-changed-in-original-module.js: Added.
+        * tests/modules/imported-bindings-can-be-changed-in-original-module/bindings.js: Added.
+        * tests/modules/indirect-export-error.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-ambiguous-2.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-ambiguous-3.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-ambiguous-4.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-ambiguous.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-default-2.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-default-3.js: Added.
+        (export.default.Cocoa):
+        * tests/modules/indirect-export-error/indirect-export-default.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-not-found-2.js: Added.
+        * tests/modules/indirect-export-error/indirect-export-not-found.js: Added.
+        * tests/modules/module-eval.js: Added.
+        * tests/modules/module-eval/A.js: Added.
+        * tests/modules/module-eval/B.js: Added.
+        * tests/modules/module-eval/drink.js: Added.
+        * tests/modules/module-is-strict-code.js: Added.
+        * tests/modules/namespace-ambiguous.js: Added.
+        * tests/modules/namespace-ambiguous/ambiguous-2.js: Added.
+        * tests/modules/namespace-ambiguous/ambiguous-3.js: Added.
+        * tests/modules/namespace-ambiguous/ambiguous-4.js: Added.
+        * tests/modules/namespace-ambiguous/ambiguous.js: Added.
+        * tests/modules/namespace-error.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-2.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-3.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-4.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-5.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-6.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-7.js: Added.
+        * tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity.js: Added.
+        * tests/modules/namespace-tdz.js: Added.
+        * tests/modules/namespace-tdz/A.js: Added.
+        * tests/modules/namespace-tdz/B.js: Added.
+        (export.later):
+        * tests/modules/namespace-tdz/main.js: Added.
+        * tests/modules/namespace.js: Added.
+        * tests/modules/namespace/additional-drink.js: Added.
+        * tests/modules/namespace/drink.js: Added.
+        (export.default.changeCappuccino):
+        * tests/modules/namespace/more-additional-drink.js: Added.
+        * tests/modules/resources/assert.js: Added.
+        (export.shouldBe):
+        (export.shouldThrow):
+        * tests/modules/scopes.js: Added.
+        * tests/modules/scopes/additional-drink.js: Added.
+        * tests/modules/scopes/drink.js: Added.
+        (export.default.changeCappuccino):
+        * tests/modules/scopes/more-additional-drink.js: Added.
+        * tests/modules/this-should-be-undefined.js: Added.
+        * tests/stress/modules-syntax-error-with-names.js:
+        * tests/stress/modules-syntax-error.js:
+        * tests/stress/modules-syntax.js:
+
+2015-09-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
         [ES6] Implement ModuleNamespaceObject
         https://bugs.webkit.org/show_bug.cgi?id=148705
 
index 74cb331..80af781 100644 (file)
@@ -499,9 +499,8 @@ static EncodedJSValue JSC_HOST_CALL functionDrainMicrotasks(ExecState*);
 #if ENABLE(WEBASSEMBLY)
 static EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState*);
 #endif
-#if ENABLE(ES6_MODULES)
+static EncodedJSValue JSC_HOST_CALL functionLoadModule(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState*);
-#endif
 
 #if ENABLE(SAMPLING_FLAGS)
 static EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);
@@ -678,9 +677,8 @@ protected:
 #if ENABLE(WEBASSEMBLY)
         addFunction(vm, "loadWebAssembly", functionLoadWebAssembly, 1);
 #endif
-#if ENABLE(ES6_MODULES)
+        addFunction(vm, "loadModule", functionLoadModule, 1);
         addFunction(vm, "checkModuleSyntax", functionCheckModuleSyntax, 1);
-#endif
 
         JSArray* array = constructEmptyArray(globalExec(), 0);
         for (size_t i = 0; i < arguments.size(); ++i)
@@ -1360,7 +1358,30 @@ EncodedJSValue JSC_HOST_CALL functionLoadWebAssembly(ExecState* exec)
 }
 #endif
 
-#if ENABLE(ES6_MODULES)
+EncodedJSValue JSC_HOST_CALL functionLoadModule(ExecState* exec)
+{
+    String fileName = exec->argument(0).toString(exec)->value(exec);
+    Vector<char> script;
+    if (!fillBufferWithContentsOfFile(fileName, script))
+        return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file."))));
+
+    JSInternalPromise* promise = evaluateModule(exec, fileName);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    JSValue error;
+    JSFunction* errorHandler = JSNativeStdFunction::create(exec->vm(), exec->lexicalGlobalObject(), 1, String(), [&](ExecState* exec) {
+        error = exec->argument(0);
+        return JSValue::encode(jsUndefined());
+    });
+
+    promise->then(exec, nullptr, errorHandler);
+    exec->vm().drainMicrotasks();
+    if (error)
+        return JSValue::encode(exec->vm().throwException(exec, error));
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState* exec)
 {
     String source = exec->argument(0).toString(exec)->value(exec);
@@ -1376,7 +1397,6 @@ EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState* exec)
         exec->vm().throwException(exec, jsNontrivialString(exec, toString("SyntaxError: ", error.message(), ":", error.line())));
     return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
 }
-#endif
 
 // Use SEH for Release builds only to get rid of the crash report dialog
 // (luckily the same tests fail in Release and Debug builds so far). Need to
@@ -1504,31 +1524,23 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
     VM& vm = globalObject->vm();
     bool success = true;
 
-#if ENABLE(ES6_MODULES)
     JSFunction* errorHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&](ExecState* exec) {
         success = false;
         dumpException(globalObject, exec->argument(0));
         return JSValue::encode(jsUndefined());
     });
-#endif
 
 #if ENABLE(SAMPLING_FLAGS)
     SamplingFlags::start();
 #endif
 
     for (size_t i = 0; i < scripts.size(); i++) {
-#if ENABLE(ES6_MODULES)
         JSInternalPromise* promise = nullptr;
-#endif
         if (scripts[i].isFile) {
             fileName = scripts[i].argument;
-            if (module) {
-#if ENABLE(ES6_MODULES)
+            if (module)
                 promise = evaluateModule(globalObject->globalExec(), fileName);
-#else
-                RELEASE_ASSERT_NOT_REACHED();
-#endif
-            } else {
+            else {
                 if (!fillBufferWithContentsOfFile(fileName, scriptBuffer))
                     return false; // fail early so we can catch missing files
                 script = scriptBuffer.data();
@@ -1541,15 +1553,11 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr
         vm.startSampling();
 
         if (module) {
-#if ENABLE(ES6_MODULES)
             if (!promise)
                 promise = evaluateModule(globalObject->globalExec(), jscSource(script, fileName));
             globalObject->globalExec()->clearException();
             promise->then(globalObject->globalExec(), nullptr, errorHandler);
             globalObject->vm().drainMicrotasks();
-#else
-            RELEASE_ASSERT_NOT_REACHED();
-#endif
         } else {
             NakedPtr<Exception> evaluationException;
             JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(script, fileName), JSValue(), evaluationException);
@@ -1648,9 +1656,7 @@ static NO_RETURN void printUsageStatement(bool help = false)
     fprintf(stderr, "  -f         Specifies a source file (deprecated)\n");
     fprintf(stderr, "  -h|--help  Prints this help message\n");
     fprintf(stderr, "  -i         Enables interactive mode (default if no files are specified)\n");
-#if ENABLE(ES6_MODULES)
     fprintf(stderr, "  -m         Execute as a module\n");
-#endif
 #if HAVE(SIGNAL_H)
     fprintf(stderr, "  -s         Installs signal handlers that exit on a crash (Unix platforms only)\n");
 #endif
@@ -1702,12 +1708,10 @@ void CommandLine::parseArguments(int argc, char** argv)
             m_profilerOutput = argv[i];
             continue;
         }
-#if ENABLE(ES6_MODULES)
         if (!strcmp(arg, "-m")) {
             m_module = true;
             continue;
         }
-#endif
         if (!strcmp(arg, "-s")) {
 #if HAVE(SIGNAL_H)
             signal(SIGILL, _exit);
index 08c12c5..c9be245 100644 (file)
@@ -269,10 +269,8 @@ String Parser<LexerType>::parseInner(const Identifier& calleeName, SourceParseMo
     if (!hasError()) {
         if (isArrowFunctionBodyExpression)
             sourceElements = parseArrowFunctionSingleExpressionBodySourceElements(context);
-#if ENABLE(ES6_MODULES)
         else if (isModuleParseMode(parseMode))
             sourceElements = parseModuleSourceElements(context, parseMode);
-#endif
         else
             sourceElements = parseSourceElements(context, CheckForStrictMode);
     }
diff --git a/Source/JavaScriptCore/tests/modules.yaml b/Source/JavaScriptCore/tests/modules.yaml
new file mode 100644 (file)
index 0000000..ab478f1
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (C) 2015 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+- path: modules
+  cmd: runModules
diff --git a/Source/JavaScriptCore/tests/modules/aliasing.js b/Source/JavaScriptCore/tests/modules/aliasing.js
new file mode 100644 (file)
index 0000000..cf5e3ee
--- /dev/null
@@ -0,0 +1,18 @@
+import { Cocoa as Drink, changeCocoa, SubDrink, changeCappuccino } from "./aliasing/drink.js"
+import { shouldBe, shouldThrow } from "./resources/assert.js";
+
+shouldBe(Drink, "Cocoa");
+shouldBe(SubDrink, "Cappuccino");
+shouldThrow(() => {
+    Cocoa
+}, `ReferenceError: Can't find variable: Cocoa`);
+
+shouldThrow(() => {
+    Cappuccino
+}, `ReferenceError: Can't find variable: Cappuccino`);
+
+changeCocoa("Mocha");
+shouldBe(Drink, "Mocha");
+
+changeCappuccino("Matcha");
+shouldBe(SubDrink, "Matcha");
diff --git a/Source/JavaScriptCore/tests/modules/aliasing/drink-2.js b/Source/JavaScriptCore/tests/modules/aliasing/drink-2.js
new file mode 100644 (file)
index 0000000..590ac8b
--- /dev/null
@@ -0,0 +1,5 @@
+export let Cappuccino = "Cappuccino"
+
+export function changeCappuccino(value) {
+    Cappuccino = value;
+}
diff --git a/Source/JavaScriptCore/tests/modules/aliasing/drink.js b/Source/JavaScriptCore/tests/modules/aliasing/drink.js
new file mode 100644 (file)
index 0000000..1da84a0
--- /dev/null
@@ -0,0 +1,7 @@
+export let Cocoa = "Cocoa";
+export function changeCocoa(value) {
+    Cocoa = value;
+}
+
+import { Cappuccino as SubDrink, changeCappuccino } from "drink-2.js"
+export { SubDrink, changeCappuccino }
diff --git a/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz.js b/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz.js
new file mode 100644 (file)
index 0000000..12bad60
--- /dev/null
@@ -0,0 +1,7 @@
+import { Cocoa, Cappuccino, Matcha } from "./cyclic-may-produce-tdz/2.js"
+import { shouldBe } from "./resources/assert.js";
+
+// All things are already set.
+shouldBe(Cocoa, "Cocoa");
+shouldBe(Cappuccino, "Cappuccino");
+shouldBe(Matcha, "Matcha");
diff --git a/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/1.js b/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/1.js
new file mode 100644 (file)
index 0000000..40c26f6
--- /dev/null
@@ -0,0 +1,12 @@
+import { Cappuccino, Matcha } from "./2.js"
+import { shouldThrow, shouldBe } from "../resources/assert.js";
+
+export let Cocoa = "Cocoa";
+
+// module "2" is not loaded yet, TDZ.
+shouldThrow(() => {
+    Cappuccino;
+}, `ReferenceError: Cannot access uninitialized variable.`);
+
+// But "Matcha" is variable (not lexical variable). It is already initialized as undefined.
+shouldBe(Matcha, undefined);
diff --git a/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/2.js b/Source/JavaScriptCore/tests/modules/cyclic-may-produce-tdz/2.js
new file mode 100644 (file)
index 0000000..20f1639
--- /dev/null
@@ -0,0 +1,15 @@
+import { Cocoa } from "./1.js"
+import { shouldBe } from "../resources/assert.js";
+
+export let Cappuccino = "Cappuccino";
+
+export var Matcha = "Matcha";
+
+// 1 is already loaded.
+shouldBe(Cocoa, "Cocoa");
+
+shouldBe(Cappuccino, "Cappuccino");
+shouldBe(Matcha, "Matcha");
+
+// Indirectly export "Cocoa"
+export { Cocoa };
diff --git a/Source/JavaScriptCore/tests/modules/default-error/main.js b/Source/JavaScriptCore/tests/modules/default-error/main.js
new file mode 100644 (file)
index 0000000..daab135
--- /dev/null
@@ -0,0 +1 @@
+import "A";
diff --git a/Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied.js b/Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied.js
new file mode 100644 (file)
index 0000000..65c50e5
--- /dev/null
@@ -0,0 +1,11 @@
+import * as namespace from "./default-value-case-should-be-copied/module.js"
+import value from "./default-value-case-should-be-copied/module.js"
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(value, 42);
+shouldBe(namespace.default, 42);
+
+namespace.changeValue(5000);
+
+shouldBe(value, 42);
+shouldBe(namespace.default, 42);
diff --git a/Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied/module.js b/Source/JavaScriptCore/tests/modules/default-value-case-should-be-copied/module.js
new file mode 100644 (file)
index 0000000..fcee338
--- /dev/null
@@ -0,0 +1,7 @@
+let value = 42;
+
+export default value;
+
+export function changeValue(v) {
+    value = v;
+}
diff --git a/Source/JavaScriptCore/tests/modules/defaults.js b/Source/JavaScriptCore/tests/modules/defaults.js
new file mode 100644 (file)
index 0000000..6bf727d
--- /dev/null
@@ -0,0 +1,10 @@
+import Cocoa from "./defaults/Cocoa.js"
+import { default as Cappuccino } from "./defaults/Cappuccino.js"
+import C2 from "./defaults/Cappuccino.js"
+import Matcha from "./defaults/Matcha.js"
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(new Cocoa().taste, 'awesome');
+shouldBe(Cappuccino, 'Cappuccino');
+shouldBe(C2 === Cappuccino, true);
+shouldBe(Matcha, 'Matcha');
diff --git a/Source/JavaScriptCore/tests/modules/defaults/Cappuccino.js b/Source/JavaScriptCore/tests/modules/defaults/Cappuccino.js
new file mode 100644 (file)
index 0000000..de92671
--- /dev/null
@@ -0,0 +1,4 @@
+
+var Cappuccino = 'Cappuccino';
+
+export { Cappuccino as default }
diff --git a/Source/JavaScriptCore/tests/modules/defaults/Cocoa.js b/Source/JavaScriptCore/tests/modules/defaults/Cocoa.js
new file mode 100644 (file)
index 0000000..f94a96c
--- /dev/null
@@ -0,0 +1,5 @@
+export default class Cocoa {
+    constructor() {
+        this.taste = 'awesome';
+    }
+}
diff --git a/Source/JavaScriptCore/tests/modules/defaults/Matcha.js b/Source/JavaScriptCore/tests/modules/defaults/Matcha.js
new file mode 100644 (file)
index 0000000..a26f2aa
--- /dev/null
@@ -0,0 +1 @@
+export default 'Matcha';
diff --git a/Source/JavaScriptCore/tests/modules/destructuring-export.js b/Source/JavaScriptCore/tests/modules/destructuring-export.js
new file mode 100644 (file)
index 0000000..161d631
--- /dev/null
@@ -0,0 +1,10 @@
+import * as namespace from "./destructuring-export/main.js"
+import { array } from "./destructuring-export/array.js"
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha"]`);
+shouldBe(namespace.Cocoa, 'Cocoa');
+shouldBe(namespace.Cappuccino, 'Cappuccino');
+shouldBe(namespace.Matcha, 'Matcha');
+
+shouldBe(JSON.stringify(array), `[1,2,3,4,5,6,7,8,9]`);
diff --git a/Source/JavaScriptCore/tests/modules/destructuring-export/array.js b/Source/JavaScriptCore/tests/modules/destructuring-export/array.js
new file mode 100644 (file)
index 0000000..509d98b
--- /dev/null
@@ -0,0 +1,3 @@
+var value = [1,2,3,4,5,6,7,8,9];
+
+export const [...array] = value.values();
diff --git a/Source/JavaScriptCore/tests/modules/destructuring-export/main.js b/Source/JavaScriptCore/tests/modules/destructuring-export/main.js
new file mode 100644 (file)
index 0000000..f2d9479
--- /dev/null
@@ -0,0 +1,16 @@
+
+const drinks = {
+    Cocoa: 'Cocoa',
+    inner: {
+        current: [ 'Matcha' ]
+    },
+    hello: 'Cappuccino'
+};
+
+export const {
+    Cocoa,
+    inner: {
+        current: [ Matcha ]
+    },
+    hello: Cappuccino
+} = drinks;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic.js
new file mode 100644 (file)
index 0000000..fe529dd
--- /dev/null
@@ -0,0 +1,5 @@
+import "./execution-order-cyclic/11.js"
+
+var global = (Function("return this"))();
+if (global.count !== 11)
+    throw new Error(`bad value ${global.count}`);
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/1.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/1.js
new file mode 100644 (file)
index 0000000..790fd8e
--- /dev/null
@@ -0,0 +1,5 @@
+import "./11.js"
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/10.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/10.js
new file mode 100644 (file)
index 0000000..9dce5d3
--- /dev/null
@@ -0,0 +1,7 @@
+import "./11.js"
+import "./9.js"
+
+var global = (Function("return this"))();
+if (global.count !== 9)
+    throw new Error(`bad value ${global.count}`);
+global.count = 10;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/11.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/11.js
new file mode 100644 (file)
index 0000000..20f3ced
--- /dev/null
@@ -0,0 +1,7 @@
+import "./10.js"
+import "./4.js"
+
+var global = (Function("return this"))();
+if (global.count !== 10)
+    throw new Error(`bad value ${global.count}`);
+global.count = 11;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/2.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/2.js
new file mode 100644 (file)
index 0000000..7868e6f
--- /dev/null
@@ -0,0 +1,8 @@
+import "./11.js"
+import "./9.js"
+import "./5.js"
+
+var global = (Function("return this"))();
+if (global.count !== 1)
+    throw new Error(`bad value ${global.count}`);
+global.count = 2;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/3.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/3.js
new file mode 100644 (file)
index 0000000..73c1054
--- /dev/null
@@ -0,0 +1,7 @@
+import "./1.js"
+import "./2.js"
+
+var global = (Function("return this"))();
+if (global.count !== 2)
+    throw new Error(`bad value ${global.count}`);
+global.count = 3;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/4.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/4.js
new file mode 100644 (file)
index 0000000..5fd1a89
--- /dev/null
@@ -0,0 +1,6 @@
+import "./2.js"
+
+var global = (Function("return this"))();
+if (global.count !== 3)
+    throw new Error(`bad value ${global.count}`);
+global.count = 4;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/5.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/5.js
new file mode 100644 (file)
index 0000000..a1deef9
--- /dev/null
@@ -0,0 +1,7 @@
+import "3.js"
+import "4.js"
+
+var global = (Function("return this"))();
+if (global.count !== 4)
+    throw new Error(`bad value ${global.count}`);
+global.count = 5;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/6.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/6.js
new file mode 100644 (file)
index 0000000..b05c593
--- /dev/null
@@ -0,0 +1,7 @@
+import "./5.js"
+import "./9.js"
+
+var global = (Function("return this"))();
+if (global.count !== 5)
+    throw new Error(`bad value ${global.count}`);
+global.count = 6;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/7.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/7.js
new file mode 100644 (file)
index 0000000..bae6c05
--- /dev/null
@@ -0,0 +1,7 @@
+import "./6.js";
+import "./9.js";
+
+var global = (Function("return this"))();
+if (global.count !== 6)
+    throw new Error(`bad value ${global.count}`);
+global.count = 7;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/8.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/8.js
new file mode 100644 (file)
index 0000000..a3b0da5
--- /dev/null
@@ -0,0 +1,6 @@
+import "./7.js"
+
+var global = (Function("return this"))();
+if (global.count !== 7)
+    throw new Error(`bad value ${global.count}`);
+global.count = 8;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-cyclic/9.js b/Source/JavaScriptCore/tests/modules/execution-order-cyclic/9.js
new file mode 100644 (file)
index 0000000..77ecdc9
--- /dev/null
@@ -0,0 +1,8 @@
+import "./11.js";
+import "./8.js";
+import "./6.js";
+
+var global = (Function("return this"))();
+if (global.count !== 8)
+    throw new Error(`bad value ${global.count}`);
+global.count = 9;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag.js b/Source/JavaScriptCore/tests/modules/execution-order-dag.js
new file mode 100644 (file)
index 0000000..7e7ac7f
--- /dev/null
@@ -0,0 +1,7 @@
+// This tests the DAG.
+import "./execution-order-dag/9.js"
+import "./execution-order-dag/10.js"
+
+var global = (Function("return this"))();
+if (global.count !== 10)
+    throw new Error(`bad value ${global.count}`);
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/1.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/1.js
new file mode 100644 (file)
index 0000000..4b1c3cc
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/10.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/10.js
new file mode 100644 (file)
index 0000000..128049d
--- /dev/null
@@ -0,0 +1,7 @@
+import "./8.js"
+import "./7.js"
+
+var global = (Function("return this"))();
+if (global.count !== 9)
+    throw new Error(`bad value ${global.count}`);
+global.count = 10;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/2.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/2.js
new file mode 100644 (file)
index 0000000..cf53bd8
--- /dev/null
@@ -0,0 +1,6 @@
+import "./1.js";
+
+var global = (Function("return this"))();
+if (global.count !== 1)
+    throw new Error(`bad value ${global.count}`);
+global.count = 2;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/3.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/3.js
new file mode 100644 (file)
index 0000000..b25eb48
--- /dev/null
@@ -0,0 +1,6 @@
+import "./2.js";
+
+var global = (Function("return this"))();
+if (global.count !== 2)
+    throw new Error(`bad value ${global.count}`);
+global.count = 3;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/4.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/4.js
new file mode 100644 (file)
index 0000000..9bdae49
--- /dev/null
@@ -0,0 +1,6 @@
+import "./1.js"
+
+var global = (Function("return this"))();
+if (global.count !== 3)
+    throw new Error(`bad value ${global.count}`);
+global.count = 4;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/5.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/5.js
new file mode 100644 (file)
index 0000000..a33b63c
--- /dev/null
@@ -0,0 +1,7 @@
+import "4.js"
+import "1.js"
+
+var global = (Function("return this"))();
+if (global.count !== 4)
+    throw new Error(`bad value ${global.count}`);
+global.count = 5;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/6.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/6.js
new file mode 100644 (file)
index 0000000..8613e71
--- /dev/null
@@ -0,0 +1,6 @@
+import "./5.js"
+
+var global = (Function("return this"))();
+if (global.count !== 5)
+    throw new Error(`bad value ${global.count}`);
+global.count = 6;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/7.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/7.js
new file mode 100644 (file)
index 0000000..2b8e9a0
--- /dev/null
@@ -0,0 +1,6 @@
+import "./6.js";
+
+var global = (Function("return this"))();
+if (global.count !== 6)
+    throw new Error(`bad value ${global.count}`);
+global.count = 7;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/8.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/8.js
new file mode 100644 (file)
index 0000000..b3e3b5f
--- /dev/null
@@ -0,0 +1,7 @@
+import "./3.js"
+import "./7.js";
+
+var global = (Function("return this"))();
+if (global.count !== 7)
+    throw new Error(`bad value ${global.count}`);
+global.count = 8;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-dag/9.js b/Source/JavaScriptCore/tests/modules/execution-order-dag/9.js
new file mode 100644 (file)
index 0000000..232e425
--- /dev/null
@@ -0,0 +1,6 @@
+import "./8.js";
+
+var global = (Function("return this"))();
+if (global.count !== 8)
+    throw new Error(`bad value ${global.count}`);
+global.count = 9;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-depth.js b/Source/JavaScriptCore/tests/modules/execution-order-depth.js
new file mode 100644 (file)
index 0000000..82e89fd
--- /dev/null
@@ -0,0 +1,5 @@
+import "./execution-order-depth/3.js"
+
+var global = (Function("return this"))();
+if (global.count !== 3)
+    throw new Error(`bad value ${global.count}`);
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-depth/1.js b/Source/JavaScriptCore/tests/modules/execution-order-depth/1.js
new file mode 100644 (file)
index 0000000..4b1c3cc
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-depth/2.js b/Source/JavaScriptCore/tests/modules/execution-order-depth/2.js
new file mode 100644 (file)
index 0000000..cf53bd8
--- /dev/null
@@ -0,0 +1,6 @@
+import "./1.js";
+
+var global = (Function("return this"))();
+if (global.count !== 1)
+    throw new Error(`bad value ${global.count}`);
+global.count = 2;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-depth/3.js b/Source/JavaScriptCore/tests/modules/execution-order-depth/3.js
new file mode 100644 (file)
index 0000000..b25eb48
--- /dev/null
@@ -0,0 +1,6 @@
+import "./2.js";
+
+var global = (Function("return this"))();
+if (global.count !== 2)
+    throw new Error(`bad value ${global.count}`);
+global.count = 3;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-self.js b/Source/JavaScriptCore/tests/modules/execution-order-self.js
new file mode 100644 (file)
index 0000000..665d903
--- /dev/null
@@ -0,0 +1,6 @@
+import "./execution-order-self.js"
+
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-sibling.js b/Source/JavaScriptCore/tests/modules/execution-order-sibling.js
new file mode 100644 (file)
index 0000000..952edb1
--- /dev/null
@@ -0,0 +1,7 @@
+import "./execution-order-sibling/1.js"
+import "./execution-order-sibling/2.js"
+import "./execution-order-sibling/3.js"
+
+var global = (Function("return this"))();
+if (global.count !== 3)
+    throw new Error(`bad value ${global.count}`);
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-sibling/1.js b/Source/JavaScriptCore/tests/modules/execution-order-sibling/1.js
new file mode 100644 (file)
index 0000000..4b1c3cc
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-sibling/2.js b/Source/JavaScriptCore/tests/modules/execution-order-sibling/2.js
new file mode 100644 (file)
index 0000000..dece661
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 1)
+    throw new Error(`bad value ${global.count}`);
+global.count = 2;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-sibling/3.js b/Source/JavaScriptCore/tests/modules/execution-order-sibling/3.js
new file mode 100644 (file)
index 0000000..4500c5b
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 2)
+    throw new Error(`bad value ${global.count}`);
+global.count = 3;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree.js b/Source/JavaScriptCore/tests/modules/execution-order-tree.js
new file mode 100644 (file)
index 0000000..da8ae59
--- /dev/null
@@ -0,0 +1,7 @@
+import "./execution-order-tree/5.js"
+import "./execution-order-tree/7.js"
+import "./execution-order-tree/11.js"
+
+var global = (Function("return this"))();
+if (global.count !== 11)
+    throw new Error(`bad value ${global.count}`);
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/1.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/1.js
new file mode 100644 (file)
index 0000000..4b1c3cc
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (typeof global.count !== 'undefined')
+    throw new Error(`bad value ${global.count}`);
+global.count = 1;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/10.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/10.js
new file mode 100644 (file)
index 0000000..e96c324
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 9)
+    throw new Error(`bad value ${global.count}`);
+global.count = 10;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/11.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/11.js
new file mode 100644 (file)
index 0000000..84bb253
--- /dev/null
@@ -0,0 +1,7 @@
+import "./9.js";
+import "./10.js";
+
+var global = (Function("return this"))();
+if (global.count !== 10)
+    throw new Error(`bad value ${global.count}`);
+global.count = 11;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/2.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/2.js
new file mode 100644 (file)
index 0000000..cf53bd8
--- /dev/null
@@ -0,0 +1,6 @@
+import "./1.js";
+
+var global = (Function("return this"))();
+if (global.count !== 1)
+    throw new Error(`bad value ${global.count}`);
+global.count = 2;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/3.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/3.js
new file mode 100644 (file)
index 0000000..e079c61
--- /dev/null
@@ -0,0 +1,7 @@
+import "./1.js";
+import "./2.js";
+
+var global = (Function("return this"))();
+if (global.count !== 2)
+    throw new Error(`bad value ${global.count}`);
+global.count = 3;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/4.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/4.js
new file mode 100644 (file)
index 0000000..a76becb
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 3)
+    throw new Error(`bad value ${global.count}`);
+global.count = 4;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/5.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/5.js
new file mode 100644 (file)
index 0000000..a1deef9
--- /dev/null
@@ -0,0 +1,7 @@
+import "3.js"
+import "4.js"
+
+var global = (Function("return this"))();
+if (global.count !== 4)
+    throw new Error(`bad value ${global.count}`);
+global.count = 5;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/6.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/6.js
new file mode 100644 (file)
index 0000000..118d474
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 5)
+    throw new Error(`bad value ${global.count}`);
+global.count = 6;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/7.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/7.js
new file mode 100644 (file)
index 0000000..2b8e9a0
--- /dev/null
@@ -0,0 +1,6 @@
+import "./6.js";
+
+var global = (Function("return this"))();
+if (global.count !== 6)
+    throw new Error(`bad value ${global.count}`);
+global.count = 7;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/8.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/8.js
new file mode 100644 (file)
index 0000000..47c6f47
--- /dev/null
@@ -0,0 +1,4 @@
+var global = (Function("return this"))();
+if (global.count !== 7)
+    throw new Error(`bad value ${global.count}`);
+global.count = 8;
diff --git a/Source/JavaScriptCore/tests/modules/execution-order-tree/9.js b/Source/JavaScriptCore/tests/modules/execution-order-tree/9.js
new file mode 100644 (file)
index 0000000..232e425
--- /dev/null
@@ -0,0 +1,6 @@
+import "./8.js";
+
+var global = (Function("return this"))();
+if (global.count !== 8)
+    throw new Error(`bad value ${global.count}`);
+global.count = 9;
diff --git a/Source/JavaScriptCore/tests/modules/export-conflict-ok.js b/Source/JavaScriptCore/tests/modules/export-conflict-ok.js
new file mode 100644 (file)
index 0000000..79e6965
--- /dev/null
@@ -0,0 +1,5 @@
+import { A, B } from "./export-conflict-ok/main.js"  // C is conflict, but not looked up.
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(A, 42);
+shouldBe(B, 50);
diff --git a/Source/JavaScriptCore/tests/modules/export-conflict-ok/A.js b/Source/JavaScriptCore/tests/modules/export-conflict-ok/A.js
new file mode 100644 (file)
index 0000000..8a84d64
--- /dev/null
@@ -0,0 +1,2 @@
+export const A = 42;
+export const C = 50;
diff --git a/Source/JavaScriptCore/tests/modules/export-conflict-ok/B.js b/Source/JavaScriptCore/tests/modules/export-conflict-ok/B.js
new file mode 100644 (file)
index 0000000..f1a65d7
--- /dev/null
@@ -0,0 +1,2 @@
+export const B = 50;
+export const C = 50;
diff --git a/Source/JavaScriptCore/tests/modules/export-conflict-ok/main.js b/Source/JavaScriptCore/tests/modules/export-conflict-ok/main.js
new file mode 100644 (file)
index 0000000..86c6f1f
--- /dev/null
@@ -0,0 +1,2 @@
+export * from "./A.js"
+export * from "./B.js"
diff --git a/Source/JavaScriptCore/tests/modules/export-from.js b/Source/JavaScriptCore/tests/modules/export-from.js
new file mode 100644 (file)
index 0000000..aa6d011
--- /dev/null
@@ -0,0 +1,8 @@
+import * as namespace from "./export-from/main.js"
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","default","enum"]`);
+shouldBe(namespace.Cocoa, "Cocoa");
+shouldBe(namespace.Cappuccino, "Cappuccino");
+shouldBe(namespace.default, "Mocha");
+shouldBe(namespace.enum, "Matcha");
diff --git a/Source/JavaScriptCore/tests/modules/export-from/main.js b/Source/JavaScriptCore/tests/modules/export-from/main.js
new file mode 100644 (file)
index 0000000..22f3b49
--- /dev/null
@@ -0,0 +1,6 @@
+export {
+    First as Cocoa,
+    Second as Cappuccino,
+    default as enum,
+    enum as default
+} from "./second.js"
diff --git a/Source/JavaScriptCore/tests/modules/export-from/second.js b/Source/JavaScriptCore/tests/modules/export-from/second.js
new file mode 100644 (file)
index 0000000..7c0bc51
--- /dev/null
@@ -0,0 +1,9 @@
+export let First = "Cocoa";
+
+export var Second = "Cappuccino"
+
+export default "Matcha";
+
+var Mocha = 'Mocha';
+
+export { Mocha as enum };
diff --git a/Source/JavaScriptCore/tests/modules/export-with-declarations-list.js b/Source/JavaScriptCore/tests/modules/export-with-declarations-list.js
new file mode 100644 (file)
index 0000000..3f365e4
--- /dev/null
@@ -0,0 +1,9 @@
+import * as namespace from "./export-with-declarations-list/main.js"
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha","Mocha"]`);
+shouldBe(namespace.Cocoa, 'Cocoa');
+shouldBe(namespace.Cappuccino, 'Cappuccino');
+shouldBe(namespace.Matcha, 'Matcha');
+shouldBe(namespace.Mocha, 'Mocha');
+
diff --git a/Source/JavaScriptCore/tests/modules/export-with-declarations-list/main.js b/Source/JavaScriptCore/tests/modules/export-with-declarations-list/main.js
new file mode 100644 (file)
index 0000000..d0e8fd2
--- /dev/null
@@ -0,0 +1,3 @@
+export let Cocoa = "Cocoa", Cappuccino = "Cappuccino";
+
+export const Matcha = "Matcha", Mocha = "Mocha";
diff --git a/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed.js b/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed.js
new file mode 100644 (file)
index 0000000..2328043
--- /dev/null
@@ -0,0 +1 @@
+import "./exported-function-may-be-called-before-module-is-executed/2.js"
diff --git a/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/1.js b/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/1.js
new file mode 100644 (file)
index 0000000..6a4b942
--- /dev/null
@@ -0,0 +1,15 @@
+import { add, raise } from "./2.js"
+import { shouldBe, shouldThrow } from "../resources/assert.js";
+
+shouldBe(typeof add, 'function');
+shouldBe(typeof raise, 'function');
+
+shouldBe(add(10, 32), 42);
+
+shouldThrow(() => {
+    // add, and raise functions are exported and can be used.
+    // But module "2"'s body is not executed yet!!!!
+    // raise function touches the lexical variable in the module "2", so TDZ
+    // error should be raised.
+    raise();
+}, `ReferenceError: Cannot access uninitialized variable.`);
diff --git a/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/2.js b/Source/JavaScriptCore/tests/modules/exported-function-may-be-called-before-module-is-executed/2.js
new file mode 100644 (file)
index 0000000..4ae5c2b
--- /dev/null
@@ -0,0 +1,13 @@
+import "./1.js"
+
+let value = 42;
+
+export function add(a, b)
+{
+    return a + b;
+}
+
+export function raise()
+{
+    return value;
+}
diff --git a/Source/JavaScriptCore/tests/modules/import-error.js b/Source/JavaScriptCore/tests/modules/import-error.js
new file mode 100644 (file)
index 0000000..0237472
--- /dev/null
@@ -0,0 +1,13 @@
+import { shouldBe, shouldThrow } from "./resources/assert.js"
+
+shouldThrow(() => {
+    loadModule('./import-error/import-not-found.js');
+}, `SyntaxError: Importing binding name 'B' is not found.`);
+
+shouldThrow(() => {
+    loadModule('./import-error/import-ambiguous.js');
+}, `SyntaxError: Importing binding name 'B' cannot be resolved due to ambiguous multiple bindings.`);
+
+shouldThrow(() => {
+    loadModule('./import-error/import-default-from-star.js');
+}, `SyntaxError: Importing binding name 'default' cannot be resolved by star export entries.`);
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-1.js b/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-1.js
new file mode 100644 (file)
index 0000000..48d7f9a
--- /dev/null
@@ -0,0 +1 @@
+export const B = 42;
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-2.js b/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous-2.js
new file mode 100644 (file)
index 0000000..bae1d17
--- /dev/null
@@ -0,0 +1 @@
+export const B = 50;
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous.js b/Source/JavaScriptCore/tests/modules/import-error/export-ambiguous.js
new file mode 100644 (file)
index 0000000..69c120d
--- /dev/null
@@ -0,0 +1,4 @@
+export const A = 42;
+
+export * from "./export-ambiguous-1.js"
+export * from "./export-ambiguous-2.js"
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-default-from-star-2.js b/Source/JavaScriptCore/tests/modules/import-error/export-default-from-star-2.js
new file mode 100644 (file)
index 0000000..035709a
--- /dev/null
@@ -0,0 +1,2 @@
+export default function Cocoa() {
+}
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-default-from-star.js b/Source/JavaScriptCore/tests/modules/import-error/export-default-from-star.js
new file mode 100644 (file)
index 0000000..4f86ebc
--- /dev/null
@@ -0,0 +1 @@
+export * from "./export-default-from-star-2.js"
diff --git a/Source/JavaScriptCore/tests/modules/import-error/export-not-found.js b/Source/JavaScriptCore/tests/modules/import-error/export-not-found.js
new file mode 100644 (file)
index 0000000..c50866a
--- /dev/null
@@ -0,0 +1,2 @@
+
+export const A = 20;
diff --git a/Source/JavaScriptCore/tests/modules/import-error/import-ambiguous.js b/Source/JavaScriptCore/tests/modules/import-error/import-ambiguous.js
new file mode 100644 (file)
index 0000000..dd6c584
--- /dev/null
@@ -0,0 +1 @@
+import { A, B } from "./export-ambiguous.js"
diff --git a/Source/JavaScriptCore/tests/modules/import-error/import-default-from-star.js b/Source/JavaScriptCore/tests/modules/import-error/import-default-from-star.js
new file mode 100644 (file)
index 0000000..f7f9e63
--- /dev/null
@@ -0,0 +1 @@
+import A from "./export-default-from-star.js"
diff --git a/Source/JavaScriptCore/tests/modules/import-error/import-not-found.js b/Source/JavaScriptCore/tests/modules/import-error/import-not-found.js
new file mode 100644 (file)
index 0000000..04568d2
--- /dev/null
@@ -0,0 +1 @@
+import { A, B } from "./export-not-found.js"
diff --git a/Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable.js b/Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable.js
new file mode 100644 (file)
index 0000000..4515e29
--- /dev/null
@@ -0,0 +1,43 @@
+import { variable, constVariable, letVariable, functionDeclaration, classDeclaration } from "./imported-bindings-are-immutable/bindings.js"
+import { shouldBe, shouldThrow } from "./resources/assert.js"
+
+shouldBe(variable, 'Cocoa');
+shouldThrow(() => {
+    variable = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldBe(constVariable, 'Cocoa');
+shouldThrow(() => {
+    constVariable = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldBe(letVariable, 'Cocoa');
+shouldThrow(() => {
+    letVariable = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldBe(typeof functionDeclaration, 'function');
+shouldThrow(() => {
+    functionDeclaration = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldBe(typeof classDeclaration, 'function');
+shouldThrow(() => {
+    classDeclaration = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+
+function reference(read) {
+    if (read)
+        return letVariable;
+    else
+        letVariable = "Cocoa";
+}
+noInline(reference);
+
+for (var i = 0; i < 10000; ++i)
+    reference(true);
+
+shouldThrow(() => {
+    reference(false);
+}, `TypeError: Attempted to assign to readonly property.`);
diff --git a/Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable/bindings.js b/Source/JavaScriptCore/tests/modules/imported-bindings-are-immutable/bindings.js
new file mode 100644 (file)
index 0000000..ed645cd
--- /dev/null
@@ -0,0 +1,11 @@
+export var variable = 'Cocoa';
+
+export const constVariable = 'Cocoa';
+
+export let letVariable = 'Cocoa';
+
+export function functionDeclaration() {
+}
+
+export class classDeclaration {
+}
diff --git a/Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module.js b/Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module.js
new file mode 100644 (file)
index 0000000..ab8b6c4
--- /dev/null
@@ -0,0 +1,17 @@
+import {
+    Cocoa,
+    Cappuccino,
+    Matcha,
+    Modifier
+} from "./imported-bindings-can-be-changed-in-original-module/bindings.js"
+import { shouldBe, shouldThrow } from "./resources/assert.js"
+
+shouldBe(Cocoa, "Cocoa");
+shouldBe(Cappuccino, "Cappuccino");
+shouldBe(Matcha, "Matcha");
+
+Modifier.change("Cocoa");
+
+shouldBe(Cocoa, "Cocoa");
+shouldBe(Cappuccino, "Cocoa");
+shouldBe(Matcha, "Cocoa");
diff --git a/Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module/bindings.js b/Source/JavaScriptCore/tests/modules/imported-bindings-can-be-changed-in-original-module/bindings.js
new file mode 100644 (file)
index 0000000..824288c
--- /dev/null
@@ -0,0 +1,16 @@
+let Cocoa = "Cocoa", Cappuccino = "Cappuccino", Matcha = "Matcha";
+
+export let Modifier = {
+    change(value)
+    {
+        Cocoa = value;
+        Cappuccino = value;
+        Matcha = value;
+    }
+};
+
+export {
+    Cocoa,
+    Cappuccino,
+    Matcha
+};
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error.js b/Source/JavaScriptCore/tests/modules/indirect-export-error.js
new file mode 100644 (file)
index 0000000..a3cfc77
--- /dev/null
@@ -0,0 +1,13 @@
+import { shouldBe, shouldThrow } from "./resources/assert.js"
+
+shouldThrow(() => {
+    loadModule('./indirect-export-error/indirect-export-not-found.js');
+}, `SyntaxError: Indirectly exported binding name 'B' is not found.`);
+
+shouldThrow(() => {
+    loadModule('./indirect-export-error/indirect-export-ambiguous.js');
+}, `SyntaxError: Indirectly exported binding name 'B' cannot be resolved due to ambiguous multiple bindings.`);
+
+shouldThrow(() => {
+    loadModule('./indirect-export-error/indirect-export-default.js');
+}, `SyntaxError: Indirectly exported binding name 'default' cannot be resolved by star export entries.`);
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-2.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-2.js
new file mode 100644 (file)
index 0000000..e639057
--- /dev/null
@@ -0,0 +1,2 @@
+export * from "./indirect-export-ambiguous-3.js"
+export * from "./indirect-export-ambiguous-4.js"
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-3.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-3.js
new file mode 100644 (file)
index 0000000..4c445a4
--- /dev/null
@@ -0,0 +1,2 @@
+export const A = 42;
+export const B = 50
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-4.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous-4.js
new file mode 100644 (file)
index 0000000..4f22722
--- /dev/null
@@ -0,0 +1 @@
+export const B = 50
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-ambiguous.js
new file mode 100644 (file)
index 0000000..ef626d9
--- /dev/null
@@ -0,0 +1 @@
+export { A, B } from "./indirect-export-ambiguous-2.js"
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-2.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-2.js
new file mode 100644 (file)
index 0000000..c177b14
--- /dev/null
@@ -0,0 +1 @@
+export * from "indirect-export-default-3.js"
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-3.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default-3.js
new file mode 100644 (file)
index 0000000..035709a
--- /dev/null
@@ -0,0 +1,2 @@
+export default function Cocoa() {
+}
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-default.js
new file mode 100644 (file)
index 0000000..6de1425
--- /dev/null
@@ -0,0 +1,2 @@
+import A from "./indirect-export-default-2.js"
+export { A }
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found-2.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found-2.js
new file mode 100644 (file)
index 0000000..83c665f
--- /dev/null
@@ -0,0 +1 @@
+export const A = 42;
diff --git a/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found.js b/Source/JavaScriptCore/tests/modules/indirect-export-error/indirect-export-not-found.js
new file mode 100644 (file)
index 0000000..5dd4879
--- /dev/null
@@ -0,0 +1 @@
+export { A, B } from "./indirect-export-not-found-2.js";
diff --git a/Source/JavaScriptCore/tests/modules/module-eval.js b/Source/JavaScriptCore/tests/modules/module-eval.js
new file mode 100644 (file)
index 0000000..5971e7e
--- /dev/null
@@ -0,0 +1,11 @@
+import { Cappuccino, Cocoa } from "./module-eval/drink.js"
+import * as B from "./module-eval/B.js"
+import { shouldThrow, shouldBe } from "./resources/assert.js"
+
+shouldBe(eval("Cappuccino"), "Cappuccino");
+
+(function () {
+    let Cappuccino = "Cocoa";
+    shouldBe(eval("Cappuccino"), "Cocoa");
+    shouldBe(eval("Cocoa"), "Cocoa");
+}());
diff --git a/Source/JavaScriptCore/tests/modules/module-eval/A.js b/Source/JavaScriptCore/tests/modules/module-eval/A.js
new file mode 100644 (file)
index 0000000..8cc42d1
--- /dev/null
@@ -0,0 +1,8 @@
+import { B } from "./B.js"
+import { shouldThrow } from "../resources/assert.js"
+
+export let A = "A";
+
+shouldThrow(() => {
+    eval("B");
+}, `ReferenceError: Cannot access uninitialized variable.`);
diff --git a/Source/JavaScriptCore/tests/modules/module-eval/B.js b/Source/JavaScriptCore/tests/modules/module-eval/B.js
new file mode 100644 (file)
index 0000000..1d5ba28
--- /dev/null
@@ -0,0 +1,3 @@
+import { A } from "./A.js"
+
+export let B = "B";
diff --git a/Source/JavaScriptCore/tests/modules/module-eval/drink.js b/Source/JavaScriptCore/tests/modules/module-eval/drink.js
new file mode 100644 (file)
index 0000000..ca837f7
--- /dev/null
@@ -0,0 +1,3 @@
+export const Cocoa = "Cocoa";
+
+export let Cappuccino = "Cappuccino";
diff --git a/Source/JavaScriptCore/tests/modules/module-is-strict-code.js b/Source/JavaScriptCore/tests/modules/module-is-strict-code.js
new file mode 100644 (file)
index 0000000..fcc3b33
--- /dev/null
@@ -0,0 +1,19 @@
+import { shouldThrow, shouldBe } from "./resources/assert.js";
+
+// Module code is always strict code.
+shouldThrow(() => {
+    eval("with(value) { }");
+}, `SyntaxError: 'with' statements are not valid in strict mode.`);
+
+// When calling the indirect eval / Function constructor, its scope is not the module scope.
+var moduleVariable = 42;
+
+shouldBe(eval("moduleVariable"), 42);
+
+shouldThrow(() => {
+    (0, eval)("moduleVariable");
+}, `ReferenceError: Can't find variable: moduleVariable`);
+
+shouldThrow(() => {
+    (Function("moduleVariable"))();
+}, `ReferenceError: Can't find variable: moduleVariable`);
diff --git a/Source/JavaScriptCore/tests/modules/namespace-ambiguous.js b/Source/JavaScriptCore/tests/modules/namespace-ambiguous.js
new file mode 100644 (file)
index 0000000..e496cd2
--- /dev/null
@@ -0,0 +1,6 @@
+import * as namespace from "./namespace-ambiguous/ambiguous.js"
+import { shouldBe, shouldThrow } from "./resources/assert.js"
+
+// Ambiguous name is omitted from the namespace.
+shouldBe(namespace.Cocoa, undefined);
+shouldBe('Cocoa' in namespace, false);
diff --git a/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-2.js b/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-2.js
new file mode 100644 (file)
index 0000000..78093d4
--- /dev/null
@@ -0,0 +1,2 @@
+export * from "ambiguous-3.js"
+export * from "ambiguous-4.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-3.js b/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-3.js
new file mode 100644 (file)
index 0000000..c765164
--- /dev/null
@@ -0,0 +1 @@
+export const Cocoa = 42;
diff --git a/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-4.js b/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous-4.js
new file mode 100644 (file)
index 0000000..c765164
--- /dev/null
@@ -0,0 +1 @@
+export const Cocoa = 42;
diff --git a/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous.js b/Source/JavaScriptCore/tests/modules/namespace-ambiguous/ambiguous.js
new file mode 100644 (file)
index 0000000..d2892eb
--- /dev/null
@@ -0,0 +1 @@
+import * as namespace from "ambiguous-2.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error.js b/Source/JavaScriptCore/tests/modules/namespace-error.js
new file mode 100644 (file)
index 0000000..e47817a
--- /dev/null
@@ -0,0 +1,5 @@
+import { shouldThrow } from "./resources/assert.js"
+
+shouldThrow(() => {
+    loadModule('./namespace-error/namespace-local-error-should-hide-global-ambiguity.js');
+}, `SyntaxError: Indirectly exported binding name 'default' cannot be resolved by star export entries.`);
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-2.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-2.js
new file mode 100644 (file)
index 0000000..443a47a
--- /dev/null
@@ -0,0 +1,3 @@
+export * from "./namespace-local-error-should-hide-global-ambiguity-3.js"
+export * from "./namespace-local-error-should-hide-global-ambiguity-4.js"
+export * from "./namespace-local-error-should-hide-global-ambiguity-5.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-3.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-3.js
new file mode 100644 (file)
index 0000000..c765164
--- /dev/null
@@ -0,0 +1 @@
+export const Cocoa = 42;
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-4.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-4.js
new file mode 100644 (file)
index 0000000..82cbcce
--- /dev/null
@@ -0,0 +1,3 @@
+export * from "./namespace-local-error-should-hide-global-ambiguity-6.js"
+import Hello from "./namespace-local-error-should-hide-global-ambiguity-7.js"
+export { Hello }
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-5.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-5.js
new file mode 100644 (file)
index 0000000..c765164
--- /dev/null
@@ -0,0 +1 @@
+export const Cocoa = 42;
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-6.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-6.js
new file mode 100644 (file)
index 0000000..c765164
--- /dev/null
@@ -0,0 +1 @@
+export const Cocoa = 42;
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-7.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity-7.js
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity.js b/Source/JavaScriptCore/tests/modules/namespace-error/namespace-local-error-should-hide-global-ambiguity.js
new file mode 100644 (file)
index 0000000..c0e0063
--- /dev/null
@@ -0,0 +1 @@
+import * as namespace from "./namespace-local-error-should-hide-global-ambiguity-2.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace-tdz.js b/Source/JavaScriptCore/tests/modules/namespace-tdz.js
new file mode 100644 (file)
index 0000000..16f2b0c
--- /dev/null
@@ -0,0 +1 @@
+import * as namespace from "./namespace-tdz/main.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace-tdz/A.js b/Source/JavaScriptCore/tests/modules/namespace-tdz/A.js
new file mode 100644 (file)
index 0000000..62491c1
--- /dev/null
@@ -0,0 +1,10 @@
+import * as namespace from "./B.js"
+import { shouldBe, shouldThrow } from "../resources/assert.js";
+
+export const A = 42;
+
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, 'B')), `{"value":256,"writable":true,"enumerable":true,"configurable":false}`);
+
+shouldBe(namespace.B, 256);
+namespace.later();
+
diff --git a/Source/JavaScriptCore/tests/modules/namespace-tdz/B.js b/Source/JavaScriptCore/tests/modules/namespace-tdz/B.js
new file mode 100644 (file)
index 0000000..d8f77e1
--- /dev/null
@@ -0,0 +1,20 @@
+import * as namespace from "./A.js"
+import { shouldBe, shouldThrow } from "../resources/assert.js";
+
+export const B = 256;
+
+shouldThrow(() => {
+    print(namespace.A);
+}, `ReferenceError: Cannot access uninitialized variable.`);
+
+shouldThrow(() => {
+    Reflect.getOwnPropertyDescriptor(namespace, 'A');
+}, `ReferenceError: Cannot access uninitialized variable.`);
+
+// Not throw any errors even if the field is not initialized yet.
+shouldBe('A' in namespace, true);
+shouldBe('hello' in namespace, false);
+
+export function later() {
+    shouldBe(namespace.A, 42);
+}
diff --git a/Source/JavaScriptCore/tests/modules/namespace-tdz/main.js b/Source/JavaScriptCore/tests/modules/namespace-tdz/main.js
new file mode 100644 (file)
index 0000000..c24f972
--- /dev/null
@@ -0,0 +1 @@
+import { A } from "./A.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace.js b/Source/JavaScriptCore/tests/modules/namespace.js
new file mode 100644 (file)
index 0000000..1bf2414
--- /dev/null
@@ -0,0 +1,81 @@
+import changeCappuccino, * as namespace from "./namespace/drink.js"
+import { shouldBe, shouldThrow } from "./resources/assert.js";
+
+shouldBe(typeof namespace, 'object');
+shouldBe(typeof changeCappuccino, 'function');
+shouldBe(namespace.Cocoa, 'Cocoa');
+shouldBe(namespace.Cappuccino, 'Cappuccino');
+shouldBe(namespace.Matcha, 'Matcha');
+shouldBe(namespace.Mocha, 'Mocha');
+shouldBe(namespace.default, changeCappuccino);
+
+changeCappuccino('Cocoa');
+shouldBe(namespace.Cocoa, 'Cocoa');
+shouldBe(namespace.Cappuccino, 'Cocoa');
+shouldBe(namespace.Matcha, 'Matcha');
+shouldBe(namespace.Mocha, 'Mocha');
+shouldBe(namespace.default, changeCappuccino);
+
+shouldBe('Cocoa' in namespace, true);
+shouldBe('Cappuccino' in namespace, true);
+shouldBe('Matcha' in namespace, true);
+shouldBe('Mocha' in namespace, true);
+shouldBe('default' in namespace, true);
+shouldBe(Symbol.iterator in namespace, true);
+shouldBe('Tea' in namespace, false);
+
+shouldBe(namespace.__proto__, undefined);
+shouldBe(Reflect.isExtensible(namespace), false);
+
+shouldThrow(() => {
+    namespace.value = 20;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldThrow(() => {
+    namespace[20] = 20;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldThrow(() => {
+    namespace[Symbol.unscopables] = 20;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldThrow(() => {
+    Object.defineProperty(namespace, 'Cookie', {
+        value: 42
+    });
+}, `TypeError: Attempting to define property on object that is not extensible.`);
+
+shouldThrow(() => {
+    namespace.__proto__ = Object.prototype;
+}, `TypeError: Attempted to assign to readonly property.`);
+
+shouldBe(Reflect.setPrototypeOf(namespace, Object.prototype), false);
+shouldBe(namespace.__proto__, undefined);
+shouldBe(Reflect.getPrototypeOf(namespace), null);
+
+// These names should be shown in the code point order.
+shouldBe(JSON.stringify(Object.getOwnPropertyNames(namespace)), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
+shouldBe(Object.getOwnPropertySymbols(namespace).length, 1);
+shouldBe(Object.getOwnPropertySymbols(namespace)[0], Symbol.iterator);
+
+shouldBe(typeof namespace[Symbol.iterator], 'function');
+var array = Array.from(namespace);
+// These names should be shown in the code point order.
+shouldBe(JSON.stringify(array), `["Cappuccino","Cocoa","Matcha","Mocha","default"]`);
+
+// The imported binding properties of the namespace object seen as writable, but, it does not mean that it is writable by users.
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, "Cocoa")), `{"value":"Cocoa","writable":true,"enumerable":true,"configurable":false}`);
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, "Matcha")), `{"value":"Matcha","writable":true,"enumerable":true,"configurable":false}`);
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, "Mocha")), `{"value":"Mocha","writable":true,"enumerable":true,"configurable":false}`);
+shouldThrow(() => {
+    // Throw an error even if the same value.
+    namespace.Cocoa = 'Cocoa';
+}, `TypeError: Attempted to assign to readonly property.`);
+
+// In the case of non imported properties, we just return the original descriptor.
+// But still these properties cannot be changed.
+shouldBe(JSON.stringify(Reflect.getOwnPropertyDescriptor(namespace, Symbol.iterator)), `{"writable":true,"enumerable":false,"configurable":true}`);
+shouldThrow(() => {
+    namespace[Symbol.iterator] = 42;
+}, `TypeError: Attempted to assign to readonly property.`);
+
diff --git a/Source/JavaScriptCore/tests/modules/namespace/additional-drink.js b/Source/JavaScriptCore/tests/modules/namespace/additional-drink.js
new file mode 100644 (file)
index 0000000..59daa53
--- /dev/null
@@ -0,0 +1,4 @@
+export const Matcha = 'Matcha';
+
+import { Mocha } from "./more-additional-drink.js"
+export { Mocha }
diff --git a/Source/JavaScriptCore/tests/modules/namespace/drink.js b/Source/JavaScriptCore/tests/modules/namespace/drink.js
new file mode 100644 (file)
index 0000000..621fd22
--- /dev/null
@@ -0,0 +1,10 @@
+
+export const Cocoa = "Cocoa";
+
+export let Cappuccino = "Cappuccino";
+
+export default function changeCappuccino(value) {
+    Cappuccino = value;
+}
+
+export * from "./additional-drink.js"
diff --git a/Source/JavaScriptCore/tests/modules/namespace/more-additional-drink.js b/Source/JavaScriptCore/tests/modules/namespace/more-additional-drink.js
new file mode 100644 (file)
index 0000000..fcc3622
--- /dev/null
@@ -0,0 +1 @@
+export const Mocha = 'Mocha';
diff --git a/Source/JavaScriptCore/tests/modules/resources/assert.js b/Source/JavaScriptCore/tests/modules/resources/assert.js
new file mode 100644 (file)
index 0000000..a006f84
--- /dev/null
@@ -0,0 +1,19 @@
+export function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error(`bad value: ${String(actual)}`);
+}
+
+export function shouldThrow(func, errorMessage) {
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
diff --git a/Source/JavaScriptCore/tests/modules/scopes.js b/Source/JavaScriptCore/tests/modules/scopes.js
new file mode 100644 (file)
index 0000000..d20c65e
--- /dev/null
@@ -0,0 +1,27 @@
+import { Cocoa, Cappuccino, Matcha } from "./scopes/drink.js"
+import { shouldBe } from "./resources/assert.js";
+
+{
+    let Cocoa = 42;
+    shouldBe(Cocoa, 42);
+}
+shouldBe(Cocoa, 'Cocoa');
+shouldBe(Cappuccino, 'Cappuccino');
+shouldBe(Matcha, 'Matcha');
+
+var global = Function("return this")();
+
+(function () {
+    var Cocoa = 42;
+    let Cappuccino = 'CPO';
+    shouldBe(Cocoa, 42);
+    shouldBe(Cappuccino, 'CPO');
+    shouldBe(Matcha, 'Matcha');
+    {
+        const Matcha = 50;
+        shouldBe(Matcha, 50);
+        shouldBe(Object, global.Object);
+    }
+    shouldBe(Object, global.Object);
+}());
+shouldBe(Object, global.Object);
diff --git a/Source/JavaScriptCore/tests/modules/scopes/additional-drink.js b/Source/JavaScriptCore/tests/modules/scopes/additional-drink.js
new file mode 100644 (file)
index 0000000..59daa53
--- /dev/null
@@ -0,0 +1,4 @@
+export const Matcha = 'Matcha';
+
+import { Mocha } from "./more-additional-drink.js"
+export { Mocha }
diff --git a/Source/JavaScriptCore/tests/modules/scopes/drink.js b/Source/JavaScriptCore/tests/modules/scopes/drink.js
new file mode 100644 (file)
index 0000000..621fd22
--- /dev/null
@@ -0,0 +1,10 @@
+
+export const Cocoa = "Cocoa";
+
+export let Cappuccino = "Cappuccino";
+
+export default function changeCappuccino(value) {
+    Cappuccino = value;
+}
+
+export * from "./additional-drink.js"
diff --git a/Source/JavaScriptCore/tests/modules/scopes/more-additional-drink.js b/Source/JavaScriptCore/tests/modules/scopes/more-additional-drink.js
new file mode 100644 (file)
index 0000000..fcc3622
--- /dev/null
@@ -0,0 +1 @@
+export const Mocha = 'Mocha';
diff --git a/Source/JavaScriptCore/tests/modules/this-should-be-undefined.js b/Source/JavaScriptCore/tests/modules/this-should-be-undefined.js
new file mode 100644 (file)
index 0000000..88453e2
--- /dev/null
@@ -0,0 +1,3 @@
+import { shouldBe } from "./resources/assert.js";
+
+shouldBe(this, undefined);
index eaa7327..803f383 100644 (file)
@@ -1,5 +1,3 @@
-//@ skip
-
 function shouldThrow(func, errorMessage) {
     var errorThrown = false;
     var error = null;
index 01130a1..cd31014 100644 (file)
@@ -1,3 +1,14 @@
+2015-09-05  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [ES6] Enable ES6 Module in JSC shell by default
+        https://bugs.webkit.org/show_bug.cgi?id=148689
+
+        Reviewed by Geoffrey Garen.
+
+        * Scripts/run-javascriptcore-tests:
+        (runJSCStressTests):
+        * Scripts/run-jsc-stress-tests:
+
 2015-09-04  Basile Clement  <basile_clement@apple.com>
 
         Unreviewed, change my email address.
index 79b6a06..0b3cda4 100755 (executable)
@@ -285,6 +285,7 @@ sub runJSCStressTests
         "Source/JavaScriptCore/tests/typeProfiler.yaml",
         "Source/JavaScriptCore/tests/controlFlowProfiler.yaml",
         "Source/JavaScriptCore/tests/es6.yaml",
+        "Source/JavaScriptCore/tests/modules.yaml",
     );
     if (isWindows() && !isCygwin()) {
         shift @jscStressDriverCmd; # Remove /usr/bin/env
index 44d272e..81dc9ac 100755 (executable)
@@ -899,6 +899,28 @@ def runES6(mode)
     addRunCommand("default", args, noisyOutputHandler, errorHandler)
 end
 
+def runModules
+    run("default-modules", "-m")
+    run("always-trigger-copy-phase-modules", "-m", "--minHeapUtilization=2.0", "--minCopiedBlockUtilization=2.0")
+
+    if !$jitTests
+        return
+    end
+
+    run("no-llint-modules", "-m", "--useLLInt=false")
+    run("no-cjit-validate-phases-modules", "-m", "--validateBytecode=true", "--validateGraphAtEachPhase=true", *NO_CJIT_OPTIONS)
+    run("dfg-eager-modules", "-m", *EAGER_OPTIONS)
+    run("dfg-eager-no-cjit-validate-modules", "-m", "--validateGraph=true", *(NO_CJIT_OPTIONS + EAGER_OPTIONS))
+    if $enableFTL
+        run("default-ftl-modules", "-m", *FTL_OPTIONS)
+        run("ftl-no-cjit-validate-modules", "-m", "--validateGraph=true", *(FTL_OPTIONS + NO_CJIT_OPTIONS))
+        run("ftl-no-cjit-no-inline-validate-modules", "-m", "--validateGraph=true", "--maximumInliningDepth=1", *(FTL_OPTIONS + NO_CJIT_OPTIONS))
+        run("ftl-eager-modules", "-m", *(FTL_OPTIONS + EAGER_OPTIONS))
+        run("ftl-eager-no-cjit-modules", "-m", "--validateGraph=true", *(FTL_OPTIONS + NO_CJIT_OPTIONS + EAGER_OPTIONS))
+        run("ftl-no-cjit-small-pool-modules", "-m", "--jitMemoryReservationSize=50000", *(FTL_OPTIONS + NO_CJIT_OPTIONS))
+    end
+end
+
 def runLayoutTest(kind, *options)
     raise unless $benchmark.to_s =~ /\.js$/
     testName = $~.pre_match