From fb93adc11f8c307c2bb6d2acd1547d1316e3037a Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Wed, 20 May 2015 21:44:57 -0400 Subject: [PATCH] add form tests alongside function tests --- test/form/no-imports-or-exports/_config.js | 3 + .../no-imports-or-exports/_expected/amd.js | 5 + .../no-imports-or-exports/_expected/cjs.js | 3 + .../no-imports-or-exports/_expected/es6.js | 1 + .../no-imports-or-exports/_expected/umd.js | 9 + test/form/no-imports-or-exports/main.js | 1 + .../_config.js | 0 .../foo.js | 0 .../main.js | 0 .../{samples => function}/bindings/_config.js | 0 test/{samples => function}/bindings/foo.js | 0 test/{samples => function}/bindings/main.js | 0 .../consistent-renaming-b/_config.js | 0 .../consistent-renaming-b/altdir/two.js | 0 .../consistent-renaming-b/main.js | 0 .../consistent-renaming-b/subdir/one.js | 0 .../consistent-renaming-b/subdir/two.js | 0 .../consistent-renaming-c/-internal.js | 0 .../consistent-renaming-c/_config.js | 0 .../consistent-renaming-c/main.js | 0 .../consistent-renaming-c/one.js | 0 .../consistent-renaming-c/one/three.js | 0 .../consistent-renaming-c/one/two.js | 0 .../consistent-renaming-c/two.js | 0 .../consistent-renaming-d/Baz.js | 0 .../consistent-renaming-d/_config.js | 0 .../consistent-renaming-d/bar.js | 0 .../consistent-renaming-d/foo.js | 0 .../consistent-renaming-d/foo/baz.js | 0 .../consistent-renaming-d/main.js | 0 .../consistent-renaming-d/rsvp/all-settled.js | 0 .../consistent-renaming-d/rsvp/enumerator.js | 0 .../consistent-renaming-d/rsvp/promise.js | 0 .../consistent-renaming-d/rsvp/promise/all.js | 0 .../consistent-renaming-e/_config.js | 0 .../consistent-renaming-e/a.js | 0 .../consistent-renaming-e/b.js | 0 .../consistent-renaming-e/main.js | 0 .../consistent-renaming-e/utils.js | 0 .../consistent-renaming/_config.js | 0 .../consistent-renaming/main.js | 0 .../consistent-renaming/one.js | 0 .../consistent-renaming/three.js | 0 .../consistent-renaming/two.js | 0 .../custom-path-resolver-async/_config.js | 0 .../custom-path-resolver-async/bar.js | 0 .../custom-path-resolver-async/main.js | 0 .../custom-path-resolver-sync/_config.js | 0 .../custom-path-resolver-sync/bar.js | 0 .../custom-path-resolver-sync/main.js | 0 .../cycles-defaults/_config.js | 0 .../cycles-defaults/a.js | 0 .../cycles-defaults/b.js | 0 .../cycles-defaults/main.js | 0 .../cycles-immediate/_config.js | 0 .../cycles-immediate/evens.js | 0 .../cycles-immediate/main.js | 0 .../cycles-immediate/odds.js | 0 .../default-export-is-not-bound/_config.js | 0 .../default-export-is-not-bound/foo.js | 0 .../default-export-is-not-bound/main.js | 0 .../duplicate-import-fails/_config.js | 0 .../duplicate-import-fails/foo.js | 0 .../duplicate-import-fails/main.js | 0 .../_config.js | 0 .../duplicate-import-specifier-fails/foo.js | 0 .../duplicate-import-specifier-fails/main.js | 0 .../_config.js | 0 .../empty-imports-have-side-effects/foo.js | 0 .../empty-imports-have-side-effects/main.js | 0 .../export-deconflicted-names/_config.js | 0 .../export-deconflicted-names/bar.js | 0 .../export-deconflicted-names/baz.js | 0 .../export-deconflicted-names/foo.js | 0 .../export-deconflicted-names/main.js | 0 .../export-default-expression/_config.js | 0 .../export-default-expression/main.js | 0 .../export-from-default/_config.js | 0 .../export-from-default/first.js | 0 .../export-from-default/main.js | 0 .../export-from-default/second.js | 0 .../export-from-internal-module/_config.js | 0 .../export-from-internal-module/foo.js | 0 .../export-from-internal-module/main.js | 0 .../export-from-no-local-binding/_config.js | 0 .../export-from-no-local-binding/first.js | 0 .../export-from-no-local-binding/main.js | 0 .../export-from-no-local-binding/second.js | 0 .../export-not-at-top-level-fails/_config.js | 0 .../export-not-at-top-level-fails/main.js | 0 .../exports-named-values/_config.js | 0 .../exports-named-values/main.js | 0 .../function-side-effects/_config.js | 0 .../function-side-effects/main.js | 0 .../function-side-effects/mutate.js | 0 .../function-side-effects/object.js | 0 .../import-as/_config.js | 0 test/{samples => function}/import-as/foo.js | 0 test/{samples => function}/import-as/main.js | 0 .../import-binding/_config.js | 0 .../import-binding/foo.js | 0 .../import-binding/main.js | 0 .../import-chain/_config.js | 0 .../import-chain/first.js | 0 .../import-chain/main.js | 0 .../import-chain/second.js | 0 .../_config.js | 0 .../import-default-and-named-function/foo.js | 0 .../import-default-and-named-function/main.js | 0 .../import-default-as-named/_config.js | 0 .../import-default-as-named/foo.js | 0 .../import-default-as-named/main.js | 0 .../import-default-as-other/_config.js | 0 .../import-default-as-other/foo.js | 0 .../import-default-as-other/main.js | 0 .../import-default-class/_config.js | 0 .../import-default-class/main.js | 0 .../import-default-class/point.js | 0 .../import-default-expression/_config.js | 0 .../import-default-expression/foo.js | 0 .../import-default-expression/main.js | 0 .../import-default-from-external/_config.js | 0 .../import-default-from-external/main.js | 0 .../import-default-function/_config.js | 0 .../import-default-function/foo.js | 0 .../import-default-function/main.js | 0 .../_config.js | 0 .../import-dependency-in-other-module/bar.js | 0 .../import-dependency-in-other-module/foo.js | 0 .../import-dependency-in-other-module/main.js | 0 .../_config.js | 0 .../import-dependency-in-same-module/foo.js | 0 .../import-dependency-in-same-module/main.js | 0 .../import-named-class/_config.js | 0 .../import-named-class/foo.js | 0 .../import-named-class/main.js | 0 .../import-named-from-external/_config.js | 0 .../import-named-from-external/main.js | 0 .../import-named-function-as-other/_config.js | 0 .../import-named-function-as-other/foo.js | 0 .../import-named-function-as-other/main.js | 0 .../import-named-function/_config.js | 0 .../import-named-function/foo.js | 0 .../import-named-function/main.js | 0 .../_config.js | 0 .../import-nameless-class-expression/foo.js | 0 .../import-nameless-class-expression/main.js | 0 .../_config.js | 0 .../main.js | 0 .../_config.js | 0 .../foo.js | 0 .../main.js | 0 .../import-not-at-top-level-fails/_config.js | 0 .../import-not-at-top-level-fails/main.js | 0 .../import-var-declaration/_config.js | 0 .../import-var-declaration/foo.js | 0 .../import-var-declaration/main.js | 0 .../method-call-side-effects/_config.js | 0 .../method-call-side-effects/main.js | 0 .../method-call-side-effects/object.js | 0 .../method-call-side-effects/thing.js | 0 .../_config.js | 0 .../namespace-reassign-import-fails/foo.js | 0 .../namespace-reassign-import-fails/main.js | 0 .../namespace-update-import-fails/_config.js | 0 .../namespace-update-import-fails/foo.js | 0 .../namespace-update-import-fails/main.js | 0 .../no-imports/_config.js | 0 test/{samples => function}/no-imports/main.js | 0 .../object-properties/_config.js | 0 .../object-properties/main.js | 0 .../object-properties/object.js | 0 .../re-export-default-import/_config.js | 0 .../re-export-default-import/first.js | 0 .../re-export-default-import/main.js | 0 .../re-export-default-import/second.js | 0 .../re-export-namespace-import/_config.js | 0 .../re-export-namespace-import/first.js | 0 .../re-export-namespace-import/main.js | 0 .../re-export-namespace-import/second.js | 0 .../reassign-import-fails/_config.js | 0 .../reassign-import-fails/foo.js | 0 .../reassign-import-fails/main.js | 0 .../_config.js | 0 .../foo.js | 0 .../main.js | 0 .../rewrite-member-expressions/_config.js | 0 .../getLengthOfOtherQueue.js | 0 .../rewrite-member-expressions/main.js | 0 .../rewrite-member-expressions/mainQueue.js | 0 .../shadowed-variables/_config.js | 0 .../shadowed-variables/foo.js | 0 .../shadowed-variables/main.js | 0 .../this-is-undefined/_config.js | 0 .../this-is-undefined/main.js | 0 .../try-catch-scoping/_config.js | 0 .../try-catch-scoping/foo.js | 0 .../try-catch-scoping/main.js | 0 .../_config.js | 0 .../update-expression-of-import-fails/foo.js | 0 .../update-expression-of-import-fails/main.js | 0 test/test.js | 191 +++++++++++------- test/utils/promiseSequence.js | 28 +++ 203 files changed, 169 insertions(+), 72 deletions(-) create mode 100644 test/form/no-imports-or-exports/_config.js create mode 100644 test/form/no-imports-or-exports/_expected/amd.js create mode 100644 test/form/no-imports-or-exports/_expected/cjs.js create mode 100644 test/form/no-imports-or-exports/_expected/es6.js create mode 100644 test/form/no-imports-or-exports/_expected/umd.js create mode 100644 test/form/no-imports-or-exports/main.js rename test/{samples => function}/allows-external-modules-from-nested-module/_config.js (100%) rename test/{samples => function}/allows-external-modules-from-nested-module/foo.js (100%) rename test/{samples => function}/allows-external-modules-from-nested-module/main.js (100%) rename test/{samples => function}/bindings/_config.js (100%) rename test/{samples => function}/bindings/foo.js (100%) rename test/{samples => function}/bindings/main.js (100%) rename test/{samples => function}/consistent-renaming-b/_config.js (100%) rename test/{samples => function}/consistent-renaming-b/altdir/two.js (100%) rename test/{samples => function}/consistent-renaming-b/main.js (100%) rename test/{samples => function}/consistent-renaming-b/subdir/one.js (100%) rename test/{samples => function}/consistent-renaming-b/subdir/two.js (100%) rename test/{samples => function}/consistent-renaming-c/-internal.js (100%) rename test/{samples => function}/consistent-renaming-c/_config.js (100%) rename test/{samples => function}/consistent-renaming-c/main.js (100%) rename test/{samples => function}/consistent-renaming-c/one.js (100%) rename test/{samples => function}/consistent-renaming-c/one/three.js (100%) rename test/{samples => function}/consistent-renaming-c/one/two.js (100%) rename test/{samples => function}/consistent-renaming-c/two.js (100%) rename test/{samples => function}/consistent-renaming-d/Baz.js (100%) rename test/{samples => function}/consistent-renaming-d/_config.js (100%) rename test/{samples => function}/consistent-renaming-d/bar.js (100%) rename test/{samples => function}/consistent-renaming-d/foo.js (100%) rename test/{samples => function}/consistent-renaming-d/foo/baz.js (100%) rename test/{samples => function}/consistent-renaming-d/main.js (100%) rename test/{samples => function}/consistent-renaming-d/rsvp/all-settled.js (100%) rename test/{samples => function}/consistent-renaming-d/rsvp/enumerator.js (100%) rename test/{samples => function}/consistent-renaming-d/rsvp/promise.js (100%) rename test/{samples => function}/consistent-renaming-d/rsvp/promise/all.js (100%) rename test/{samples => function}/consistent-renaming-e/_config.js (100%) rename test/{samples => function}/consistent-renaming-e/a.js (100%) rename test/{samples => function}/consistent-renaming-e/b.js (100%) rename test/{samples => function}/consistent-renaming-e/main.js (100%) rename test/{samples => function}/consistent-renaming-e/utils.js (100%) rename test/{samples => function}/consistent-renaming/_config.js (100%) rename test/{samples => function}/consistent-renaming/main.js (100%) rename test/{samples => function}/consistent-renaming/one.js (100%) rename test/{samples => function}/consistent-renaming/three.js (100%) rename test/{samples => function}/consistent-renaming/two.js (100%) rename test/{samples => function}/custom-path-resolver-async/_config.js (100%) rename test/{samples => function}/custom-path-resolver-async/bar.js (100%) rename test/{samples => function}/custom-path-resolver-async/main.js (100%) rename test/{samples => function}/custom-path-resolver-sync/_config.js (100%) rename test/{samples => function}/custom-path-resolver-sync/bar.js (100%) rename test/{samples => function}/custom-path-resolver-sync/main.js (100%) rename test/{samples => function}/cycles-defaults/_config.js (100%) rename test/{samples => function}/cycles-defaults/a.js (100%) rename test/{samples => function}/cycles-defaults/b.js (100%) rename test/{samples => function}/cycles-defaults/main.js (100%) rename test/{samples => function}/cycles-immediate/_config.js (100%) rename test/{samples => function}/cycles-immediate/evens.js (100%) rename test/{samples => function}/cycles-immediate/main.js (100%) rename test/{samples => function}/cycles-immediate/odds.js (100%) rename test/{samples => function}/default-export-is-not-bound/_config.js (100%) rename test/{samples => function}/default-export-is-not-bound/foo.js (100%) rename test/{samples => function}/default-export-is-not-bound/main.js (100%) rename test/{samples => function}/duplicate-import-fails/_config.js (100%) rename test/{samples => function}/duplicate-import-fails/foo.js (100%) rename test/{samples => function}/duplicate-import-fails/main.js (100%) rename test/{samples => function}/duplicate-import-specifier-fails/_config.js (100%) rename test/{samples => function}/duplicate-import-specifier-fails/foo.js (100%) rename test/{samples => function}/duplicate-import-specifier-fails/main.js (100%) rename test/{samples => function}/empty-imports-have-side-effects/_config.js (100%) rename test/{samples => function}/empty-imports-have-side-effects/foo.js (100%) rename test/{samples => function}/empty-imports-have-side-effects/main.js (100%) rename test/{samples => function}/export-deconflicted-names/_config.js (100%) rename test/{samples => function}/export-deconflicted-names/bar.js (100%) rename test/{samples => function}/export-deconflicted-names/baz.js (100%) rename test/{samples => function}/export-deconflicted-names/foo.js (100%) rename test/{samples => function}/export-deconflicted-names/main.js (100%) rename test/{samples => function}/export-default-expression/_config.js (100%) rename test/{samples => function}/export-default-expression/main.js (100%) rename test/{samples => function}/export-from-default/_config.js (100%) rename test/{samples => function}/export-from-default/first.js (100%) rename test/{samples => function}/export-from-default/main.js (100%) rename test/{samples => function}/export-from-default/second.js (100%) rename test/{samples => function}/export-from-internal-module/_config.js (100%) rename test/{samples => function}/export-from-internal-module/foo.js (100%) rename test/{samples => function}/export-from-internal-module/main.js (100%) rename test/{samples => function}/export-from-no-local-binding/_config.js (100%) rename test/{samples => function}/export-from-no-local-binding/first.js (100%) rename test/{samples => function}/export-from-no-local-binding/main.js (100%) rename test/{samples => function}/export-from-no-local-binding/second.js (100%) rename test/{samples => function}/export-not-at-top-level-fails/_config.js (100%) rename test/{samples => function}/export-not-at-top-level-fails/main.js (100%) rename test/{samples => function}/exports-named-values/_config.js (100%) rename test/{samples => function}/exports-named-values/main.js (100%) rename test/{samples => function}/function-side-effects/_config.js (100%) rename test/{samples => function}/function-side-effects/main.js (100%) rename test/{samples => function}/function-side-effects/mutate.js (100%) rename test/{samples => function}/function-side-effects/object.js (100%) rename test/{samples => function}/import-as/_config.js (100%) rename test/{samples => function}/import-as/foo.js (100%) rename test/{samples => function}/import-as/main.js (100%) rename test/{samples => function}/import-binding/_config.js (100%) rename test/{samples => function}/import-binding/foo.js (100%) rename test/{samples => function}/import-binding/main.js (100%) rename test/{samples => function}/import-chain/_config.js (100%) rename test/{samples => function}/import-chain/first.js (100%) rename test/{samples => function}/import-chain/main.js (100%) rename test/{samples => function}/import-chain/second.js (100%) rename test/{samples => function}/import-default-and-named-function/_config.js (100%) rename test/{samples => function}/import-default-and-named-function/foo.js (100%) rename test/{samples => function}/import-default-and-named-function/main.js (100%) rename test/{samples => function}/import-default-as-named/_config.js (100%) rename test/{samples => function}/import-default-as-named/foo.js (100%) rename test/{samples => function}/import-default-as-named/main.js (100%) rename test/{samples => function}/import-default-as-other/_config.js (100%) rename test/{samples => function}/import-default-as-other/foo.js (100%) rename test/{samples => function}/import-default-as-other/main.js (100%) rename test/{samples => function}/import-default-class/_config.js (100%) rename test/{samples => function}/import-default-class/main.js (100%) rename test/{samples => function}/import-default-class/point.js (100%) rename test/{samples => function}/import-default-expression/_config.js (100%) rename test/{samples => function}/import-default-expression/foo.js (100%) rename test/{samples => function}/import-default-expression/main.js (100%) rename test/{samples => function}/import-default-from-external/_config.js (100%) rename test/{samples => function}/import-default-from-external/main.js (100%) rename test/{samples => function}/import-default-function/_config.js (100%) rename test/{samples => function}/import-default-function/foo.js (100%) rename test/{samples => function}/import-default-function/main.js (100%) rename test/{samples => function}/import-dependency-in-other-module/_config.js (100%) rename test/{samples => function}/import-dependency-in-other-module/bar.js (100%) rename test/{samples => function}/import-dependency-in-other-module/foo.js (100%) rename test/{samples => function}/import-dependency-in-other-module/main.js (100%) rename test/{samples => function}/import-dependency-in-same-module/_config.js (100%) rename test/{samples => function}/import-dependency-in-same-module/foo.js (100%) rename test/{samples => function}/import-dependency-in-same-module/main.js (100%) rename test/{samples => function}/import-named-class/_config.js (100%) rename test/{samples => function}/import-named-class/foo.js (100%) rename test/{samples => function}/import-named-class/main.js (100%) rename test/{samples => function}/import-named-from-external/_config.js (100%) rename test/{samples => function}/import-named-from-external/main.js (100%) rename test/{samples => function}/import-named-function-as-other/_config.js (100%) rename test/{samples => function}/import-named-function-as-other/foo.js (100%) rename test/{samples => function}/import-named-function-as-other/main.js (100%) rename test/{samples => function}/import-named-function/_config.js (100%) rename test/{samples => function}/import-named-function/foo.js (100%) rename test/{samples => function}/import-named-function/main.js (100%) rename test/{samples => function}/import-nameless-class-expression/_config.js (100%) rename test/{samples => function}/import-nameless-class-expression/foo.js (100%) rename test/{samples => function}/import-nameless-class-expression/main.js (100%) rename test/{samples => function}/import-namespace-from-external-module/_config.js (100%) rename test/{samples => function}/import-namespace-from-external-module/main.js (100%) rename test/{samples => function}/import-namespace-from-internal-module/_config.js (100%) rename test/{samples => function}/import-namespace-from-internal-module/foo.js (100%) rename test/{samples => function}/import-namespace-from-internal-module/main.js (100%) rename test/{samples => function}/import-not-at-top-level-fails/_config.js (100%) rename test/{samples => function}/import-not-at-top-level-fails/main.js (100%) rename test/{samples => function}/import-var-declaration/_config.js (100%) rename test/{samples => function}/import-var-declaration/foo.js (100%) rename test/{samples => function}/import-var-declaration/main.js (100%) rename test/{samples => function}/method-call-side-effects/_config.js (100%) rename test/{samples => function}/method-call-side-effects/main.js (100%) rename test/{samples => function}/method-call-side-effects/object.js (100%) rename test/{samples => function}/method-call-side-effects/thing.js (100%) rename test/{samples => function}/namespace-reassign-import-fails/_config.js (100%) rename test/{samples => function}/namespace-reassign-import-fails/foo.js (100%) rename test/{samples => function}/namespace-reassign-import-fails/main.js (100%) rename test/{samples => function}/namespace-update-import-fails/_config.js (100%) rename test/{samples => function}/namespace-update-import-fails/foo.js (100%) rename test/{samples => function}/namespace-update-import-fails/main.js (100%) rename test/{samples => function}/no-imports/_config.js (100%) rename test/{samples => function}/no-imports/main.js (100%) rename test/{samples => function}/object-properties/_config.js (100%) rename test/{samples => function}/object-properties/main.js (100%) rename test/{samples => function}/object-properties/object.js (100%) rename test/{samples => function}/re-export-default-import/_config.js (100%) rename test/{samples => function}/re-export-default-import/first.js (100%) rename test/{samples => function}/re-export-default-import/main.js (100%) rename test/{samples => function}/re-export-default-import/second.js (100%) rename test/{samples => function}/re-export-namespace-import/_config.js (100%) rename test/{samples => function}/re-export-namespace-import/first.js (100%) rename test/{samples => function}/re-export-namespace-import/main.js (100%) rename test/{samples => function}/re-export-namespace-import/second.js (100%) rename test/{samples => function}/reassign-import-fails/_config.js (100%) rename test/{samples => function}/reassign-import-fails/foo.js (100%) rename test/{samples => function}/reassign-import-fails/main.js (100%) rename test/{samples => function}/reassign-import-not-at-top-level-fails/_config.js (100%) rename test/{samples => function}/reassign-import-not-at-top-level-fails/foo.js (100%) rename test/{samples => function}/reassign-import-not-at-top-level-fails/main.js (100%) rename test/{samples => function}/rewrite-member-expressions/_config.js (100%) rename test/{samples => function}/rewrite-member-expressions/getLengthOfOtherQueue.js (100%) rename test/{samples => function}/rewrite-member-expressions/main.js (100%) rename test/{samples => function}/rewrite-member-expressions/mainQueue.js (100%) rename test/{samples => function}/shadowed-variables/_config.js (100%) rename test/{samples => function}/shadowed-variables/foo.js (100%) rename test/{samples => function}/shadowed-variables/main.js (100%) rename test/{samples => function}/this-is-undefined/_config.js (100%) rename test/{samples => function}/this-is-undefined/main.js (100%) rename test/{samples => function}/try-catch-scoping/_config.js (100%) rename test/{samples => function}/try-catch-scoping/foo.js (100%) rename test/{samples => function}/try-catch-scoping/main.js (100%) rename test/{samples => function}/update-expression-of-import-fails/_config.js (100%) rename test/{samples => function}/update-expression-of-import-fails/foo.js (100%) rename test/{samples => function}/update-expression-of-import-fails/main.js (100%) create mode 100644 test/utils/promiseSequence.js diff --git a/test/form/no-imports-or-exports/_config.js b/test/form/no-imports-or-exports/_config.js new file mode 100644 index 0000000..88d3759 --- /dev/null +++ b/test/form/no-imports-or-exports/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'single module, no imports or exports' +}; diff --git a/test/form/no-imports-or-exports/_expected/amd.js b/test/form/no-imports-or-exports/_expected/amd.js new file mode 100644 index 0000000..f0eeb44 --- /dev/null +++ b/test/form/no-imports-or-exports/_expected/amd.js @@ -0,0 +1,5 @@ +define(function () { 'use strict'; + + console.log( 'this is it' ); + +}); diff --git a/test/form/no-imports-or-exports/_expected/cjs.js b/test/form/no-imports-or-exports/_expected/cjs.js new file mode 100644 index 0000000..39727a6 --- /dev/null +++ b/test/form/no-imports-or-exports/_expected/cjs.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log( 'this is it' ); diff --git a/test/form/no-imports-or-exports/_expected/es6.js b/test/form/no-imports-or-exports/_expected/es6.js new file mode 100644 index 0000000..32c5cf7 --- /dev/null +++ b/test/form/no-imports-or-exports/_expected/es6.js @@ -0,0 +1 @@ +console.log( 'this is it' ); diff --git a/test/form/no-imports-or-exports/_expected/umd.js b/test/form/no-imports-or-exports/_expected/umd.js new file mode 100644 index 0000000..37794fa --- /dev/null +++ b/test/form/no-imports-or-exports/_expected/umd.js @@ -0,0 +1,9 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(this, function () { 'use strict'; + + console.log( 'this is it' ); + +})); diff --git a/test/form/no-imports-or-exports/main.js b/test/form/no-imports-or-exports/main.js new file mode 100644 index 0000000..32c5cf7 --- /dev/null +++ b/test/form/no-imports-or-exports/main.js @@ -0,0 +1 @@ +console.log( 'this is it' ); diff --git a/test/samples/allows-external-modules-from-nested-module/_config.js b/test/function/allows-external-modules-from-nested-module/_config.js similarity index 100% rename from test/samples/allows-external-modules-from-nested-module/_config.js rename to test/function/allows-external-modules-from-nested-module/_config.js diff --git a/test/samples/allows-external-modules-from-nested-module/foo.js b/test/function/allows-external-modules-from-nested-module/foo.js similarity index 100% rename from test/samples/allows-external-modules-from-nested-module/foo.js rename to test/function/allows-external-modules-from-nested-module/foo.js diff --git a/test/samples/allows-external-modules-from-nested-module/main.js b/test/function/allows-external-modules-from-nested-module/main.js similarity index 100% rename from test/samples/allows-external-modules-from-nested-module/main.js rename to test/function/allows-external-modules-from-nested-module/main.js diff --git a/test/samples/bindings/_config.js b/test/function/bindings/_config.js similarity index 100% rename from test/samples/bindings/_config.js rename to test/function/bindings/_config.js diff --git a/test/samples/bindings/foo.js b/test/function/bindings/foo.js similarity index 100% rename from test/samples/bindings/foo.js rename to test/function/bindings/foo.js diff --git a/test/samples/bindings/main.js b/test/function/bindings/main.js similarity index 100% rename from test/samples/bindings/main.js rename to test/function/bindings/main.js diff --git a/test/samples/consistent-renaming-b/_config.js b/test/function/consistent-renaming-b/_config.js similarity index 100% rename from test/samples/consistent-renaming-b/_config.js rename to test/function/consistent-renaming-b/_config.js diff --git a/test/samples/consistent-renaming-b/altdir/two.js b/test/function/consistent-renaming-b/altdir/two.js similarity index 100% rename from test/samples/consistent-renaming-b/altdir/two.js rename to test/function/consistent-renaming-b/altdir/two.js diff --git a/test/samples/consistent-renaming-b/main.js b/test/function/consistent-renaming-b/main.js similarity index 100% rename from test/samples/consistent-renaming-b/main.js rename to test/function/consistent-renaming-b/main.js diff --git a/test/samples/consistent-renaming-b/subdir/one.js b/test/function/consistent-renaming-b/subdir/one.js similarity index 100% rename from test/samples/consistent-renaming-b/subdir/one.js rename to test/function/consistent-renaming-b/subdir/one.js diff --git a/test/samples/consistent-renaming-b/subdir/two.js b/test/function/consistent-renaming-b/subdir/two.js similarity index 100% rename from test/samples/consistent-renaming-b/subdir/two.js rename to test/function/consistent-renaming-b/subdir/two.js diff --git a/test/samples/consistent-renaming-c/-internal.js b/test/function/consistent-renaming-c/-internal.js similarity index 100% rename from test/samples/consistent-renaming-c/-internal.js rename to test/function/consistent-renaming-c/-internal.js diff --git a/test/samples/consistent-renaming-c/_config.js b/test/function/consistent-renaming-c/_config.js similarity index 100% rename from test/samples/consistent-renaming-c/_config.js rename to test/function/consistent-renaming-c/_config.js diff --git a/test/samples/consistent-renaming-c/main.js b/test/function/consistent-renaming-c/main.js similarity index 100% rename from test/samples/consistent-renaming-c/main.js rename to test/function/consistent-renaming-c/main.js diff --git a/test/samples/consistent-renaming-c/one.js b/test/function/consistent-renaming-c/one.js similarity index 100% rename from test/samples/consistent-renaming-c/one.js rename to test/function/consistent-renaming-c/one.js diff --git a/test/samples/consistent-renaming-c/one/three.js b/test/function/consistent-renaming-c/one/three.js similarity index 100% rename from test/samples/consistent-renaming-c/one/three.js rename to test/function/consistent-renaming-c/one/three.js diff --git a/test/samples/consistent-renaming-c/one/two.js b/test/function/consistent-renaming-c/one/two.js similarity index 100% rename from test/samples/consistent-renaming-c/one/two.js rename to test/function/consistent-renaming-c/one/two.js diff --git a/test/samples/consistent-renaming-c/two.js b/test/function/consistent-renaming-c/two.js similarity index 100% rename from test/samples/consistent-renaming-c/two.js rename to test/function/consistent-renaming-c/two.js diff --git a/test/samples/consistent-renaming-d/Baz.js b/test/function/consistent-renaming-d/Baz.js similarity index 100% rename from test/samples/consistent-renaming-d/Baz.js rename to test/function/consistent-renaming-d/Baz.js diff --git a/test/samples/consistent-renaming-d/_config.js b/test/function/consistent-renaming-d/_config.js similarity index 100% rename from test/samples/consistent-renaming-d/_config.js rename to test/function/consistent-renaming-d/_config.js diff --git a/test/samples/consistent-renaming-d/bar.js b/test/function/consistent-renaming-d/bar.js similarity index 100% rename from test/samples/consistent-renaming-d/bar.js rename to test/function/consistent-renaming-d/bar.js diff --git a/test/samples/consistent-renaming-d/foo.js b/test/function/consistent-renaming-d/foo.js similarity index 100% rename from test/samples/consistent-renaming-d/foo.js rename to test/function/consistent-renaming-d/foo.js diff --git a/test/samples/consistent-renaming-d/foo/baz.js b/test/function/consistent-renaming-d/foo/baz.js similarity index 100% rename from test/samples/consistent-renaming-d/foo/baz.js rename to test/function/consistent-renaming-d/foo/baz.js diff --git a/test/samples/consistent-renaming-d/main.js b/test/function/consistent-renaming-d/main.js similarity index 100% rename from test/samples/consistent-renaming-d/main.js rename to test/function/consistent-renaming-d/main.js diff --git a/test/samples/consistent-renaming-d/rsvp/all-settled.js b/test/function/consistent-renaming-d/rsvp/all-settled.js similarity index 100% rename from test/samples/consistent-renaming-d/rsvp/all-settled.js rename to test/function/consistent-renaming-d/rsvp/all-settled.js diff --git a/test/samples/consistent-renaming-d/rsvp/enumerator.js b/test/function/consistent-renaming-d/rsvp/enumerator.js similarity index 100% rename from test/samples/consistent-renaming-d/rsvp/enumerator.js rename to test/function/consistent-renaming-d/rsvp/enumerator.js diff --git a/test/samples/consistent-renaming-d/rsvp/promise.js b/test/function/consistent-renaming-d/rsvp/promise.js similarity index 100% rename from test/samples/consistent-renaming-d/rsvp/promise.js rename to test/function/consistent-renaming-d/rsvp/promise.js diff --git a/test/samples/consistent-renaming-d/rsvp/promise/all.js b/test/function/consistent-renaming-d/rsvp/promise/all.js similarity index 100% rename from test/samples/consistent-renaming-d/rsvp/promise/all.js rename to test/function/consistent-renaming-d/rsvp/promise/all.js diff --git a/test/samples/consistent-renaming-e/_config.js b/test/function/consistent-renaming-e/_config.js similarity index 100% rename from test/samples/consistent-renaming-e/_config.js rename to test/function/consistent-renaming-e/_config.js diff --git a/test/samples/consistent-renaming-e/a.js b/test/function/consistent-renaming-e/a.js similarity index 100% rename from test/samples/consistent-renaming-e/a.js rename to test/function/consistent-renaming-e/a.js diff --git a/test/samples/consistent-renaming-e/b.js b/test/function/consistent-renaming-e/b.js similarity index 100% rename from test/samples/consistent-renaming-e/b.js rename to test/function/consistent-renaming-e/b.js diff --git a/test/samples/consistent-renaming-e/main.js b/test/function/consistent-renaming-e/main.js similarity index 100% rename from test/samples/consistent-renaming-e/main.js rename to test/function/consistent-renaming-e/main.js diff --git a/test/samples/consistent-renaming-e/utils.js b/test/function/consistent-renaming-e/utils.js similarity index 100% rename from test/samples/consistent-renaming-e/utils.js rename to test/function/consistent-renaming-e/utils.js diff --git a/test/samples/consistent-renaming/_config.js b/test/function/consistent-renaming/_config.js similarity index 100% rename from test/samples/consistent-renaming/_config.js rename to test/function/consistent-renaming/_config.js diff --git a/test/samples/consistent-renaming/main.js b/test/function/consistent-renaming/main.js similarity index 100% rename from test/samples/consistent-renaming/main.js rename to test/function/consistent-renaming/main.js diff --git a/test/samples/consistent-renaming/one.js b/test/function/consistent-renaming/one.js similarity index 100% rename from test/samples/consistent-renaming/one.js rename to test/function/consistent-renaming/one.js diff --git a/test/samples/consistent-renaming/three.js b/test/function/consistent-renaming/three.js similarity index 100% rename from test/samples/consistent-renaming/three.js rename to test/function/consistent-renaming/three.js diff --git a/test/samples/consistent-renaming/two.js b/test/function/consistent-renaming/two.js similarity index 100% rename from test/samples/consistent-renaming/two.js rename to test/function/consistent-renaming/two.js diff --git a/test/samples/custom-path-resolver-async/_config.js b/test/function/custom-path-resolver-async/_config.js similarity index 100% rename from test/samples/custom-path-resolver-async/_config.js rename to test/function/custom-path-resolver-async/_config.js diff --git a/test/samples/custom-path-resolver-async/bar.js b/test/function/custom-path-resolver-async/bar.js similarity index 100% rename from test/samples/custom-path-resolver-async/bar.js rename to test/function/custom-path-resolver-async/bar.js diff --git a/test/samples/custom-path-resolver-async/main.js b/test/function/custom-path-resolver-async/main.js similarity index 100% rename from test/samples/custom-path-resolver-async/main.js rename to test/function/custom-path-resolver-async/main.js diff --git a/test/samples/custom-path-resolver-sync/_config.js b/test/function/custom-path-resolver-sync/_config.js similarity index 100% rename from test/samples/custom-path-resolver-sync/_config.js rename to test/function/custom-path-resolver-sync/_config.js diff --git a/test/samples/custom-path-resolver-sync/bar.js b/test/function/custom-path-resolver-sync/bar.js similarity index 100% rename from test/samples/custom-path-resolver-sync/bar.js rename to test/function/custom-path-resolver-sync/bar.js diff --git a/test/samples/custom-path-resolver-sync/main.js b/test/function/custom-path-resolver-sync/main.js similarity index 100% rename from test/samples/custom-path-resolver-sync/main.js rename to test/function/custom-path-resolver-sync/main.js diff --git a/test/samples/cycles-defaults/_config.js b/test/function/cycles-defaults/_config.js similarity index 100% rename from test/samples/cycles-defaults/_config.js rename to test/function/cycles-defaults/_config.js diff --git a/test/samples/cycles-defaults/a.js b/test/function/cycles-defaults/a.js similarity index 100% rename from test/samples/cycles-defaults/a.js rename to test/function/cycles-defaults/a.js diff --git a/test/samples/cycles-defaults/b.js b/test/function/cycles-defaults/b.js similarity index 100% rename from test/samples/cycles-defaults/b.js rename to test/function/cycles-defaults/b.js diff --git a/test/samples/cycles-defaults/main.js b/test/function/cycles-defaults/main.js similarity index 100% rename from test/samples/cycles-defaults/main.js rename to test/function/cycles-defaults/main.js diff --git a/test/samples/cycles-immediate/_config.js b/test/function/cycles-immediate/_config.js similarity index 100% rename from test/samples/cycles-immediate/_config.js rename to test/function/cycles-immediate/_config.js diff --git a/test/samples/cycles-immediate/evens.js b/test/function/cycles-immediate/evens.js similarity index 100% rename from test/samples/cycles-immediate/evens.js rename to test/function/cycles-immediate/evens.js diff --git a/test/samples/cycles-immediate/main.js b/test/function/cycles-immediate/main.js similarity index 100% rename from test/samples/cycles-immediate/main.js rename to test/function/cycles-immediate/main.js diff --git a/test/samples/cycles-immediate/odds.js b/test/function/cycles-immediate/odds.js similarity index 100% rename from test/samples/cycles-immediate/odds.js rename to test/function/cycles-immediate/odds.js diff --git a/test/samples/default-export-is-not-bound/_config.js b/test/function/default-export-is-not-bound/_config.js similarity index 100% rename from test/samples/default-export-is-not-bound/_config.js rename to test/function/default-export-is-not-bound/_config.js diff --git a/test/samples/default-export-is-not-bound/foo.js b/test/function/default-export-is-not-bound/foo.js similarity index 100% rename from test/samples/default-export-is-not-bound/foo.js rename to test/function/default-export-is-not-bound/foo.js diff --git a/test/samples/default-export-is-not-bound/main.js b/test/function/default-export-is-not-bound/main.js similarity index 100% rename from test/samples/default-export-is-not-bound/main.js rename to test/function/default-export-is-not-bound/main.js diff --git a/test/samples/duplicate-import-fails/_config.js b/test/function/duplicate-import-fails/_config.js similarity index 100% rename from test/samples/duplicate-import-fails/_config.js rename to test/function/duplicate-import-fails/_config.js diff --git a/test/samples/duplicate-import-fails/foo.js b/test/function/duplicate-import-fails/foo.js similarity index 100% rename from test/samples/duplicate-import-fails/foo.js rename to test/function/duplicate-import-fails/foo.js diff --git a/test/samples/duplicate-import-fails/main.js b/test/function/duplicate-import-fails/main.js similarity index 100% rename from test/samples/duplicate-import-fails/main.js rename to test/function/duplicate-import-fails/main.js diff --git a/test/samples/duplicate-import-specifier-fails/_config.js b/test/function/duplicate-import-specifier-fails/_config.js similarity index 100% rename from test/samples/duplicate-import-specifier-fails/_config.js rename to test/function/duplicate-import-specifier-fails/_config.js diff --git a/test/samples/duplicate-import-specifier-fails/foo.js b/test/function/duplicate-import-specifier-fails/foo.js similarity index 100% rename from test/samples/duplicate-import-specifier-fails/foo.js rename to test/function/duplicate-import-specifier-fails/foo.js diff --git a/test/samples/duplicate-import-specifier-fails/main.js b/test/function/duplicate-import-specifier-fails/main.js similarity index 100% rename from test/samples/duplicate-import-specifier-fails/main.js rename to test/function/duplicate-import-specifier-fails/main.js diff --git a/test/samples/empty-imports-have-side-effects/_config.js b/test/function/empty-imports-have-side-effects/_config.js similarity index 100% rename from test/samples/empty-imports-have-side-effects/_config.js rename to test/function/empty-imports-have-side-effects/_config.js diff --git a/test/samples/empty-imports-have-side-effects/foo.js b/test/function/empty-imports-have-side-effects/foo.js similarity index 100% rename from test/samples/empty-imports-have-side-effects/foo.js rename to test/function/empty-imports-have-side-effects/foo.js diff --git a/test/samples/empty-imports-have-side-effects/main.js b/test/function/empty-imports-have-side-effects/main.js similarity index 100% rename from test/samples/empty-imports-have-side-effects/main.js rename to test/function/empty-imports-have-side-effects/main.js diff --git a/test/samples/export-deconflicted-names/_config.js b/test/function/export-deconflicted-names/_config.js similarity index 100% rename from test/samples/export-deconflicted-names/_config.js rename to test/function/export-deconflicted-names/_config.js diff --git a/test/samples/export-deconflicted-names/bar.js b/test/function/export-deconflicted-names/bar.js similarity index 100% rename from test/samples/export-deconflicted-names/bar.js rename to test/function/export-deconflicted-names/bar.js diff --git a/test/samples/export-deconflicted-names/baz.js b/test/function/export-deconflicted-names/baz.js similarity index 100% rename from test/samples/export-deconflicted-names/baz.js rename to test/function/export-deconflicted-names/baz.js diff --git a/test/samples/export-deconflicted-names/foo.js b/test/function/export-deconflicted-names/foo.js similarity index 100% rename from test/samples/export-deconflicted-names/foo.js rename to test/function/export-deconflicted-names/foo.js diff --git a/test/samples/export-deconflicted-names/main.js b/test/function/export-deconflicted-names/main.js similarity index 100% rename from test/samples/export-deconflicted-names/main.js rename to test/function/export-deconflicted-names/main.js diff --git a/test/samples/export-default-expression/_config.js b/test/function/export-default-expression/_config.js similarity index 100% rename from test/samples/export-default-expression/_config.js rename to test/function/export-default-expression/_config.js diff --git a/test/samples/export-default-expression/main.js b/test/function/export-default-expression/main.js similarity index 100% rename from test/samples/export-default-expression/main.js rename to test/function/export-default-expression/main.js diff --git a/test/samples/export-from-default/_config.js b/test/function/export-from-default/_config.js similarity index 100% rename from test/samples/export-from-default/_config.js rename to test/function/export-from-default/_config.js diff --git a/test/samples/export-from-default/first.js b/test/function/export-from-default/first.js similarity index 100% rename from test/samples/export-from-default/first.js rename to test/function/export-from-default/first.js diff --git a/test/samples/export-from-default/main.js b/test/function/export-from-default/main.js similarity index 100% rename from test/samples/export-from-default/main.js rename to test/function/export-from-default/main.js diff --git a/test/samples/export-from-default/second.js b/test/function/export-from-default/second.js similarity index 100% rename from test/samples/export-from-default/second.js rename to test/function/export-from-default/second.js diff --git a/test/samples/export-from-internal-module/_config.js b/test/function/export-from-internal-module/_config.js similarity index 100% rename from test/samples/export-from-internal-module/_config.js rename to test/function/export-from-internal-module/_config.js diff --git a/test/samples/export-from-internal-module/foo.js b/test/function/export-from-internal-module/foo.js similarity index 100% rename from test/samples/export-from-internal-module/foo.js rename to test/function/export-from-internal-module/foo.js diff --git a/test/samples/export-from-internal-module/main.js b/test/function/export-from-internal-module/main.js similarity index 100% rename from test/samples/export-from-internal-module/main.js rename to test/function/export-from-internal-module/main.js diff --git a/test/samples/export-from-no-local-binding/_config.js b/test/function/export-from-no-local-binding/_config.js similarity index 100% rename from test/samples/export-from-no-local-binding/_config.js rename to test/function/export-from-no-local-binding/_config.js diff --git a/test/samples/export-from-no-local-binding/first.js b/test/function/export-from-no-local-binding/first.js similarity index 100% rename from test/samples/export-from-no-local-binding/first.js rename to test/function/export-from-no-local-binding/first.js diff --git a/test/samples/export-from-no-local-binding/main.js b/test/function/export-from-no-local-binding/main.js similarity index 100% rename from test/samples/export-from-no-local-binding/main.js rename to test/function/export-from-no-local-binding/main.js diff --git a/test/samples/export-from-no-local-binding/second.js b/test/function/export-from-no-local-binding/second.js similarity index 100% rename from test/samples/export-from-no-local-binding/second.js rename to test/function/export-from-no-local-binding/second.js diff --git a/test/samples/export-not-at-top-level-fails/_config.js b/test/function/export-not-at-top-level-fails/_config.js similarity index 100% rename from test/samples/export-not-at-top-level-fails/_config.js rename to test/function/export-not-at-top-level-fails/_config.js diff --git a/test/samples/export-not-at-top-level-fails/main.js b/test/function/export-not-at-top-level-fails/main.js similarity index 100% rename from test/samples/export-not-at-top-level-fails/main.js rename to test/function/export-not-at-top-level-fails/main.js diff --git a/test/samples/exports-named-values/_config.js b/test/function/exports-named-values/_config.js similarity index 100% rename from test/samples/exports-named-values/_config.js rename to test/function/exports-named-values/_config.js diff --git a/test/samples/exports-named-values/main.js b/test/function/exports-named-values/main.js similarity index 100% rename from test/samples/exports-named-values/main.js rename to test/function/exports-named-values/main.js diff --git a/test/samples/function-side-effects/_config.js b/test/function/function-side-effects/_config.js similarity index 100% rename from test/samples/function-side-effects/_config.js rename to test/function/function-side-effects/_config.js diff --git a/test/samples/function-side-effects/main.js b/test/function/function-side-effects/main.js similarity index 100% rename from test/samples/function-side-effects/main.js rename to test/function/function-side-effects/main.js diff --git a/test/samples/function-side-effects/mutate.js b/test/function/function-side-effects/mutate.js similarity index 100% rename from test/samples/function-side-effects/mutate.js rename to test/function/function-side-effects/mutate.js diff --git a/test/samples/function-side-effects/object.js b/test/function/function-side-effects/object.js similarity index 100% rename from test/samples/function-side-effects/object.js rename to test/function/function-side-effects/object.js diff --git a/test/samples/import-as/_config.js b/test/function/import-as/_config.js similarity index 100% rename from test/samples/import-as/_config.js rename to test/function/import-as/_config.js diff --git a/test/samples/import-as/foo.js b/test/function/import-as/foo.js similarity index 100% rename from test/samples/import-as/foo.js rename to test/function/import-as/foo.js diff --git a/test/samples/import-as/main.js b/test/function/import-as/main.js similarity index 100% rename from test/samples/import-as/main.js rename to test/function/import-as/main.js diff --git a/test/samples/import-binding/_config.js b/test/function/import-binding/_config.js similarity index 100% rename from test/samples/import-binding/_config.js rename to test/function/import-binding/_config.js diff --git a/test/samples/import-binding/foo.js b/test/function/import-binding/foo.js similarity index 100% rename from test/samples/import-binding/foo.js rename to test/function/import-binding/foo.js diff --git a/test/samples/import-binding/main.js b/test/function/import-binding/main.js similarity index 100% rename from test/samples/import-binding/main.js rename to test/function/import-binding/main.js diff --git a/test/samples/import-chain/_config.js b/test/function/import-chain/_config.js similarity index 100% rename from test/samples/import-chain/_config.js rename to test/function/import-chain/_config.js diff --git a/test/samples/import-chain/first.js b/test/function/import-chain/first.js similarity index 100% rename from test/samples/import-chain/first.js rename to test/function/import-chain/first.js diff --git a/test/samples/import-chain/main.js b/test/function/import-chain/main.js similarity index 100% rename from test/samples/import-chain/main.js rename to test/function/import-chain/main.js diff --git a/test/samples/import-chain/second.js b/test/function/import-chain/second.js similarity index 100% rename from test/samples/import-chain/second.js rename to test/function/import-chain/second.js diff --git a/test/samples/import-default-and-named-function/_config.js b/test/function/import-default-and-named-function/_config.js similarity index 100% rename from test/samples/import-default-and-named-function/_config.js rename to test/function/import-default-and-named-function/_config.js diff --git a/test/samples/import-default-and-named-function/foo.js b/test/function/import-default-and-named-function/foo.js similarity index 100% rename from test/samples/import-default-and-named-function/foo.js rename to test/function/import-default-and-named-function/foo.js diff --git a/test/samples/import-default-and-named-function/main.js b/test/function/import-default-and-named-function/main.js similarity index 100% rename from test/samples/import-default-and-named-function/main.js rename to test/function/import-default-and-named-function/main.js diff --git a/test/samples/import-default-as-named/_config.js b/test/function/import-default-as-named/_config.js similarity index 100% rename from test/samples/import-default-as-named/_config.js rename to test/function/import-default-as-named/_config.js diff --git a/test/samples/import-default-as-named/foo.js b/test/function/import-default-as-named/foo.js similarity index 100% rename from test/samples/import-default-as-named/foo.js rename to test/function/import-default-as-named/foo.js diff --git a/test/samples/import-default-as-named/main.js b/test/function/import-default-as-named/main.js similarity index 100% rename from test/samples/import-default-as-named/main.js rename to test/function/import-default-as-named/main.js diff --git a/test/samples/import-default-as-other/_config.js b/test/function/import-default-as-other/_config.js similarity index 100% rename from test/samples/import-default-as-other/_config.js rename to test/function/import-default-as-other/_config.js diff --git a/test/samples/import-default-as-other/foo.js b/test/function/import-default-as-other/foo.js similarity index 100% rename from test/samples/import-default-as-other/foo.js rename to test/function/import-default-as-other/foo.js diff --git a/test/samples/import-default-as-other/main.js b/test/function/import-default-as-other/main.js similarity index 100% rename from test/samples/import-default-as-other/main.js rename to test/function/import-default-as-other/main.js diff --git a/test/samples/import-default-class/_config.js b/test/function/import-default-class/_config.js similarity index 100% rename from test/samples/import-default-class/_config.js rename to test/function/import-default-class/_config.js diff --git a/test/samples/import-default-class/main.js b/test/function/import-default-class/main.js similarity index 100% rename from test/samples/import-default-class/main.js rename to test/function/import-default-class/main.js diff --git a/test/samples/import-default-class/point.js b/test/function/import-default-class/point.js similarity index 100% rename from test/samples/import-default-class/point.js rename to test/function/import-default-class/point.js diff --git a/test/samples/import-default-expression/_config.js b/test/function/import-default-expression/_config.js similarity index 100% rename from test/samples/import-default-expression/_config.js rename to test/function/import-default-expression/_config.js diff --git a/test/samples/import-default-expression/foo.js b/test/function/import-default-expression/foo.js similarity index 100% rename from test/samples/import-default-expression/foo.js rename to test/function/import-default-expression/foo.js diff --git a/test/samples/import-default-expression/main.js b/test/function/import-default-expression/main.js similarity index 100% rename from test/samples/import-default-expression/main.js rename to test/function/import-default-expression/main.js diff --git a/test/samples/import-default-from-external/_config.js b/test/function/import-default-from-external/_config.js similarity index 100% rename from test/samples/import-default-from-external/_config.js rename to test/function/import-default-from-external/_config.js diff --git a/test/samples/import-default-from-external/main.js b/test/function/import-default-from-external/main.js similarity index 100% rename from test/samples/import-default-from-external/main.js rename to test/function/import-default-from-external/main.js diff --git a/test/samples/import-default-function/_config.js b/test/function/import-default-function/_config.js similarity index 100% rename from test/samples/import-default-function/_config.js rename to test/function/import-default-function/_config.js diff --git a/test/samples/import-default-function/foo.js b/test/function/import-default-function/foo.js similarity index 100% rename from test/samples/import-default-function/foo.js rename to test/function/import-default-function/foo.js diff --git a/test/samples/import-default-function/main.js b/test/function/import-default-function/main.js similarity index 100% rename from test/samples/import-default-function/main.js rename to test/function/import-default-function/main.js diff --git a/test/samples/import-dependency-in-other-module/_config.js b/test/function/import-dependency-in-other-module/_config.js similarity index 100% rename from test/samples/import-dependency-in-other-module/_config.js rename to test/function/import-dependency-in-other-module/_config.js diff --git a/test/samples/import-dependency-in-other-module/bar.js b/test/function/import-dependency-in-other-module/bar.js similarity index 100% rename from test/samples/import-dependency-in-other-module/bar.js rename to test/function/import-dependency-in-other-module/bar.js diff --git a/test/samples/import-dependency-in-other-module/foo.js b/test/function/import-dependency-in-other-module/foo.js similarity index 100% rename from test/samples/import-dependency-in-other-module/foo.js rename to test/function/import-dependency-in-other-module/foo.js diff --git a/test/samples/import-dependency-in-other-module/main.js b/test/function/import-dependency-in-other-module/main.js similarity index 100% rename from test/samples/import-dependency-in-other-module/main.js rename to test/function/import-dependency-in-other-module/main.js diff --git a/test/samples/import-dependency-in-same-module/_config.js b/test/function/import-dependency-in-same-module/_config.js similarity index 100% rename from test/samples/import-dependency-in-same-module/_config.js rename to test/function/import-dependency-in-same-module/_config.js diff --git a/test/samples/import-dependency-in-same-module/foo.js b/test/function/import-dependency-in-same-module/foo.js similarity index 100% rename from test/samples/import-dependency-in-same-module/foo.js rename to test/function/import-dependency-in-same-module/foo.js diff --git a/test/samples/import-dependency-in-same-module/main.js b/test/function/import-dependency-in-same-module/main.js similarity index 100% rename from test/samples/import-dependency-in-same-module/main.js rename to test/function/import-dependency-in-same-module/main.js diff --git a/test/samples/import-named-class/_config.js b/test/function/import-named-class/_config.js similarity index 100% rename from test/samples/import-named-class/_config.js rename to test/function/import-named-class/_config.js diff --git a/test/samples/import-named-class/foo.js b/test/function/import-named-class/foo.js similarity index 100% rename from test/samples/import-named-class/foo.js rename to test/function/import-named-class/foo.js diff --git a/test/samples/import-named-class/main.js b/test/function/import-named-class/main.js similarity index 100% rename from test/samples/import-named-class/main.js rename to test/function/import-named-class/main.js diff --git a/test/samples/import-named-from-external/_config.js b/test/function/import-named-from-external/_config.js similarity index 100% rename from test/samples/import-named-from-external/_config.js rename to test/function/import-named-from-external/_config.js diff --git a/test/samples/import-named-from-external/main.js b/test/function/import-named-from-external/main.js similarity index 100% rename from test/samples/import-named-from-external/main.js rename to test/function/import-named-from-external/main.js diff --git a/test/samples/import-named-function-as-other/_config.js b/test/function/import-named-function-as-other/_config.js similarity index 100% rename from test/samples/import-named-function-as-other/_config.js rename to test/function/import-named-function-as-other/_config.js diff --git a/test/samples/import-named-function-as-other/foo.js b/test/function/import-named-function-as-other/foo.js similarity index 100% rename from test/samples/import-named-function-as-other/foo.js rename to test/function/import-named-function-as-other/foo.js diff --git a/test/samples/import-named-function-as-other/main.js b/test/function/import-named-function-as-other/main.js similarity index 100% rename from test/samples/import-named-function-as-other/main.js rename to test/function/import-named-function-as-other/main.js diff --git a/test/samples/import-named-function/_config.js b/test/function/import-named-function/_config.js similarity index 100% rename from test/samples/import-named-function/_config.js rename to test/function/import-named-function/_config.js diff --git a/test/samples/import-named-function/foo.js b/test/function/import-named-function/foo.js similarity index 100% rename from test/samples/import-named-function/foo.js rename to test/function/import-named-function/foo.js diff --git a/test/samples/import-named-function/main.js b/test/function/import-named-function/main.js similarity index 100% rename from test/samples/import-named-function/main.js rename to test/function/import-named-function/main.js diff --git a/test/samples/import-nameless-class-expression/_config.js b/test/function/import-nameless-class-expression/_config.js similarity index 100% rename from test/samples/import-nameless-class-expression/_config.js rename to test/function/import-nameless-class-expression/_config.js diff --git a/test/samples/import-nameless-class-expression/foo.js b/test/function/import-nameless-class-expression/foo.js similarity index 100% rename from test/samples/import-nameless-class-expression/foo.js rename to test/function/import-nameless-class-expression/foo.js diff --git a/test/samples/import-nameless-class-expression/main.js b/test/function/import-nameless-class-expression/main.js similarity index 100% rename from test/samples/import-nameless-class-expression/main.js rename to test/function/import-nameless-class-expression/main.js diff --git a/test/samples/import-namespace-from-external-module/_config.js b/test/function/import-namespace-from-external-module/_config.js similarity index 100% rename from test/samples/import-namespace-from-external-module/_config.js rename to test/function/import-namespace-from-external-module/_config.js diff --git a/test/samples/import-namespace-from-external-module/main.js b/test/function/import-namespace-from-external-module/main.js similarity index 100% rename from test/samples/import-namespace-from-external-module/main.js rename to test/function/import-namespace-from-external-module/main.js diff --git a/test/samples/import-namespace-from-internal-module/_config.js b/test/function/import-namespace-from-internal-module/_config.js similarity index 100% rename from test/samples/import-namespace-from-internal-module/_config.js rename to test/function/import-namespace-from-internal-module/_config.js diff --git a/test/samples/import-namespace-from-internal-module/foo.js b/test/function/import-namespace-from-internal-module/foo.js similarity index 100% rename from test/samples/import-namespace-from-internal-module/foo.js rename to test/function/import-namespace-from-internal-module/foo.js diff --git a/test/samples/import-namespace-from-internal-module/main.js b/test/function/import-namespace-from-internal-module/main.js similarity index 100% rename from test/samples/import-namespace-from-internal-module/main.js rename to test/function/import-namespace-from-internal-module/main.js diff --git a/test/samples/import-not-at-top-level-fails/_config.js b/test/function/import-not-at-top-level-fails/_config.js similarity index 100% rename from test/samples/import-not-at-top-level-fails/_config.js rename to test/function/import-not-at-top-level-fails/_config.js diff --git a/test/samples/import-not-at-top-level-fails/main.js b/test/function/import-not-at-top-level-fails/main.js similarity index 100% rename from test/samples/import-not-at-top-level-fails/main.js rename to test/function/import-not-at-top-level-fails/main.js diff --git a/test/samples/import-var-declaration/_config.js b/test/function/import-var-declaration/_config.js similarity index 100% rename from test/samples/import-var-declaration/_config.js rename to test/function/import-var-declaration/_config.js diff --git a/test/samples/import-var-declaration/foo.js b/test/function/import-var-declaration/foo.js similarity index 100% rename from test/samples/import-var-declaration/foo.js rename to test/function/import-var-declaration/foo.js diff --git a/test/samples/import-var-declaration/main.js b/test/function/import-var-declaration/main.js similarity index 100% rename from test/samples/import-var-declaration/main.js rename to test/function/import-var-declaration/main.js diff --git a/test/samples/method-call-side-effects/_config.js b/test/function/method-call-side-effects/_config.js similarity index 100% rename from test/samples/method-call-side-effects/_config.js rename to test/function/method-call-side-effects/_config.js diff --git a/test/samples/method-call-side-effects/main.js b/test/function/method-call-side-effects/main.js similarity index 100% rename from test/samples/method-call-side-effects/main.js rename to test/function/method-call-side-effects/main.js diff --git a/test/samples/method-call-side-effects/object.js b/test/function/method-call-side-effects/object.js similarity index 100% rename from test/samples/method-call-side-effects/object.js rename to test/function/method-call-side-effects/object.js diff --git a/test/samples/method-call-side-effects/thing.js b/test/function/method-call-side-effects/thing.js similarity index 100% rename from test/samples/method-call-side-effects/thing.js rename to test/function/method-call-side-effects/thing.js diff --git a/test/samples/namespace-reassign-import-fails/_config.js b/test/function/namespace-reassign-import-fails/_config.js similarity index 100% rename from test/samples/namespace-reassign-import-fails/_config.js rename to test/function/namespace-reassign-import-fails/_config.js diff --git a/test/samples/namespace-reassign-import-fails/foo.js b/test/function/namespace-reassign-import-fails/foo.js similarity index 100% rename from test/samples/namespace-reassign-import-fails/foo.js rename to test/function/namespace-reassign-import-fails/foo.js diff --git a/test/samples/namespace-reassign-import-fails/main.js b/test/function/namespace-reassign-import-fails/main.js similarity index 100% rename from test/samples/namespace-reassign-import-fails/main.js rename to test/function/namespace-reassign-import-fails/main.js diff --git a/test/samples/namespace-update-import-fails/_config.js b/test/function/namespace-update-import-fails/_config.js similarity index 100% rename from test/samples/namespace-update-import-fails/_config.js rename to test/function/namespace-update-import-fails/_config.js diff --git a/test/samples/namespace-update-import-fails/foo.js b/test/function/namespace-update-import-fails/foo.js similarity index 100% rename from test/samples/namespace-update-import-fails/foo.js rename to test/function/namespace-update-import-fails/foo.js diff --git a/test/samples/namespace-update-import-fails/main.js b/test/function/namespace-update-import-fails/main.js similarity index 100% rename from test/samples/namespace-update-import-fails/main.js rename to test/function/namespace-update-import-fails/main.js diff --git a/test/samples/no-imports/_config.js b/test/function/no-imports/_config.js similarity index 100% rename from test/samples/no-imports/_config.js rename to test/function/no-imports/_config.js diff --git a/test/samples/no-imports/main.js b/test/function/no-imports/main.js similarity index 100% rename from test/samples/no-imports/main.js rename to test/function/no-imports/main.js diff --git a/test/samples/object-properties/_config.js b/test/function/object-properties/_config.js similarity index 100% rename from test/samples/object-properties/_config.js rename to test/function/object-properties/_config.js diff --git a/test/samples/object-properties/main.js b/test/function/object-properties/main.js similarity index 100% rename from test/samples/object-properties/main.js rename to test/function/object-properties/main.js diff --git a/test/samples/object-properties/object.js b/test/function/object-properties/object.js similarity index 100% rename from test/samples/object-properties/object.js rename to test/function/object-properties/object.js diff --git a/test/samples/re-export-default-import/_config.js b/test/function/re-export-default-import/_config.js similarity index 100% rename from test/samples/re-export-default-import/_config.js rename to test/function/re-export-default-import/_config.js diff --git a/test/samples/re-export-default-import/first.js b/test/function/re-export-default-import/first.js similarity index 100% rename from test/samples/re-export-default-import/first.js rename to test/function/re-export-default-import/first.js diff --git a/test/samples/re-export-default-import/main.js b/test/function/re-export-default-import/main.js similarity index 100% rename from test/samples/re-export-default-import/main.js rename to test/function/re-export-default-import/main.js diff --git a/test/samples/re-export-default-import/second.js b/test/function/re-export-default-import/second.js similarity index 100% rename from test/samples/re-export-default-import/second.js rename to test/function/re-export-default-import/second.js diff --git a/test/samples/re-export-namespace-import/_config.js b/test/function/re-export-namespace-import/_config.js similarity index 100% rename from test/samples/re-export-namespace-import/_config.js rename to test/function/re-export-namespace-import/_config.js diff --git a/test/samples/re-export-namespace-import/first.js b/test/function/re-export-namespace-import/first.js similarity index 100% rename from test/samples/re-export-namespace-import/first.js rename to test/function/re-export-namespace-import/first.js diff --git a/test/samples/re-export-namespace-import/main.js b/test/function/re-export-namespace-import/main.js similarity index 100% rename from test/samples/re-export-namespace-import/main.js rename to test/function/re-export-namespace-import/main.js diff --git a/test/samples/re-export-namespace-import/second.js b/test/function/re-export-namespace-import/second.js similarity index 100% rename from test/samples/re-export-namespace-import/second.js rename to test/function/re-export-namespace-import/second.js diff --git a/test/samples/reassign-import-fails/_config.js b/test/function/reassign-import-fails/_config.js similarity index 100% rename from test/samples/reassign-import-fails/_config.js rename to test/function/reassign-import-fails/_config.js diff --git a/test/samples/reassign-import-fails/foo.js b/test/function/reassign-import-fails/foo.js similarity index 100% rename from test/samples/reassign-import-fails/foo.js rename to test/function/reassign-import-fails/foo.js diff --git a/test/samples/reassign-import-fails/main.js b/test/function/reassign-import-fails/main.js similarity index 100% rename from test/samples/reassign-import-fails/main.js rename to test/function/reassign-import-fails/main.js diff --git a/test/samples/reassign-import-not-at-top-level-fails/_config.js b/test/function/reassign-import-not-at-top-level-fails/_config.js similarity index 100% rename from test/samples/reassign-import-not-at-top-level-fails/_config.js rename to test/function/reassign-import-not-at-top-level-fails/_config.js diff --git a/test/samples/reassign-import-not-at-top-level-fails/foo.js b/test/function/reassign-import-not-at-top-level-fails/foo.js similarity index 100% rename from test/samples/reassign-import-not-at-top-level-fails/foo.js rename to test/function/reassign-import-not-at-top-level-fails/foo.js diff --git a/test/samples/reassign-import-not-at-top-level-fails/main.js b/test/function/reassign-import-not-at-top-level-fails/main.js similarity index 100% rename from test/samples/reassign-import-not-at-top-level-fails/main.js rename to test/function/reassign-import-not-at-top-level-fails/main.js diff --git a/test/samples/rewrite-member-expressions/_config.js b/test/function/rewrite-member-expressions/_config.js similarity index 100% rename from test/samples/rewrite-member-expressions/_config.js rename to test/function/rewrite-member-expressions/_config.js diff --git a/test/samples/rewrite-member-expressions/getLengthOfOtherQueue.js b/test/function/rewrite-member-expressions/getLengthOfOtherQueue.js similarity index 100% rename from test/samples/rewrite-member-expressions/getLengthOfOtherQueue.js rename to test/function/rewrite-member-expressions/getLengthOfOtherQueue.js diff --git a/test/samples/rewrite-member-expressions/main.js b/test/function/rewrite-member-expressions/main.js similarity index 100% rename from test/samples/rewrite-member-expressions/main.js rename to test/function/rewrite-member-expressions/main.js diff --git a/test/samples/rewrite-member-expressions/mainQueue.js b/test/function/rewrite-member-expressions/mainQueue.js similarity index 100% rename from test/samples/rewrite-member-expressions/mainQueue.js rename to test/function/rewrite-member-expressions/mainQueue.js diff --git a/test/samples/shadowed-variables/_config.js b/test/function/shadowed-variables/_config.js similarity index 100% rename from test/samples/shadowed-variables/_config.js rename to test/function/shadowed-variables/_config.js diff --git a/test/samples/shadowed-variables/foo.js b/test/function/shadowed-variables/foo.js similarity index 100% rename from test/samples/shadowed-variables/foo.js rename to test/function/shadowed-variables/foo.js diff --git a/test/samples/shadowed-variables/main.js b/test/function/shadowed-variables/main.js similarity index 100% rename from test/samples/shadowed-variables/main.js rename to test/function/shadowed-variables/main.js diff --git a/test/samples/this-is-undefined/_config.js b/test/function/this-is-undefined/_config.js similarity index 100% rename from test/samples/this-is-undefined/_config.js rename to test/function/this-is-undefined/_config.js diff --git a/test/samples/this-is-undefined/main.js b/test/function/this-is-undefined/main.js similarity index 100% rename from test/samples/this-is-undefined/main.js rename to test/function/this-is-undefined/main.js diff --git a/test/samples/try-catch-scoping/_config.js b/test/function/try-catch-scoping/_config.js similarity index 100% rename from test/samples/try-catch-scoping/_config.js rename to test/function/try-catch-scoping/_config.js diff --git a/test/samples/try-catch-scoping/foo.js b/test/function/try-catch-scoping/foo.js similarity index 100% rename from test/samples/try-catch-scoping/foo.js rename to test/function/try-catch-scoping/foo.js diff --git a/test/samples/try-catch-scoping/main.js b/test/function/try-catch-scoping/main.js similarity index 100% rename from test/samples/try-catch-scoping/main.js rename to test/function/try-catch-scoping/main.js diff --git a/test/samples/update-expression-of-import-fails/_config.js b/test/function/update-expression-of-import-fails/_config.js similarity index 100% rename from test/samples/update-expression-of-import-fails/_config.js rename to test/function/update-expression-of-import-fails/_config.js diff --git a/test/samples/update-expression-of-import-fails/foo.js b/test/function/update-expression-of-import-fails/foo.js similarity index 100% rename from test/samples/update-expression-of-import-fails/foo.js rename to test/function/update-expression-of-import-fails/foo.js diff --git a/test/samples/update-expression-of-import-fails/main.js b/test/function/update-expression-of-import-fails/main.js similarity index 100% rename from test/samples/update-expression-of-import-fails/main.js rename to test/function/update-expression-of-import-fails/main.js diff --git a/test/test.js b/test/test.js index 4888ae5..2e02c3e 100644 --- a/test/test.js +++ b/test/test.js @@ -5,9 +5,11 @@ var path = require( 'path' ); var sander = require( 'sander' ); var assert = require( 'assert' ); var babel = require( 'babel-core' ); +var sequence = require( './utils/promiseSequence' ); var rollup = require( '../dist/rollup' ); -var SAMPLES = path.resolve( __dirname, 'samples' ); +var FUNCTION = path.resolve( __dirname, 'function' ); +var FORM = path.resolve( __dirname, 'form' ); function extend ( target ) { [].slice.call( arguments, 1 ).forEach( function ( source ) { @@ -20,97 +22,142 @@ function extend ( target ) { } describe( 'rollup', function () { - it( 'exists', function () { - assert.ok( !!rollup ); - }); + describe( 'sanity checks', function () { + it( 'exists', function () { + assert.ok( !!rollup ); + }); - it( 'has a rollup method', function () { - assert.equal( typeof rollup.rollup, 'function' );; + it( 'has a rollup method', function () { + assert.equal( typeof rollup.rollup, 'function' ); + }); }); - sander.readdirSync( SAMPLES ).sort().forEach( function ( dir ) { - if ( dir[0] === '.' ) return; // .DS_Store... - - var config; - - try { - config = require( SAMPLES + '/' + dir + '/_config' ); - } catch ( err ) { - config = { description: dir }; - } + describe( 'function', function () { + sander.readdirSync( FUNCTION ).sort().forEach( function ( dir ) { + if ( dir[0] === '.' ) return; // .DS_Store... - ( config.skip ? it.skip : config.solo ? it.only : it )( dir, function () { - return rollup.rollup( SAMPLES + '/' + dir + '/main.js', extend( {}, config.options ) ) - .then( function ( bundle ) { - var unintendedError; + var config; - if ( config.error ) { - throw new Error( 'Expected an error while rolling up' ); - } + try { + config = require( FUNCTION + '/' + dir + '/_config' ); + } catch ( err ) { + config = { description: dir }; + } - // try to generate output - try { - var result = bundle.generate( extend( {}, config.bundleOptions, { - format: 'cjs' - })); + ( config.skip ? it.skip : config.solo ? it.only : it )( dir, function () { + return rollup.rollup( FUNCTION + '/' + dir + '/main.js', extend( {}, config.options ) ) + .then( function ( bundle ) { + var unintendedError; if ( config.error ) { - unintendedError = new Error( 'Expected an error while generating output' ); + throw new Error( 'Expected an error while rolling up' ); } - } catch ( err ) { - if ( config.error ) { - config.error( err ); - } else { - unintendedError = err; - } - } - - if ( unintendedError ) throw unintendedError; - var code; - - try { - if ( config.babel ) { - code = babel.transform( code, { - whitelist: config.babel - }).code; - } else { - code = result.code; + // try to generate output + try { + var result = bundle.generate( extend( {}, config.bundleOptions, { + format: 'cjs' + })); + + if ( config.error ) { + unintendedError = new Error( 'Expected an error while generating output' ); + } + } catch ( err ) { + if ( config.error ) { + config.error( err ); + } else { + unintendedError = err; + } } - var fn = new Function( 'require', 'module', 'exports', 'assert', code ); - var module = { - exports: {} - }; - fn( require, module, module.exports, assert ); - - if ( config.error ) { - unintendedError = new Error( 'Expected an error while executing output' ); + if ( unintendedError ) throw unintendedError; + + var code; + + try { + if ( config.babel ) { + code = babel.transform( code, { + whitelist: config.babel + }).code; + } else { + code = result.code; + } + + var fn = new Function( 'require', 'module', 'exports', 'assert', code ); + var module = { + exports: {} + }; + fn( require, module, module.exports, assert ); + + if ( config.error ) { + unintendedError = new Error( 'Expected an error while executing output' ); + } + + if ( config.exports ) { + config.exports( module.exports ); + } + } catch ( err ) { + if ( config.error ) { + config.error( err ); + } else { + unintendedError = err; + } } - if ( config.exports ) { - config.exports( module.exports ); + if ( config.show || unintendedError ) { + console.log( code + '\n\n\n' ); } - } catch ( err ) { + + if ( unintendedError ) throw unintendedError; + }, function ( err ) { if ( config.error ) { config.error( err ); } else { - unintendedError = err; + throw err; } - } - - if ( config.show || unintendedError ) { - console.log( code + '\n\n\n' ); - } - - if ( unintendedError ) throw unintendedError; - }, function ( err ) { - if ( config.error ) { - config.error( err ); - } else { - throw err; - } + }); + }); + }); + }); + + describe( 'form', function () { + var profiles = [ + { format: 'amd' }, + { format: 'cjs' }, + { format: 'es6' }, + { format: 'umd' } + ]; + + sander.readdirSync( FORM ).sort().forEach( function ( dir ) { + if ( dir[0] === '.' ) return; // .DS_Store... + + var config; + + try { + config = require( FORM + '/' + dir + '/_config' ); + } catch ( err ) { + config = { description: dir }; + } + + var bundlePromise = rollup.rollup( FORM + '/' + dir + '/main.js', extend( {}, config.options ) ); + + profiles.forEach( function ( profile ) { + ( config.skip ? it.skip : config.solo ? it.only : it )( dir + ' (' + profile.format + ')', function () { + return bundlePromise.then( function ( bundle ) { + var actual = bundle.generate({ + format: profile.format + }).code.trim(); + + try { + var expected = sander.readFileSync( FORM, dir, '_expected', profile.format + '.js' ).toString().trim(); + } catch ( err ) { + assert.equal( actual, 'missing file' ); + } + + assert.equal( actual, expected ); + }); }); + }); }); }); }); diff --git a/test/utils/promiseSequence.js b/test/utils/promiseSequence.js new file mode 100644 index 0000000..5eed953 --- /dev/null +++ b/test/utils/promiseSequence.js @@ -0,0 +1,28 @@ +var Promise = require( 'sander' ).Promise; + +module.exports = function sequence ( arr, callback ) { + var len = arr.length; + var results = new Array( len ); + + var promise = Promise.resolve(); + + function next ( i ) { + return promise + .then( function () { + return callback( arr[i], i ); + }) + .then( function ( result ) { + results[i] = result; + }); + } + + var i; + + for ( i = 0; i < len; i += 1 ) { + promise = next( i ); + } + + return promise.then( function () { + return results; + }); +};