diff options
Diffstat (limited to 'test')
227 files changed, 3373 insertions, 0 deletions
diff --git a/test/test-babel-runtime.html b/test/test-babel-runtime.html new file mode 100644 index 000000000..bb62e1e42 --- /dev/null +++ b/test/test-babel-runtime.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system.src.js" type="text/javascript"></script> + + <script src="../bower_components/qunit/qunit/qunit.js"></script> + + <script> + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS Runtime"); + + function err(e) { + setTimeout(function() { + throw e.stack || e; + start(); + }); + } + + System.transpiler = 'babel'; + System.paths['babel/external-helpers'] = '../node_modules/babel-core/external-helpers.js'; + + asyncTest('Dynamicall loading modules with Traceur runtime', function() { + System['import']('tests/with-runtime-babel.js').then(function(m) { + ok(m.c); + start(); + }, err); + }); + + </script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-babel.html b/test/test-babel.html new file mode 100644 index 000000000..2cf3d1ea7 --- /dev/null +++ b/test/test-babel.html @@ -0,0 +1,29 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system.src.js" type="text/javascript"></script> + <script> + System.paths.babel = '../node_modules/babel-core/browser.js'; + System.transpiler = 'babel'; + System['import']('test.js')['catch'](function(e) { + setTimeout(function() { + throw e.stack || e; + }) + }); + </script> + + <script src="../bower_components/qunit/qunit/qunit.js"></script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-babel.js b/test/test-babel.js new file mode 100644 index 000000000..062b6158e --- /dev/null +++ b/test/test-babel.js @@ -0,0 +1,3 @@ +System.transpiler = 'babel'; +System.baseURL = 'test/'; +require('./test');
\ No newline at end of file diff --git a/test/test-csp-inline.html b/test/test-csp-inline.html new file mode 100644 index 000000000..4f6dce16e --- /dev/null +++ b/test/test-csp-inline.html @@ -0,0 +1,61 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc';"> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system.src.js" type="text/javascript"></script> + <script src="../bower_components/qunit/qunit/qunit.js"></script> + + <script nonce='abc'> + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS nonce"); + + function err(e) { + setTimeout(function() { + throw e.stack || e; + start(); + }); + } + + asyncTest('Importing a script with a good nonce', function() { + System.config({ + meta: { + 'tests/csp/nonce.js': { + nonce: 'abc' + } + } + }); + System['import']('tests/csp/nonce.js').then(function(m) { + ok(m.nonce === 'abc'); + start(); + }); + }); + + asyncTest('Importing a script with a bad nonce', function() { + System.config({ + meta: { + 'tests/csp/nonce2.js': { + nonce: 'asdf' + } + } + }); + System['import']('tests/csp/nonce2.js').then(function(m) { + ok(m.nonce !== 'ab'); + start(); + }); + }); + </script> + </body> +</html> diff --git a/test/test-csp.html b/test/test-csp.html new file mode 100644 index 000000000..f488974f6 --- /dev/null +++ b/test/test-csp.html @@ -0,0 +1,280 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system-csp-production.src.js" type="text/javascript"></script> + <script src="../bower_components/qunit/qunit/qunit.js"></script> + + <script> + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS CSP"); + + function err(e) { + setTimeout(function() { + throw e.stack || e; + start(); + }); + } + + asyncTest('System version', function() { + ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? CSP$/)); + start(); + }); + + asyncTest('Loading an AMD module', function() { + System['import']('tests/amd-module.js').then(function(m) { + ok(m.amd == true); + ok(m.dep.amd == 'dep'); + start(); + }, err); + }); + + System.config({ + bundles: { + 'tests/amd-bundle.js': ['bundle-1', 'bundle-2'] + } + }); + asyncTest('Loading an AMD bundle', function() { + System['import']('bundle-1').then(function(m) { + ok(m.defined == true); + start(); + }, err); + + stop(); + System['import']('bundle-2').then(function(m) { + ok(m.defined == true); + start(); + }, err); + }); + + asyncTest('Loading an AMD named define', function() { + System['import']('tests/nameddefine.js').then(function() { + System['import']('another-define').then(function(m) { + ok(m.named == 'define'); + start(); + }, err); + }, err); + }); + + asyncTest('Global script with exports as an array', function() { + System.config({ + meta: { + 'tests/global-exports-array.js': { + exports: ['A', 'B'] + } + } + }); + + System['import']('tests/global-exports-array.js').then(function(m) { + ok(m.A == 'A'); + ok(m.B == 'B'); + ok(!m.C); + ok(m['default'] == 'A'); + start(); + }, err); + }); + + asyncTest('Loading a badly named AMD define', function() { + System['import']('tests/jquery-named.js').then(function(jquery) { + ok(jquery.is == 'jquery'); + start(); + }, err); + }); + + + asyncTest('System.register Circular', function() { + System['import']('tests/register-circular1.js').then(function(m) { + ok(m.q == 3, 'Binding not allocated'); + ok(m.r == 5, 'Binding not updated'); + start(); + }, err); + }); + + + asyncTest('Loading a UMD module', function() { + System['import']('tests/umd.js').then(function(m) { + ok(m.d == 'hi'); + start(); + }, err); + }); + + asyncTest('Loading a bundle', function() { + System['import']('tests/bundle.js').then(function(m) { + return System['import']('bundle-define1'); + }) + .then(function(m) { + ok(m.name == 'bundle1'); + + return System['import']('bundle-define2'); + }) + .then(function(m) { + ok(m.name == 'bundle2'); + + start(); + }) + ['catch'](err); + }); + + asyncTest('Loading a bundle on demand', function() { + + System.config({ + bundles: { + 'tests/main-bundle.js': ['jquery'] + } + }); + System['import']('jquery').then(function(m) { + ok(m.name == 'jquery-bundled'); + start(); + }, err); + }); + + System.config({ + bundles: { + 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first'] + } + }); + asyncTest('Loading AMD from a bundle', function() { + System['import']('tree/amd').then(function(m) { + ok(m.is == 'amd'); + start(); + }, err); + }); + + asyncTest('Loading CommonJS from a bundle', function() { + System['import']('tree/cjs').then(function(m) { + ok(m.cjs === true); + start(); + }, err); + }); + + asyncTest('Loading a Global from a bundle', function() { + System['import']('tree/global').then(function(m) { + ok(m === 'output'); + start(); + }, err); + }); + + asyncTest('Loading named System.register', function() { + System['import']('tree/third').then(function(m) { + ok(m.some == 'exports'); + start(); + }, err); + }); + + asyncTest('Loading System.register from ES6', function() { + System['import']('tree/first').then(function(m) { + ok(m.p == 5); + start(); + }); + }); + + asyncTest('Running a simple non-fetch plugin', function() { + System.set('tests/es6-plugin', System.newModule({ + fetch: function() { + return ''; + }, + instantiate: function() { + return "plugin"; + } + })); + System['import']('test/file!tests/es6-plugin').then(function(m) { + ok(m == 'plugin'); + start(); + }); + }); + + asyncTest('Loading a non-registering module', function() { + System['import']('tests/global-dep.js')['catch'](function(e) { + ok(e.toString().indexOf('did not call System.register or AMD define') != -1); + start(); + }); + }); + + asyncTest('Loading a global with exports defined', function() { + System.config({ + meta: { + 'tests/global-single.js': { + exports: 'foo' + } + } + }); + System['import']('tests/global-single.js').then(function(m) { + ok(m == 'bar'); + start(); + }); + }); + + asyncTest('Loading a precompiled global with exports still defined', function() { + System.config({ + meta: { + 'tests/global-single-compiled.js': { + exports: 'foobar' + } + } + }); + System['import']('tests/global-single-compiled.js').then(function(m) { + ok(m == 'foo'); + start(); + }); + }); + + asyncTest('Importing a script with wrong integrity fails', function() { + System.config({ + meta: { + 'tests/csp/integrity.js': { + integrity: 'sha256-abc' + } + } + }); + System['import']('tests/csp/integrity.js').then(err, function(e) { + ok(typeof e !== 'undefined'); + start(); + }); + }); + + asyncTest('Importing a script with correct integrity', function() { + System.config({ + meta: { + 'tests/csp/integrity.js': { + integrity: 'sha256-_AfZ2eZSJyVU4HFktUpbsTEoSJF1hL5eGKjgdXZnNTw=' + } + } + }); + System['import']('tests/csp/integrity.js').then(function(m) { + ok(m.integrity === 'integrity'); + start(); + }, err); + }); + + asyncTest('Importing jQuery from CDN', function() { + System['import']('https://code.jquery.com/jquery-1.11.3.min.js').then(function($) { + ok($.fn); + start(); + }); + }); + + asyncTest('Loading package configuration json', function() { + System.config({ + packageConfigPaths: ['tests/testpkg*.json'] + }); + System.import('tests/testpkg2') + .then(function(m) { + ok(m.asdf == 'asdf'); + start(); + }, err); + }) + </script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-jsextensions.html b/test/test-jsextensions.html new file mode 100644 index 000000000..bb64a8f73 --- /dev/null +++ b/test/test-jsextensions.html @@ -0,0 +1,112 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + <script src="../bower_components/qunit/qunit/qunit.js"></script> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script> + // test polyfill loading + // window.URL = undefined; + </script> + + <script src="../dist/system.src.js" type="text/javascript"></script> + <script> + System.traceurOptions = { asyncFunctions: true }; + System.paths.traceur = '../node_modules/traceur/bin/traceur.js'; + + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS JS Extensions"); + + System.config({ + defaultJSExtensions: true + }); + + asyncTest('Error handling', function() { + System['import']('tests/main').then(function(m) { + ok(m.dep == 'value'); + start(); + }); + }); + + asyncTest('Pathing extension handling', function() { + System.config({ + paths: { + 'path': 'tests/main' + }, + packages: { + 'tests/testpkg': { + basePath: 'lib', + defaultExtension: 'ts', + map: { + './asdf': './test.ts' + } + }, + 'tests/subcontextual-map': { + main: 'submodule', + map: { + dep: 'path' + } + } + } + }); + + Promise.all([ + System['import']('path'), + System['import']('tests/testpkg/asdf'), + System['import']('tests/subcontextual-map'), + System['import']('tests/main-dep'), + System['import']('tests/main-dep.js') + ]) + .then(function(mods) { + ok(mods[0].dep == 'value'); + ok(mods[1] == 'ts'); + ok(mods[2].dep == 'value'); + ok(mods[3] == mods[2]); + ok(mods[3] == mods[4]); + start(); + }) + }); + + System.config({ + packages: { + 'custom': { + defaultExtension: 'ext' + } + } + }); + asyncTest('Register extensions', function(err) { + System['import']('tests/register-default-extension.js').then(function() { + System['import']('custom/file.ext').then(function(m) { + ok(m.custom == 'ext'); + start(); + }, err); + }, err); + }); + + System.config({ + packages: { + 'tests/no-default-ext': { + defaultExtension: false + } + } + }); + asyncTest('No default extension', function(err) { + System['import']('tests/no-default-ext/file.ext').then(function(m) { + ok(m.ext == 'ext'); + start(); + }, err); + }); + </script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-register-only.html b/test/test-register-only.html new file mode 100644 index 000000000..65ff64100 --- /dev/null +++ b/test/test-register-only.html @@ -0,0 +1,45 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system-register-only.src.js" type="text/javascript"></script> + <script src="../bower_components/qunit/qunit/qunit.js"></script> + + <script> + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS CSP"); + + function err(e) { + setTimeout(function() { + throw e.stack || e; + start(); + }); + } + + asyncTest('System version', function() { + ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? Register Only$/)); + start(); + }); + + asyncTest('System.register Circular', function() { + System['import']('tests/register-circular1.js').then(function(m) { + ok(m.q == 3, 'Binding not allocated'); + ok(m.r == 5, 'Binding not updated'); + start(); + }, err); + }); + </script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-tracer.html b/test/test-tracer.html new file mode 100644 index 000000000..52075004f --- /dev/null +++ b/test/test-tracer.html @@ -0,0 +1,71 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script src="../dist/system.src.js" type="text/javascript"></script> + + <script src="../bower_components/qunit/qunit/qunit.js"></script> + + <script> + System.paths.traceur = '../node_modules/traceur/bin/traceur.js'; + + QUnit.config.testTimeout = 2000; + + QUnit.module("SystemJS Tracer"); + + function err(e) { + setTimeout(function() { + throw e.stack || e; + start(); + }); + } + + // enable tracing + System.pluginLoader = new System.constructor(); + System.pluginLoader.paths = System.paths; + System.pluginLoader.baseURL = System.baseURL; + System.trace = true; + // System.execute = false; + + asyncTest('ES6 Circular', function() { + System['import']('tests/es6-circular1.js').then(function(m) { + ok(System.loads[System.normalizeSync('tests/es6-circular1.js')].deps[0] == './es6-circular2.js'); + start(); + }, err); + }); + + asyncTest('AMD & CJS circular, ES6 Circular', function() { + System['import']('tests/all-circular1.js').then(function(m) { + ok(System.loads[System.normalizeSync('tests/all-circular1.js')].deps[0] == './all-circular2.js'); + start(); + }, err); + }); + + asyncTest('AMD -> System.register circular -> ES6', function() { + System['import']('tests/all-layers1.js').then(function(m) { + ok(System.loads[System.normalizeSync('tests/all-layers1.js')].deps[0] == './all-layers2.js'); + start(); + }, err); + }); + + asyncTest('Advanced compiler plugin', function() { + System['import']('tests/compiler-test.coffee!tests/advanced-plugin.js').then(function(m) { + ok(true); + start(); + }, err); + }); + + </script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-traceur.html b/test/test-traceur.html new file mode 100644 index 000000000..87f4cd23d --- /dev/null +++ b/test/test-traceur.html @@ -0,0 +1,34 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <script> + // test polyfill loading + // window.URL = undefined; + </script> + + <script src="../dist/system.src.js" type="text/javascript"></script> + <script> + System.traceurOptions = { asyncFunctions: true }; + System.paths.traceur = '../node_modules/traceur/bin/traceur.js'; + System['import']('test.js')['catch'](function(e) { + setTimeout(function() { + throw e.stack || e; + }); + }); + </script> + + <script src="../bower_components/qunit/qunit/qunit.js"></script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-traceur.js b/test/test-traceur.js new file mode 100644 index 000000000..983f51b36 --- /dev/null +++ b/test/test-traceur.js @@ -0,0 +1,3 @@ +System.transpiler = 'traceur'; +System.baseURL = 'test/'; +require('./test');
\ No newline at end of file diff --git a/test/test-typescript.html b/test/test-typescript.html new file mode 100644 index 000000000..4258164c9 --- /dev/null +++ b/test/test-typescript.html @@ -0,0 +1,31 @@ +<!doctype html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/> + </head> + <body> + + <h1 id="qunit-header">SystemJS Test Suite</h1> + + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-test-area"></div> + + <!-- <script src="../bower_components/traceur/traceur.js"></script> --> + <script src="../node_modules/es6-module-loader/dist/es6-module-loader.src.js"></script> + <script src="../dist/system.src.js" type="text/javascript"></script> + <script> + System.paths['typescript'] = '../node_modules/typescript/lib/typescript.js'; + System.transpiler = 'typescript'; + System['import']('test.js')['catch'](function(e) { + setTimeout(function() { + throw e; + }) + }); + </script> + + <script src="../bower_components/qunit/qunit/qunit.js"></script> + </body> +</html>
\ No newline at end of file diff --git a/test/test-typescript.js b/test/test-typescript.js new file mode 100644 index 000000000..e7a858309 --- /dev/null +++ b/test/test-typescript.js @@ -0,0 +1,4 @@ +global.ts = require('typescript'); +System.transpiler = 'typescript'; +System.baseURL = 'test/'; +require('./test');
\ No newline at end of file diff --git a/test/test.js b/test/test.js new file mode 100644 index 000000000..6d981d761 --- /dev/null +++ b/test/test.js @@ -0,0 +1,1462 @@ +"format global"; + +(function(global) { + +QUnit.config.testTimeout = 30000; + +QUnit.module("SystemJS"); + +if (typeof window == 'undefined') + System.baseURL = 'test'; + +function err(e) { + setTimeout(function() { + if (typeof window == 'undefined') + console.log(e && e.stack || e); + else + throw e; + start(); + }); +} + +var ie8 = typeof navigator != 'undefined' && navigator.appVersion && navigator.appVersion.indexOf('MSIE 8') != -1; + +asyncTest('System version', function() { + ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? (Standard|Node)$/)); + start(); +}); + +asyncTest('new Module().toString() == "Module"', function() { + System['import']('tests/global.js').then(function() { + var m = System.get(System.normalizeSync('tests/global.js')); + ok(m == 'Module'); + start(); + }); +}); + +asyncTest('Error handling', function() { + System['import']('tests/error-loader.js').then(err, function(e) { + ok(true); + start(); + }); +}); + +asyncTest('Error handling2', function() { + System['import']('tests/error-loader2.js').then(err, function(e) { + if (typeof console != 'undefined' && console.error) + console.error(e); + ok(true); + start(); + }); +}); + +if (!ie8) +asyncTest('Global script loading', function() { + System['import']('tests/global.js').then(function(m) { + ok(m.jjQuery && m.another, 'Global objects not defined'); + start(); + }, err); +}); + +if (!ie8) +asyncTest('Global script with var syntax', function() { + System['import']('tests/global-single.js').then(function(m) { + ok(m == 'bar', 'Wrong global value'); + start(); + }, err); +}); + +asyncTest('Global script with multiple objects the same', function() { + System['import']('tests/global-multi.js').then(function(m) { + ok(m.jquery == 'here', 'Multi globals not detected'); + start(); + }, err); +}); + +if (!ie8) +asyncTest('Global script multiple objects different', function() { + System['import']('tests/global-multi-diff.js').then(function(m) { + ok(m.foo == 'barz'); + ok(m.baz == 'chaz'); + ok(m.zed == 'ted'); + start(); + }, err); +}); + +asyncTest('Global script loading with inline shim', function() { + System['import']('tests/global-inline-dep.js').then(function(m) { + ok(m == '1.8.3', 'Global dependency not defined'); + start(); + }, err); +}); + +asyncTest('Global script with inline exports', function() { + System['import']('tests/global-inline-export.js').then(function(m) { + ok(m == 'r', 'Inline export not applied'); + start(); + }, err); +}); + +asyncTest('Global script with shim config', function() { + System.config({ + meta: { + 'tests/global-shim-config.js': { + deps: ['./global-shim-config-dep.js'] + } + } + }); + // System. = { deps: ['./global-shim-config-dep.js'] }; + System['import']('tests/global-shim-config.js').then(function(m) { + ok(m == 'shimmed', 'Not shimmed'); + start(); + }, err); +}); + +if (!ie8) +asyncTest('Global script with inaccessible properties', function() { + Object.defineProperty(System.global, 'errorOnAccess', { + configurable: true, + enumerable: true, + get: function() { throw Error('This property is inaccessible'); }, + }); + + System['import']('tests/global-inaccessible-props.js').then(function(m) { + ok(m == 'result of global-inaccessible-props', 'Failed due to a inaccessible property'); + + delete System.global.errorOnAccess; + start(); + }, err); +}); + +asyncTest('Global script loading that detects as AMD with shim config', function() { + System.config({ + meta: { + 'tests/global-shim-amd.js': { format: 'global' } + } + }); + + System['import']('tests/global-shim-amd.js').then(function(m) { + ok(m == 'global', 'Not shimmed'); + start(); + }, err); +}); + +asyncTest('Global script with exports as an array', function() { + System.config({ + meta: { + 'tests/global-exports-array.js': { + exports: ['A', 'B'] + } + } + }); + + System['import']('tests/global-exports-array.js').then(function(m) { + ok(m.A == 'A'); + ok(m.B == 'B'); + ok(!m.C); + ok(m['default'] == 'A'); + start(); + }, err); +}); + +asyncTest('Global with encapsulated execution', function() { + System.config({ + meta: { + 'tests/global-encapsulation.js': { + encapsulateGlobal: true + } + } + }); + + System['import']('tests/global-encapsulation.js').then(function(m) { + ok(m == 'encapsulated global'); + ok(global.globalName === undefined); + start(); + }, err); +}); + +if (!ie8) +asyncTest('Meta should override meta syntax', function() { + System.meta[System.normalizeSync('tests/meta-override.js')] = { format: 'esm' }; + System['import']('tests/meta-override.js').then(function(m) { + ok(m.p == 'value', 'Not ES6'); + start(); + }, err); +}); + +asyncTest('Support the empty module', function() { + System['import']('@empty').then(function(m) { + ok(m, 'No empty module'); + start(); + }, err); +}); + +asyncTest('Global script with shim config exports', function() { + System.meta[System.normalizeSync('tests/global-shim-config-exports.js')] = { exports: 'p' }; + System['import']('tests/global-shim-config-exports.js').then(function(m) { + ok(m == 'export', 'Exports not shimmed'); + start(); + }, err); +}); + +asyncTest('Map configuration', function() { + System.map['maptest'] = 'tests/map-test.js'; + System['import']('maptest').then(function(m) { + ok(m.maptest == 'maptest', 'Mapped module not loaded'); + start(); + }, err); +}); + +asyncTest('Map configuration subpath', function() { + System.map['maptest'] = 'tests/map-test'; + System['import']('maptest/sub.js').then(function(m) { + ok(m.maptest == 'maptestsub', 'Mapped folder not loaded'); + start(); + }, err); +}); + +asyncTest('Contextual map configuration', function() { + System.config({ + packages: { + 'tests/contextual-test': { + main: 'contextual-map.js' + } + }, + map: { + 'tests/contextual-test': { + maptest: '../contextual-map-dep.js' + } + } + }); + System['import']('tests/contextual-test').then(function(m) { + ok(m.mapdep == 'mapdep', 'Contextual map dep not loaded'); + start(); + }, err); +}); + +asyncTest('Contextual map configuration for a package that is a file', function() { + System.config({ + packages: { + 'tests/jquery.js': { + meta: { + '*': { + deps: ['a'] + } + }, + map: { + 'a': 'tests/amd-dep-A.js' + } + } + }, + map: { + jquery: 'tests/jquery.js' + } + }); + System['import']('tests/jquery.js').then(function(m) { + ok(m == 10); + start(); + }, err); +}) + +asyncTest('Package map with shim', function() { + System.config({ + packages: { + 'tests/shim-package': { + meta: { + '*': { + deps: ['shim-map-dep'] + } + }, + map: { + 'shim-map-dep': '../shim-map-test-dep.js' + } + } + } + }); + System['import']('tests/shim-package/shim-map-test.js').then(function(m) { + ok(m == 'depvalue', 'shim dep not loaded'); + start(); + }, err); +}); + +asyncTest('Loading an AMD module', function() { + System.config({ + meta: { + 'tests/amd-module.js': { + format: 'amd' + } + } + }); + System['import']('tests/amd-module.js').then(function(m) { + ok(m.amd == true, 'Incorrect module'); + ok(m.dep.amd == 'dep', 'Dependency not defined'); + start(); + }, err); +}); + +asyncTest('AMD detection test', function() { + System['import']('tests/amd-module-2.js').then(function(m) { + ok(m.amd); + start(); + }, err); +}); + +asyncTest('AMD detection test with comments', function() { + System['import']('tests/amd-module-3.js').then(function(m) { + ok(m.amd); + start(); + }, err); +}); + +asyncTest('AMD detection test with byte order mark (BOM)', function() { + System['import']('tests/amd-module-bom.js').then(function(m) { + ok(m.amd); + start(); + }, err); +}); + +asyncTest('AMD with dynamic require callback', function() { + System['import']('tests/amd-dynamic-require.js').then(function(m) { + m.onCallback(function(m) { + ok(m === 'dynamic'); + start(); + }); + }); +}); + +asyncTest('Loading an AMD bundle', function() { + System.config({ + bundles: { + 'tests/amd-bundle.js': ['bundle-*'] + } + }); + System['import']('bundle-1').then(function(m) { + ok(m.defined == true); + start(); + }, err); + + stop(); + System['import']('bundle-2').then(function(m) { + ok(m.defined == true); + start(); + }, err); +}); + +asyncTest('Loading an AMD named define', function() { + System['import']('tests/nameddefine.js').then(function(m1) { + ok(m1.converter, 'Showdown not loaded'); + System['import']('another-define').then(function(m2) { + ok(m2.named === 'define', 'Another module is not defined'); + start(); + }, err); + }, err); +}); + +asyncTest('Loading an AMD bundle with an anonymous define', function() { + System['import']('tests/anon-named.js').then(function(m) { + ok(m.anon == true); + start(); + }, err); +}); + +asyncTest('Loading an AMD bundle with multiple anonymous defines', function() { + System['import']('tests/multiple-anonymous.js').then(function(m) { + ok(false); + start(); + }, function(e) { + ok(e.toString().indexOf('Multiple anonymous') != -1) + start(); + }); +}) + +asyncTest('Loading AMD CommonJS form', function() { + System['import']('tests/amd-cjs-module.js').then(function(m) { + ok(m.test == 'hi', 'Not defined'); + start(); + }, err); +}); + +asyncTest('AMD contextual require toUrl', function() { + System['import']('tests/amd-contextual.js').then(function(m) { + ok(m.name == System.baseURL + 'tests/amd-contextual.js'); + ok(m.rel == System.baseURL + 'rel-path.js'); + start(); + }, err); +}); + +// TODO: fix! +/* asyncTest('AMD race condition test', function() { + System.config({ + bundles: { + "tests/out.js": ["tests/lib/modB.js"] + } + }); + + var completed = 0; + function completeImport() { + if (++completed == 3) { + ok(true); + start(); + } + } + + System.import('tests/modA.js').then(completeImport, err); + setTimeout(function () { + System.import('tests/modC.js').then(completeImport, err); + System.import('tests/lib/modB.js').then(completeImport, err); + }, 10); +}); */ + +asyncTest('Loading a CommonJS module', function() { + System['import']('tests/common-js-module.js').then(function(m) { + ok(m.hello == 'world', 'module value not defined'); + ok(m.first == 'this is a dep', 'dep value not defined'); + start(); + }, err); +}); + +asyncTest('Loading a CommonJS module with this', function() { + System['import']('tests/cjs-this.js').then(function(m) { + ok(m.asdf == 'module value'); + start(); + }, err); +}); + +asyncTest('CommonJS setting module.exports', function() { + System['import']('tests/cjs-exports.js').then(function(m) { + ok(m.e == 'export'); + start(); + }, err); +}); + +asyncTest('CommonJS detection variation 1', function() { + System['import']('tests/commonjs-variation.js').then(function(m) { + ok(m.e === System.get('@empty')); + start(); + }, err); +}); + +if (!ie8) +asyncTest('CommonJS detection variation 2', function() { + System['import']('tests/commonjs-variation2.js').then(function(m) { + ok(typeof m.OpaqueToken === 'function'); + start(); + }, err); +}); + +asyncTest('CommonJS detection test with byte order mark (BOM)', function() { + System['import']('tests/cjs-exports-bom.js').then(function(m) { + ok(m.foo == 'bar'); + start(); + }, err); +}); + +asyncTest('CommonJS module detection test with byte order mark (BOM)', function() { + System['import']('tests/cjs-module-bom.js').then(function(m) { + ok(m.foo == 'bar'); + start(); + }, err); +}); + +asyncTest('CommonJS require variations', function() { + System['import']('tests/commonjs-requires.js').then(function(m) { + ok(m.d1 == 'd'); + ok(m.d2 == 'd'); + ok(m.d3 == "require('not a dep')"); + ok(m.d4 == "text/* require('still not a dep') text"); + ok(m.d5 == 'text \'quote\' require("yet still not a dep")'); + ok(m.d6 == 'd6'); + ok(m.d7 == 'export'); + start(); + }, err); +}); + +asyncTest('CommonJS globals', function() { + System.config({ + meta: { + 'tests/commonjs-globals.js': { + globals: { + process: './cjs-process.js' + } + } + } + }); + System['import']('tests/commonjs-globals.js').then(function(m) { + ok(m.process.env.NODE_ENV) + start(); + }, err); +}); + +asyncTest('CommonJS require.resolve', function() { + System['import']('tests/cjs-resolve.js').then(function(m) { + ok(m.substr(m.length - 12, 12) == 'test/tests/a'); + start(); + }, err); +}) + +asyncTest('Loading a UMD module', function() { + System['import']('tests/umd.js').then(function(m) { + ok(m.d == 'hi', 'module value not defined'); + start(); + }, err); +}); + +asyncTest('Loading AMD with format hint', function() { + System['import']('tests/amd-format.js').then(function(m) { + ok(m.amd == 'amd', 'AMD not loaded'); + start(); + }, err); +}); + +asyncTest('Loading CJS with format hint', function() { + System['import']('tests/cjs-format.js').then(function(m) { + ok(m.cjs == 'cjs', 'CJS not loaded'); + start(); + }, err); +}); + +asyncTest('CommonJS globals', function() { + System['import']('tests/cjs-globals.js').then(function(m) { + ok(m.filename.match(/tests\/cjs-globals\.js$/)); + ok(m.dirname.match(/\/tests$/)); + ok(m.global == global); + start(); + }, err); +}); + +asyncTest('Versions', function() { + System['import']('tests/zero@0.js').then(function(m) { + ok(m == '0'); + start() + }, err); +}); + +asyncTest('Loading a module with # in the name', function() { + System['import']('tests/#.js').then(function(m) { + ok(m == '#'); + start(); + }, err); +}); + +asyncTest('Simple compiler Plugin', function() { + System.map['coffee'] = 'tests/compiler-plugin.js'; + System['import']('tests/compiler-test.coffee!').then(function(m) { + ok(m.output == 'plugin output', 'Plugin not working.'); + ok(m.extra == 'yay!', 'Compiler not working.'); + start(); + }, err); +}); + +asyncTest('Mapping a plugin argument', function() { + System.map['bootstrap'] = 'tests/bootstrap@3.1.1'; + System.map['coffee'] = 'tests/compiler-plugin.js'; + System['import']('bootstrap/test.coffee!coffee').then(function(m) { + ok(m.extra == 'yay!', 'not working'); + start(); + }, err); +}); + +asyncTest('Using pluginFirst config', function() { + System.pluginFirst = true; + System.map['bootstrap'] = 'tests/bootstrap@3.1.1'; + System.map['coffee'] = 'tests/compiler-plugin.js'; + System['import']('coffee!bootstrap/test.coffee').then(function(m) { + ok(m.extra == 'yay!', 'not working'); + System.pluginFirst = false; + start(); + }, err); +}); + +asyncTest('Advanced compiler plugin', function() { + System['import']('tests/compiler-test.js!tests/advanced-plugin.js').then(function(m) { + ok(m == 'custom fetch:' + System.baseURL + 'tests/compiler-test.js!' + System.baseURL + 'tests/advanced-plugin.js', m); + start(); + }, err); +}); + +asyncTest('Plugin as a dependency', function() { + System.map['css'] = 'tests/css.js'; + System['import']('tests/cjs-loading-plugin.js').then(function(m) { + ok(m.pluginSource == 'this is css'); + start(); + }, err); +}); + +asyncTest('AMD Circular', function() { + System['import']('tests/amd-circular1.js').then(function(m) { + ok(m.outFunc() == 5, 'Expected execution'); + start(); + })['catch'](err); +}); + +asyncTest('CJS Circular', function() { + System['import']('tests/cjs-circular1.js').then(function(m) { + ok(m.first == 'second value'); + ok(m.firstWas == 'first value', 'Original value'); + start(); + }, err); +}); + +asyncTest('System.register Circular', function() { + System.config({ + meta: { + 'tests/register-circular1.js': { + scriptLoad: true + } + } + }); + System['import']('tests/register-circular1.js').then(function(m) { + ok(m.q == 3, 'Binding not allocated'); + ok(m.r == 5, 'Binding not updated'); + start(); + }, err); +}); + +asyncTest('System.register regex test', function() { + System['import']('tests/register-regex.js').then(function(m) { + ok(m); + start(); + }, err); +}); + +asyncTest('System.register regex test 2', function() { + System['import']('tests/register-regex-2.js').then(function(m) { + ok(m); + start(); + }, err); +}); + +asyncTest('System.register module name arg', function() { + System['import']('tests/module-name.js').then(function(m) { + ok(m.name == System.baseURL + 'tests/module-name.js'); + start(); + }, err); +}); + +asyncTest('System.register group linking test', function() { + System.config({ + bundles: { + 'tests/group-test.js': ['group-a'] + } + }); + System['import']('group-a').then(function(m) { + ok(m); + start(); + }, err); +}); + +System.config({ + bundles: { + 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first'] + } +}); + +asyncTest('Loading AMD from a bundle', function() { + System['import']('tree/amd').then(function(m) { + ok(m.is == 'amd'); + start(); + }, err); +}); + +asyncTest('Loading CommonJS from a bundle', function() { + System['import']('tree/cjs').then(function(m) { + ok(m.cjs === true); + start(); + }, err); +}); + +asyncTest('Loading a Global from a bundle', function() { + System['import']('tree/global').then(function(m) { + ok(m === 'output'); + start(); + }, err); +}); + +asyncTest('Loading named System.register', function() { + System['import']('tree/third').then(function(m) { + ok(m.some == 'exports'); + start(); + }, err); +}); +asyncTest('Loading System.register from ES6', function() { + System.config({ + meta: { + 'tree/first': { + format: 'esm' + } + } + }); + System['import']('tree/first').then(function(m) { + ok(m.p == 5); + start(); + }, err); +}); + +asyncTest('AMD simplified CommonJS wrapping with an aliased require', function() { + System['import']('tests/amd-simplified-cjs-aliased-require1.js').then(function(m) { + ok(m.require2,"got dependency from aliased require"); + ok(m.require2.amdCJS,"got dependency from aliased require listed as a dependency"); + start(); + }, err); +}); + +asyncTest('Loading dynamic modules with __esModule flag set', function() { + System['import']('tests/es-module-flag.js').then(function() { + m = System.get(System.normalizeSync('tests/es-module-flag.js')); + ok(m.exportName == 'export'); + ok(m['default'] == 'default export'); + ok(m.__esModule === true); + start(); + }, err); +}); + +if (!ie8) { +asyncTest('ES6 named export loading of CJS', function() { + System['import']('tests/es-named-import-cjs.js').then(function(m) { + ok(m.cjsFuncValue === 'named export'); + start(); + }); +}); + +// TypeScript does not support async functions yet +if (System.transpiler !== 'typescript') +asyncTest('Async functions', function() { + System.babelOptions = { stage: 0 }; + System.traceurOptions = { asyncFunctions: true }; + System['import']('tests/async.js').then(function(m) { + ok(true); + start(); + }); +}); + +if (System.transpiler !== 'typescript') +asyncTest('Wrapper module support', function() { + System['import']('tests/wrapper.js').then(function(m) { + ok(m.d == 'default1', 'Wrapper module not defined.'); + start(); + }, err); +}); + +asyncTest('ES6 plugin', function() { + System['import']('tests/blah.js!tests/es6-plugin.js').then(function(m) { + ok(m == 'plugin'); + start(); + }, err); +}); + +asyncTest('ES6 detection', function() { + System['import']('tests/es6-detection1.js').then(function(m) { + ok(true); + start(); + }, err); +}); + +asyncTest('Basic exporting & importing', function() { + var m1, m2, m3, m4, err; + var checkComplete = function() { + if (m1 && m2 && m3 && m4 && err) { + ok(m1['default'] == 'default1', 'Error defining default 1'); + ok(m2['default'] == 'default2', 'Error defining default 2'); + ok(m3['default'] == 'default3', 'Error defining default 3'); + ok(m4.test == 'default3', 'Error defining module'); + start(); + } + }; + System['import']('tests/default1.js').then(function(_m1) { + if (m1 === undefined) + m1 = null; + else + m1 = _m1; + checkComplete(); + })['catch'](err); + System['import']('tests/default1.js').then(function(_m1) { + if (m1 === undefined) + m1 = null; + else + m1 = _m1; + checkComplete(); + })['catch'](err); + System['import']('tests/default2.js').then(function(_m2) { + m2 = _m2; + checkComplete(); + })['catch'](err); + System['import']('tests/asdf.js').then(function() { + }, function(_err) { + err = _err; + checkComplete(); + })['catch'](err); + System['import']('tests/default3.js').then(function(_m3) { + m3 = _m3; + checkComplete(); + })['catch'](err); + System['import']('tests/module.js').then(function(_m4) { + m4 = _m4; + checkComplete(); + })['catch'](err); +}); + +asyncTest('Export Star', function(assert) { + System['import']('tests/export-star.js').then(function(m) { + ok(m.foo == 'foo'); + ok(m.bar == 'bar'); + start(); + }, err); +}); + +asyncTest('Importing a mapped loaded module', function() { + System.map['default1'] = 'tests/default1.js'; + System['import']('default1').then(function(m) { + System['import']('default1').then(function(m) { + ok(m, 'no module'); + start(); + }, err); + }, err); +}); + +asyncTest('Loading empty ES6', function() { + System['import']('tests/empty-es6.js').then(function(m) { + ok(m && emptyES6); + start(); + }, err); +}) + +asyncTest('Loading ES6 with format hint', function() { + System['import']('tests/es6-format.js').then(function(m) { + expect(0); + start(); + }, err); +}); + +asyncTest('Loading ES6 loading AMD', function() { + System['import']('tests/es6-loading-amd.js').then(function(m) { + ok(m.amd == true); + start(); + }) +}); + +asyncTest('Loading AMD with import *', function() { + System['import']('tests/es6-import-star-amd.js').then(function(m) { + ok(m.g == true); + start(); + }, err); +}); + +asyncTest('Loading ES6 and AMD', function() { + System['import']('tests/es6-and-amd.js').then(function(m) { + ok(m.amd_module == 'AMD Module'); + ok(m.es6_module == 'ES6 Module'); + start(); + }, err); +}); + +asyncTest('ES module deps support', function() { + System.config({ + meta: { + 'tests/esm-with-deps.js': { + deps: ['tests/esm-dep.js'] + } + } + }); + System['import']('tests/esm-with-deps.js').then(function(m) { + ok(m.p == 5); + ok(global.esmDep == 'esm-dep'); + start(); + }); +}); + +asyncTest('Module Name meta', function() { + System['import']('tests/reflection.js').then(function(m) { + ok(m.myname == System.normalizeSync('tests/reflection.js'), 'Module name not returned'); + start(); + }, err); +}); + +asyncTest('Relative dyanamic loading', function() { + System['import']('tests/reldynamic.js').then(function(m) { + return m.dynamicLoad(); + }) + .then(function(m) { + ok(m.dynamic == 'module', 'Dynamic load failed'); + start(); + }) + ['catch'](err); +}); + +asyncTest('ES6 Circular', function() { + System['import']('tests/es6-circular1.js').then(function(m) { + ok(m.q == 3, 'Binding not allocated'); + if (System.transpiler != '6to5') ok(m.r == 3, 'Binding not updated'); + start(); + }, err); +}); + +asyncTest('AMD & CJS circular, ES6 Circular', function() { + System['import']('tests/all-circular1.js').then(function(m) { + if (System.transpiler != '6to5') ok(m.q == 4); + ok(m.o.checkObj() == 'changed'); + start(); + }, err); +}); + +asyncTest('AMD -> System.register circular -> ES6', function() { + System['import']('tests/all-layers1.js').then(function(m) { + ok(m == true) + start(); + }, err); +}); + +asyncTest('Metadata dependencies work for named defines', function() { + System['import']('tests/meta-deps.js').then(function(m) { + return System['import']('b'); + }).then(function(m) { + ok(m.a === 'a'); + start(); + }); +}); + +asyncTest('Loading an AMD module that requires another works', function() { + expect(0); + System['import']('tests/amd-require.js').then(function(){ + // Just getting this far means it is working. + start(); + }); +}); + +asyncTest('Loading a connected tree that connects ES and CJS modules', function(){ + System['import']('tests/connected-tree/a.js').then(function(a){ + ok(a.name === "a"); + start(); + }); +}); + +asyncTest('Loading two bundles that have a shared dependency', function() { + System.config({ + bundles: { + "tests/shared-dep-bundles/a.js": ["lib/shared-dep", "lib/a"], + "tests/shared-dep-bundles/b.js": ["lib/shared-dep", "lib/b"] + } + }); + expect(0); + System['import']('lib/a').then(function() { + System['import']('lib/b').then(function() { + //If it gets here it's fine + start(); + }, err); + }, err); +}); +} + +asyncTest("System clone", function() { + var clonedSystem = new System.constructor(); + + clonedSystem.baseURL = System.baseURL; + + System.map['maptest'] = 'tests/map-test.js'; + clonedSystem.map['maptest'] = 'tests/map-test-dep.js'; + + Promise.all([System['import']('maptest'), clonedSystem['import']('maptest')]).then(function(modules) { + var m = modules[0]; + var mClone = modules[1]; + + ok(m.maptest == 'maptest', 'Mapped module not loaded'); + ok(mClone.dep == 'maptest', 'Mapped module not loaded'); + ok(mClone !== m, "different modules"); + + start(); + }, err); +}); + +asyncTest('Custom loader instance System scoped', function() { + var customSystem = new System.constructor(); + + customSystem.baseURL = System.baseURL; + customSystem.paths = System.paths; + customSystem.transpiler = System.transpiler; + customSystem['import']('tests/loader-scoping.js') + .then(function(m) { + ok(m.loader == customSystem); + start(); + }, err);; +}); + +if(typeof window !== 'undefined' && window.Worker) { + asyncTest('Using SystemJS in a Web Worker', function() { + var worker = new Worker('./tests/worker-' + System.transpiler + '.js'); + worker.onmessage = function(e) { + ok(e.data.amd === 'AMD Module'); + ok(e.data.es6 === 'ES6 Module'); + start(); + }; + }); +} + +asyncTest("Duplicate entries", function() { + System["import"]('tests/duplicateDeps/m1.js').then(function(m) { + var r = m.foo() + ":" + m.f3(); + ok(r === "3:3", "duplicate entries in dependency list not handled correctly"); + start(); + }) +}); + +// new features!! +if (!ie8) +asyncTest('Named imports for non-es6', function() { + System['import']('tests/es6-cjs-named-export.js').then(function(m) { + ok(m.someExport == 'asdf'); + start(); + }, err); +}); + +asyncTest('Globals', function() { + System.config({ + meta: { + 'tests/with-global-deps.js': { + globals: { + '$$$': 'tests/dep.js' + } + } + } + }); + System['import']('tests/with-global-deps.js').then(function(m) { + for (var p in m) + ok(false); + ok(!global.$$$); + start(); + }, err); +}); + +asyncTest('Scriptload precompiled global with exports still defined', function() { + System.config({ + meta: { + 'tests/global-single-compiled.js': { + scriptLoad: true, + exports: 'foobar', + format: typeof global != 'undefined' ? 'register' : 'global' + } + } + }); + System['import']('tests/global-single-compiled.js').then(function(m) { + ok(m == 'foo'); + start(); + }, err); +}); + +asyncTest('Multi-format deps meta', function() { + System['import']('tests/amd-extra-deps.js').then(function(m) { + ok(m.join(',') == '10,5'); + start(); + }, err); +}); + + +asyncTest('Wildcard meta', function() { + System.config({ + meta: { + 'tests/cs/main.js': { + deps: ['./dep.js'] + }, + 'tests/cs/*': { + loader: 'tests/cs-loader.js' + } + } + }); + System['import']('tests/cs/main.js').then(function(m) { + ok(m == 'cs'); + start(); + }); +}); + +asyncTest('Package configuration CommonJS config example', function() { + System.config({ + map: { + 'global-test': 'tests/testpkg/test.ts' + }, + //packageConfigPaths: ['tests/testpk*.json'], + packageConfigPaths: ['tests/testpkg/system.json'], + packages: { + 'tests/testpkg': { + main: './noext', + map: { + "testpkg": "." + }, + asdf: 'asdf' + } + } + }); + + Promise.all([ + System['import']('tests/testpkg'), + System['import']('tests/testpkg/json'), + System['import']('tests/testpkg/dir/test'), + System['import']('tests/testpkg/dir2'), + System['import']('tests/testpkg/dir/'), + System['import']('tests/testpkg/env-module'), + System['import']('tests/testpkg/self'), + System['import']('tests/testpkg/conditional1'), + System['import']('tests/testpkg/conditional2'), + System['import']('tests/testpkg/self-load.js'), + System['import']('tests/testpkg/dir/self-load.js') + ]).then(function(m) { + ok(m[0].prop == 'value'); + ok(m[1].prop == 'value'); + ok(m[2] == 'ts'); + ok(m[3].json == 'index'); + ok(m[4] == 'dirindex'); + ok(m[5] == (typeof window != 'undefined' ? 'browser' : 'not browser')); + ok(m[6].prop == 'value'); + ok(m[7] == 'interpolated!'); + ok(m[8] == 'interpolated!'); + ok(m[9].a.prop == 'value' && m[9].b.prop == 'value'); + ok(m[10].a.prop == 'value' && m[10].b.prop == 'value'); + ok(global.depCacheTest == 'passed'); + start(); + }, err); +}); + +asyncTest('Package edge cases', function() { + + var clonedSystem = new System.constructor(); + + var pkgCfg = { defaultExtension: 'asdf' }; + + try { + clonedSystem.config({ + packages: { + '//': pkgCfg + } + }); + ok(false); + } + catch(e) { + ok(e.toString().indexOf('not a valid package name') != -1); + } + + try { + clonedSystem.config({ + packages: { + 'https://': pkgCfg + } + }); + ok(false); + } + catch(e) { + ok(e.toString().indexOf('not a valid package name') != -1); + } + + clonedSystem.config({ + packages: { + 'https://cdn.jquery.com': pkgCfg, + '//cdn.jquery.com': pkgCfg + } + }); + + clonedSystem.config({ + packages: { + // both equivalent: + '.': pkgCfg, + './': pkgCfg, + + '/': pkgCfg, + + // this is now a nested package + // but our trailling / should avoid extension rules + // both equivalent: + '../': pkgCfg, + '..': pkgCfg + } + }); + + // ensure trailing "/" is equivalent to "tests/testpkg" + clonedSystem.config({ + packageConfigPaths: ['tests/*.json'], + packages: { + 'tests/testpkg2/': { + defaultExtension: 'js' + } + } + }); + + // we now have nested packages: + // testpkg/ within test/ within / root:// + // we're testing that we always select the rules of the inner package + clonedSystem['import']('tests/testpkg2/').then(function(m) { + ok(m.asdf == 'asdf'); + start(); + }, err); +}); + +asyncTest('Package map circular cases', function() { + System.config({ + map: { + tp3: 'tests/testpkg3' + }, + packages: { + 'tests/testpkg3': { + map: { + './lib': './lib/asdf.js', + './lib/': './lib/index.js', + './lib/p': './lib/q.js', + './src/': './src/index.js', + './bin': './bin/index.js' + } + } + } + }); + + Promise.all([ + System.normalize('tp3/lib'), + System.normalize('tp3/lib/'), + System.normalize('tp3/lib/q'), + System.normalize('tp3/lib/p'), + + System.normalize('../lib', System.baseURL + 'tests/testpkg3/asdf/x.js'), + System.normalize('../lib/', System.baseURL + 'tests/testpkg3/asdf/x.js'), + System.normalize('../lib/x', System.baseURL + 'tests/testpkg3/asdf/x.js'), + + System.normalize('.', System.baseURL + 'tests/testpkg3/lib/a'), + System.normalize('./', System.baseURL + 'tests/testpkg3/lib/x'), + System.normalize('./p', System.baseURL + 'tests/testpkg3/lib/x'), + System.normalize('./q', System.baseURL + 'tests/testpkg3/lib/x'), + + System.normalize('./lib', System.baseURL + 'tests/testpkg3/x.js'), + System.normalize('./lib/', System.baseURL + 'tests/testpkg3/x.js'), + System.normalize('./lib/p', System.baseURL + 'tests/testpkg3/x.js'), + System.normalize('./lib/q', System.baseURL + 'tests/testpkg3/x.js'), + + System.normalize('../lib/', System.baseURL + 'tests/testpkg3/lib/x.js'), + System.normalize('../lib/x', System.baseURL + 'tests/testpkg3/lib/x.js'), + System.normalize('tp3/lib/q', System.baseURL + 'tests/testpkg3/lib/x.js'), + + System.normalize('./src', System.baseURL + 'tests/testpkg3/'), + System.normalize('./src/', System.baseURL + 'tests/testpkg3/'), + System.normalize('./src/x', System.baseURL + 'tests/testpkg3/'), + + System.normalize('tp3/src'), + System.normalize('tp3/src/'), + System.normalize('tp3/src/x'), + + System.normalize('./bin', System.baseURL + 'tests/testpkg3/'), + System.normalize('./bin/', System.baseURL + 'tests/testpkg3/'), + System.normalize('./bin/x', System.baseURL + 'tests/testpkg3/'), + + System.normalize('tp3/bin'), + System.normalize('tp3/bin/'), + System.normalize('tp3/bin/x'), + + System.normalize('.', System.baseURL + 'tests/testpkg3/bin/x') + ]) + .then(function(n) { + ok(n[0] == System.baseURL + 'tests/testpkg3/lib/asdf.js'); + ok(n[1] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[2] == System.baseURL + 'tests/testpkg3/lib/q.js'); + ok(n[3] == System.baseURL + 'tests/testpkg3/lib/q.js'); + + ok(n[4] == System.baseURL + 'tests/testpkg3/lib/asdf.js'); + ok(n[5] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[6] == System.baseURL + 'tests/testpkg3/lib/x.js'); + + ok(n[7] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[8] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[9] == System.baseURL + 'tests/testpkg3/lib/q.js'); + ok(n[10] == System.baseURL + 'tests/testpkg3/lib/q.js'); + + ok(n[11] == System.baseURL + 'tests/testpkg3/lib/asdf.js'); + ok(n[12] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[13] == System.baseURL + 'tests/testpkg3/lib/q.js'); + ok(n[14] == System.baseURL + 'tests/testpkg3/lib/q.js'); + + ok(n[15] == System.baseURL + 'tests/testpkg3/lib/index.js'); + ok(n[16] == System.baseURL + 'tests/testpkg3/lib/x.js'); + ok(n[17] == System.baseURL + 'tests/testpkg3/lib/q.js'); + + ok(n[18] == System.baseURL + 'tests/testpkg3/src.js'); + ok(n[19] == System.baseURL + 'tests/testpkg3/src/index.js'); + ok(n[20] == System.baseURL + 'tests/testpkg3/src/x.js'); + + ok(n[21] == System.baseURL + 'tests/testpkg3/src.js'); + ok(n[22] == System.baseURL + 'tests/testpkg3/src/index.js'); + ok(n[23] == System.baseURL + 'tests/testpkg3/src/x.js'); + + ok(n[24] == System.baseURL + 'tests/testpkg3/bin/index.js'); + ok(n[25] == System.baseURL + 'tests/testpkg3/bin/index.js'); + ok(n[26] == System.baseURL + 'tests/testpkg3/bin/x.js'); + + ok(n[27] == System.baseURL + 'tests/testpkg3/bin/index.js'); + ok(n[28] == System.baseURL + 'tests/testpkg3/bin/index.js'); + ok(n[29] == System.baseURL + 'tests/testpkg3/bin/x.js'); + + ok(n[30] == System.baseURL + 'tests/testpkg3/bin/index.js'); + start(); + }, err); + +}); + +if (!ie8) +asyncTest('Conditional loading', function() { + System.set('env', System.newModule({ 'browser': 'ie' })); + + System['import']('tests/branch-#{env|browser}.js').then(function(m) { + ok(m.branch == 'ie'); + start(); + }, err); +}); + +asyncTest('Boolean conditional false', function() { + System.set('env', System.newModule({ 'js': { 'es5': true } })); + + System['import']('tests/branch-boolean.js#?~env|js.es5').then(function(m) { + ok(m === System.get('@empty')); + start(); + }, err); +}); + +if (!ie8) +asyncTest('Boolean conditional true', function() { + System.set('env', System.newModule({ 'js': { 'es5': true } })); + + System.config({ + paths: { + 'branch-boolean.js': 'tests/branch-boolean.js' + } + }); + + System['import']('branch-boolean.js#?env|js.es5').then(function(m) { + ok(m['default'] === true); + start(); + }, err); +}); + +asyncTest('Loading a System.registerdynamic module (not bundled)', function() { + System['import']('tests/registerdynamic-main.js').then(function(m) { + ok(typeof m.dependency === 'function'); + ok(m.dependency() === 'ok'); + start(); + }).then(null, err); +}); + +asyncTest('Importing a script with wrong integrity fails', function() { + System.config({ + meta: { + 'tests/csp/integrity.js': { + format: 'amd', + integrity: 'sha256-abc' + } + } + }); + System['import']('tests/csp/integrity.js').then(function(m) { + ok(m.integrity == 'integrity'); + start(); + }, function(e) { + ok(typeof e !== 'undefined'); + console.log('SRI not supported in this browser'); + start(); + }); +}); + +if (typeof process != 'undefined') { + asyncTest('Loading Node core modules', function() { + System['import']('@node/fs').then(function(m) { + ok(m.writeFile); + start(); + }); + }); + + + asyncTest('No global define leak in Node', function() { + ok(typeof define == 'undefined'); + start(); + }); +} + +asyncTest('Package-local alias esm', function() { + System.config({ + map: { + 'package-local-alias-esm': 'tests/package-local-alias' + }, + packages: { + 'package-local-alias-esm': { + main: 'index-esm.js', + format: 'esm', + meta: { + './local-esm': {alias: './local/index-esm.js'} + } + } + } + }); + System['import']('package-local-alias-esm').then(function(m) { + ok(m.q == 'q'); + ok(m.fromLocal == 'x'); + start(); + }); +}); + +asyncTest('Package-local alias cjs', function() { + System.config({ + map: { + 'package-local-alias-cjs': 'tests/package-local-alias' + }, + packages: { + 'package-local-alias-cjs': { + main: 'index-cjs.js', + format: 'cjs', + meta: { + './local-cjs': {alias: './local/index-cjs.js'} + } + } + } + }); + System['import']('package-local-alias-cjs').then(function(m) { + ok(m.q == 'q'); + ok(m.fromLocal == 'x'); + start(); + }); +}); + +asyncTest('Package-local alias esm default export', function() { + System.config({ + map: { + 'package-local-alias-default-esm': 'tests/package-local-alias' + }, + packages: { + 'package-local-alias-default-esm': { // can't reuse package names from previous test + main: 'index-default-esm.js', // because System.config() results persist across tests + format: 'esm', + meta: { + './local-default-esm': {alias: './local/index-default-esm.js'} + } + } + } + }); + System['import']('package-local-alias-default-esm').then(function(m) { + ok(m.q == 'q'); + ok(m.fromLocal == 'x'); + ok(m.fromLocalDirect == 'x'); + start(); + }); +}); + +asyncTest('Package-local alias cjs default export', function() { + System.config({ + map: { + 'package-local-alias-default-cjs': 'tests/package-local-alias' + }, + packages: { + 'package-local-alias-default-cjs': { + main: 'index-default-cjs.js', + format: 'cjs', + meta: { + './local-default-cjs': {alias: './local/index-default-cjs.js'} + } + } + } + }); + System['import']('package-local-alias-default-cjs').then(function(m) { + ok(m.q == 'q'); + ok(m.fromLocal == 'x'); + ok(m.fromLocalDirect == 'x'); + start(); + }); +}); + + +})(typeof window == 'undefined' ? global : window); diff --git a/test/tests/#.js b/test/tests/#.js new file mode 100644 index 000000000..0cf86a864 --- /dev/null +++ b/test/tests/#.js @@ -0,0 +1 @@ +module.exports = '#';
\ No newline at end of file diff --git a/test/tests/advanced-plugin.js b/test/tests/advanced-plugin.js new file mode 100644 index 000000000..26c6a450c --- /dev/null +++ b/test/tests/advanced-plugin.js @@ -0,0 +1,20 @@ + +exports.locate = function(load) { + return new Promise(function(resolve, reject) { + setTimeout(function() { + resolve('custom fetch'); + }, 20); + }); +} + +exports.fetch = function(load) { + return new Promise(function(resolve, reject) { + setTimeout(function() { + resolve(load.address); + }, 20); + }); +} + +exports.translate = function(load) { + load.source = '"deps ./plugin-dep.js"; (typeof window != "undefined" ? window : global).q = "' + load.source + ':' + load.name + '";'; +}
\ No newline at end of file diff --git a/test/tests/all-circular1.js b/test/tests/all-circular1.js new file mode 100644 index 000000000..131dfecce --- /dev/null +++ b/test/tests/all-circular1.js @@ -0,0 +1,9 @@ +import { a } from './all-circular2.js'; +export var q; +export function p() { + q = a; +} + +import o from './all-circular3.js'; + +export { o };
\ No newline at end of file diff --git a/test/tests/all-circular2.js b/test/tests/all-circular2.js new file mode 100644 index 000000000..c88eceb9c --- /dev/null +++ b/test/tests/all-circular2.js @@ -0,0 +1,3 @@ +import { p } from './all-circular1.js'; +export var a = 4; +p();
\ No newline at end of file diff --git a/test/tests/all-circular3.js b/test/tests/all-circular3.js new file mode 100644 index 000000000..fea5e3f22 --- /dev/null +++ b/test/tests/all-circular3.js @@ -0,0 +1,10 @@ +define(function(require, exports) { + var obj = require('./all-circular4.js').obj; + exports.checkObj = function() { + return obj.circular; + } + exports.setObj = function() { + obj.circular = 'changed'; + } + require('./all-circular4.js').set(); +});
\ No newline at end of file diff --git a/test/tests/all-circular4.js b/test/tests/all-circular4.js new file mode 100644 index 000000000..692445730 --- /dev/null +++ b/test/tests/all-circular4.js @@ -0,0 +1,5 @@ +exports.obj = { circular: 'mess' }; +var setter = require('./all-circular3.js'); +exports.set = function() { + setter.setObj(); +} diff --git a/test/tests/all-layers1.js b/test/tests/all-layers1.js new file mode 100644 index 000000000..2dea20d17 --- /dev/null +++ b/test/tests/all-layers1.js @@ -0,0 +1,3 @@ +define(['./all-layers2.js'], function(al2) { + return al2.q == 10 && al2.r == 5; +});
\ No newline at end of file diff --git a/test/tests/all-layers2.js b/test/tests/all-layers2.js new file mode 100644 index 000000000..a4a72e128 --- /dev/null +++ b/test/tests/all-layers2.js @@ -0,0 +1,20 @@ +System.register(["./all-layers3.js"], function($__export) { + "use strict"; + var q, r, c; + function p() { + if (q) + r = $__export('r', c); + else + q = $__export('q', c); + } + $__export('p', p); + return { + setters: [function(m) { + c = m.c; + }], + execute: function() { + c = 5; + p(); + } + }; +}); diff --git a/test/tests/all-layers3.js b/test/tests/all-layers3.js new file mode 100644 index 000000000..ac519f19a --- /dev/null +++ b/test/tests/all-layers3.js @@ -0,0 +1,17 @@ +System.register(["./all-layers2.js", "./all-layers4.js"], function($__export) { + "use strict"; + var c, p; + return { + setters: [ + function(m) { + p = m.p; + }, + function(m) { + $__export('c', c = m.c); + } + ], + execute: function() { + p(); + } + }; +}); diff --git a/test/tests/all-layers4.js b/test/tests/all-layers4.js new file mode 100644 index 000000000..4a2d7bf8a --- /dev/null +++ b/test/tests/all-layers4.js @@ -0,0 +1 @@ +export var c = 10;
\ No newline at end of file diff --git a/test/tests/amd-bundle.js b/test/tests/amd-bundle.js new file mode 100644 index 000000000..8856e2db9 --- /dev/null +++ b/test/tests/amd-bundle.js @@ -0,0 +1,6 @@ +define('bundle-1', function() { + return { defined: true }; +}); +define('bundle-2', function() { + return { defined: true }; +});
\ No newline at end of file diff --git a/test/tests/amd-circular1.js b/test/tests/amd-circular1.js new file mode 100644 index 000000000..2533e9bfd --- /dev/null +++ b/test/tests/amd-circular1.js @@ -0,0 +1,7 @@ +define(function(require, exports) { + var depFunc = require('./amd-circular2.js').fn; + exports.val = 5; + exports.outFunc = function() { + return depFunc(); + } +});
\ No newline at end of file diff --git a/test/tests/amd-circular2.js b/test/tests/amd-circular2.js new file mode 100644 index 000000000..df9254d24 --- /dev/null +++ b/test/tests/amd-circular2.js @@ -0,0 +1,6 @@ +define(function(require, exports) { + var circular1 = require('./amd-circular1.js'); + exports.fn = function() { + return circular1.val; + } +});
\ No newline at end of file diff --git a/test/tests/amd-cjs-module.js b/test/tests/amd-cjs-module.js new file mode 100644 index 000000000..1ac2c3e1a --- /dev/null +++ b/test/tests/amd-cjs-module.js @@ -0,0 +1,4 @@ +define(function(require, exports) { + var p = require('./amd-dep.js'); + exports.test = 'hi'; +});
\ No newline at end of file diff --git a/test/tests/amd-contextual.js b/test/tests/amd-contextual.js new file mode 100644 index 000000000..b5e886297 --- /dev/null +++ b/test/tests/amd-contextual.js @@ -0,0 +1,6 @@ +define(['require', 'module'], function(require, module) { + return { + name: module.uri, + rel: require.toUrl('../rel-path.js') + }; +});
\ No newline at end of file diff --git a/test/tests/amd-dep-A.js b/test/tests/amd-dep-A.js new file mode 100644 index 000000000..c047cc49f --- /dev/null +++ b/test/tests/amd-dep-A.js @@ -0,0 +1 @@ +A = 10;
\ No newline at end of file diff --git a/test/tests/amd-dep-B.js b/test/tests/amd-dep-B.js new file mode 100644 index 000000000..6f5b4c6b0 --- /dev/null +++ b/test/tests/amd-dep-B.js @@ -0,0 +1 @@ +B = 5;
\ No newline at end of file diff --git a/test/tests/amd-dep.js b/test/tests/amd-dep.js new file mode 100644 index 000000000..4ad8f7e5c --- /dev/null +++ b/test/tests/amd-dep.js @@ -0,0 +1,3 @@ +define({ + amd: 'dep' +});
\ No newline at end of file diff --git a/test/tests/amd-dynamic-require.js b/test/tests/amd-dynamic-require.js new file mode 100644 index 000000000..6b7315dc3 --- /dev/null +++ b/test/tests/amd-dynamic-require.js @@ -0,0 +1,19 @@ +define(['require'], function(require) { + var cb, module; + + require('./amd-dynamic.js', function(_module) { + module = _module; + + if (cb) + cb(module); + }); + + return { + onCallback: function(_cb) { + if (module) + _cb(module); + else + cb = _cb; + } + }; +});
\ No newline at end of file diff --git a/test/tests/amd-dynamic.js b/test/tests/amd-dynamic.js new file mode 100644 index 000000000..88692ae46 --- /dev/null +++ b/test/tests/amd-dynamic.js @@ -0,0 +1,3 @@ +define(function() { + return 'dynamic'; +});
\ No newline at end of file diff --git a/test/tests/amd-extra-deps.js b/test/tests/amd-extra-deps.js new file mode 100644 index 000000000..86b8777ff --- /dev/null +++ b/test/tests/amd-extra-deps.js @@ -0,0 +1,7 @@ +// NB update to "deps[]" when deps is deprecated +"deps ./amd-dep-A.js"; +"deps ./amd-dep-B.js"; + +define([], function() { + return [A, B]; +});
\ No newline at end of file diff --git a/test/tests/amd-format.js b/test/tests/amd-format.js new file mode 100644 index 000000000..3bc01fe38 --- /dev/null +++ b/test/tests/amd-format.js @@ -0,0 +1,18 @@ +/* + this is AMD +*/ +// works with comments!!! +/* + At least I hope so +*/ +"amd"; + +var m = { + amd: 'amd' +}; +define(m); + +// attempt to fool amd detection +if (typeof module != 'undefined') + module.exports = 'hello'; + diff --git a/test/tests/amd-module-2.js b/test/tests/amd-module-2.js new file mode 100644 index 000000000..5fdcb3e58 --- /dev/null +++ b/test/tests/amd-module-2.js @@ -0,0 +1,6 @@ +define([ + './amd-module.js', + '@empty', +], function () { + return { amd: true }; +});
\ No newline at end of file diff --git a/test/tests/amd-module-3.js b/test/tests/amd-module-3.js new file mode 100644 index 000000000..6c9128051 --- /dev/null +++ b/test/tests/amd-module-3.js @@ -0,0 +1,13 @@ +define([ + // with a single-line comment + './amd-module.js', + /* with a multi-line + comment + */ + './amd-module.js' + // trailing single-line comment + /* trailing multi-line + comment */ +], function () { + return { amd: true }; +}); diff --git a/test/tests/amd-module-bom.js b/test/tests/amd-module-bom.js new file mode 100644 index 000000000..0f3de0b7f --- /dev/null +++ b/test/tests/amd-module-bom.js @@ -0,0 +1,4 @@ +define([], function () { + // file starts with a byte order mark (BOM) + return { amd: true }; +}); diff --git a/test/tests/amd-module.js b/test/tests/amd-module.js new file mode 100644 index 000000000..3cb3d58cf --- /dev/null +++ b/test/tests/amd-module.js @@ -0,0 +1,6 @@ +define(['./amd-dep.js'], function(d) { + return { + dep: d, + amd: true + }; +});
\ No newline at end of file diff --git a/test/tests/amd-require.js b/test/tests/amd-require.js new file mode 100644 index 000000000..1db1c8a16 --- /dev/null +++ b/test/tests/amd-require.js @@ -0,0 +1,3 @@ +define(function(require) { + require(["tests/amd-dep.js"]); +}); diff --git a/test/tests/amd-simplified-cjs-aliased-require1.js b/test/tests/amd-simplified-cjs-aliased-require1.js new file mode 100644 index 000000000..819ca44c1 --- /dev/null +++ b/test/tests/amd-simplified-cjs-aliased-require1.js @@ -0,0 +1,7 @@ +define(function(req){ + var r2 = req("./amd-simplified-cjs-aliased-require2.js"); + return { + name: "require1", + require2: r2 + }; +}); diff --git a/test/tests/amd-simplified-cjs-aliased-require2.js b/test/tests/amd-simplified-cjs-aliased-require2.js new file mode 100644 index 000000000..be391226a --- /dev/null +++ b/test/tests/amd-simplified-cjs-aliased-require2.js @@ -0,0 +1,8 @@ +define(["./amd-dep.js","require"],function(amdDep, req){ + var amdCJS = req("./amd-cjs-module.js"); + return { + name: "require2", + amdCJS: amdCJS, + amdDep: amdDep + }; +}); diff --git a/test/tests/anon-named.js b/test/tests/anon-named.js new file mode 100644 index 000000000..6d0a61315 --- /dev/null +++ b/test/tests/anon-named.js @@ -0,0 +1,10 @@ +define('named-in-anon', function() { + return 'named'; +}); + +define(['named-in-anon'], function(named) { + return { + anon: true, + named: named + }; +});
\ No newline at end of file diff --git a/test/tests/async.js b/test/tests/async.js new file mode 100644 index 000000000..f25bf5a81 --- /dev/null +++ b/test/tests/async.js @@ -0,0 +1,5 @@ +// will detect as CommonJS +if (false) require('asdf'); + +// should detect as ES6 first +export async function p() {}
\ No newline at end of file diff --git a/test/tests/bootstrap@3.1.1/test.coffee b/test/tests/bootstrap@3.1.1/test.coffee new file mode 100644 index 000000000..fc0891795 --- /dev/null +++ b/test/tests/bootstrap@3.1.1/test.coffee @@ -0,0 +1 @@ +exports.p = 4; diff --git a/test/tests/branch-boolean.js b/test/tests/branch-boolean.js new file mode 100644 index 000000000..bc5b6ccdb --- /dev/null +++ b/test/tests/branch-boolean.js @@ -0,0 +1 @@ +export default true;
\ No newline at end of file diff --git a/test/tests/branch-ie.js b/test/tests/branch-ie.js new file mode 100644 index 000000000..ea184442e --- /dev/null +++ b/test/tests/branch-ie.js @@ -0,0 +1 @@ +export var branch = 'ie';
\ No newline at end of file diff --git a/test/tests/bundle.js b/test/tests/bundle.js new file mode 100644 index 000000000..d69e7ca69 --- /dev/null +++ b/test/tests/bundle.js @@ -0,0 +1,7 @@ +define('bundle-define1', function() { + return { name: 'bundle1' }; +}); + +define('bundle-define2', function() { + return { name: 'bundle2' }; +});
\ No newline at end of file diff --git a/test/tests/cjs-circular1.js b/test/tests/cjs-circular1.js new file mode 100644 index 000000000..f2946cf87 --- /dev/null +++ b/test/tests/cjs-circular1.js @@ -0,0 +1,4 @@ +exports.first = 'first value'; +var p = require('./cjs-circular2.js').p; +exports.first = 'second value'; +exports.firstWas = p();
\ No newline at end of file diff --git a/test/tests/cjs-circular2.js b/test/tests/cjs-circular2.js new file mode 100644 index 000000000..b6c8d87e4 --- /dev/null +++ b/test/tests/cjs-circular2.js @@ -0,0 +1,4 @@ +var first = require('./cjs-circular1.js').first; +exports.p = function() { + return first; +}
\ No newline at end of file diff --git a/test/tests/cjs-exports-bom.js b/test/tests/cjs-exports-bom.js new file mode 100644 index 000000000..a3174cc3c --- /dev/null +++ b/test/tests/cjs-exports-bom.js @@ -0,0 +1 @@ +exports.foo = "bar";
\ No newline at end of file diff --git a/test/tests/cjs-exports-dep.js b/test/tests/cjs-exports-dep.js new file mode 100644 index 000000000..326bed6cf --- /dev/null +++ b/test/tests/cjs-exports-dep.js @@ -0,0 +1 @@ +exports.e = require('./cjs-exports.js')();
\ No newline at end of file diff --git a/test/tests/cjs-exports.js b/test/tests/cjs-exports.js new file mode 100644 index 000000000..fdd99ca92 --- /dev/null +++ b/test/tests/cjs-exports.js @@ -0,0 +1,6 @@ +module.exports = F; +require('./cjs-exports-dep.js'); +function F() { + return 'export'; +} +module.exports = require('./cjs-exports-dep.js');
\ No newline at end of file diff --git a/test/tests/cjs-format.js b/test/tests/cjs-format.js new file mode 100644 index 000000000..7ac68dc97 --- /dev/null +++ b/test/tests/cjs-format.js @@ -0,0 +1,4 @@ +"format cjs"; +if (typeof define != 'undefined') + define(function() {}); +exports.cjs = 'cjs'; diff --git a/test/tests/cjs-globals.js b/test/tests/cjs-globals.js new file mode 100644 index 000000000..d71e2ed57 --- /dev/null +++ b/test/tests/cjs-globals.js @@ -0,0 +1,3 @@ +exports.dirname = __dirname; +exports.filename = __filename; +exports.global = global;
\ No newline at end of file diff --git a/test/tests/cjs-loading-plugin.js b/test/tests/cjs-loading-plugin.js new file mode 100644 index 000000000..11dc2a5a4 --- /dev/null +++ b/test/tests/cjs-loading-plugin.js @@ -0,0 +1 @@ +module.exports = require('./test.css!');
\ No newline at end of file diff --git a/test/tests/cjs-module-bom.js b/test/tests/cjs-module-bom.js new file mode 100644 index 000000000..2176395e8 --- /dev/null +++ b/test/tests/cjs-module-bom.js @@ -0,0 +1 @@ +module.exports.foo = "bar";
\ No newline at end of file diff --git a/test/tests/cjs-named-export.js b/test/tests/cjs-named-export.js new file mode 100644 index 000000000..6609eeafc --- /dev/null +++ b/test/tests/cjs-named-export.js @@ -0,0 +1,5 @@ +var p = module.exports = function() { + +} + +p.someExport = 'asdf';
\ No newline at end of file diff --git a/test/tests/cjs-process.js b/test/tests/cjs-process.js new file mode 100644 index 000000000..7f750c112 --- /dev/null +++ b/test/tests/cjs-process.js @@ -0,0 +1,3 @@ +exports.env = { + NODE_ENV: 'dev' +};
\ No newline at end of file diff --git a/test/tests/cjs-resolve.js b/test/tests/cjs-resolve.js new file mode 100644 index 000000000..8461373e9 --- /dev/null +++ b/test/tests/cjs-resolve.js @@ -0,0 +1 @@ +module.exports = require.resolve('./a');
\ No newline at end of file diff --git a/test/tests/cjs-this.js b/test/tests/cjs-this.js new file mode 100644 index 000000000..79a4bb5db --- /dev/null +++ b/test/tests/cjs-this.js @@ -0,0 +1,2 @@ +"format cjs"; +this.asdf = 'module value';
\ No newline at end of file diff --git a/test/tests/common-js-dep.js b/test/tests/common-js-dep.js new file mode 100644 index 000000000..3543bf0bf --- /dev/null +++ b/test/tests/common-js-dep.js @@ -0,0 +1 @@ +exports.output = 'this is a dep';
\ No newline at end of file diff --git a/test/tests/common-js-module.js b/test/tests/common-js-module.js new file mode 100644 index 000000000..c7b6c12ee --- /dev/null +++ b/test/tests/common-js-module.js @@ -0,0 +1,2 @@ +exports.first = require('./common-js-dep.js').output; +exports.hello = 'world'; diff --git a/test/tests/commonjs-d.js b/test/tests/commonjs-d.js new file mode 100644 index 000000000..b23a181b8 --- /dev/null +++ b/test/tests/commonjs-d.js @@ -0,0 +1 @@ +module.exports = 'd';
\ No newline at end of file diff --git a/test/tests/commonjs-d2.js b/test/tests/commonjs-d2.js new file mode 100644 index 000000000..3b340b2e0 --- /dev/null +++ b/test/tests/commonjs-d2.js @@ -0,0 +1 @@ +module.exports = 'd6';
\ No newline at end of file diff --git a/test/tests/commonjs-globals.js b/test/tests/commonjs-globals.js new file mode 100644 index 000000000..44194a0db --- /dev/null +++ b/test/tests/commonjs-globals.js @@ -0,0 +1 @@ +exports.process = process;
\ No newline at end of file diff --git a/test/tests/commonjs-requires.js b/test/tests/commonjs-requires.js new file mode 100644 index 000000000..af80d8058 --- /dev/null +++ b/test/tests/commonjs-requires.js @@ -0,0 +1,40 @@ +exports.d6 = +/**/require('./commonjs-d2.js'); + +exports.d1 = require( + './commonjs-d.js' +); + +exports.d2 = (require +("./commonjs-d.js")); + +var regex = / \/* /; + +exports.d3 = "require('not a dep')"; + +exports.d4 = "text/* require('still not a dep') text"; + +exports.d5 = 'text \'quote\' require("yet still not a dep")'; + +var regexWithString = /asdfasdf " /; + +var regexClose = /asdf " */; + +// This comment triggered SystemJS to do a require because of this -> require('') +exports.d7 = 'export'; + +var p = false && require('" + "test" + "'); + +// this line shouldn't be detected +" = require(", "),\n "; + + +/* + +Unsolved breaking cases: + +var regex = / " /; var string = " /* " // one line; +require('asdf') // <- this will now be skipped as it will be in the '/*' comment +*//* + +*/
\ No newline at end of file diff --git a/test/tests/commonjs-variation.js b/test/tests/commonjs-variation.js new file mode 100644 index 000000000..bf8b8c27e --- /dev/null +++ b/test/tests/commonjs-variation.js @@ -0,0 +1,5 @@ +module.exports = { + e: (function p() { + return require('@empty'); + })() +}
\ No newline at end of file diff --git a/test/tests/commonjs-variation2.js b/test/tests/commonjs-variation2.js new file mode 100644 index 000000000..f7a25047b --- /dev/null +++ b/test/tests/commonjs-variation2.js @@ -0,0 +1,8 @@ +Object.defineProperties(module.exports, { + OpaqueToken: {get: function() { + return OpaqueToken; + }}, + __esModule: {value: true} +}); + +function OpaqueToken() {}
\ No newline at end of file diff --git a/test/tests/compiled.coffee b/test/tests/compiled.coffee new file mode 100644 index 000000000..dd46ac6f7 --- /dev/null +++ b/test/tests/compiled.coffee @@ -0,0 +1 @@ +var p = 4;
\ No newline at end of file diff --git a/test/tests/compiler-plugin.js b/test/tests/compiler-plugin.js new file mode 100644 index 000000000..e7068fae3 --- /dev/null +++ b/test/tests/compiler-plugin.js @@ -0,0 +1,4 @@ +"format cjs"; +exports.translate = function(load) { + return 'require("tests/global.js"); exports.extra = "yay!"; \n' + load.source; +} diff --git a/test/tests/compiler-test.coffee b/test/tests/compiler-test.coffee new file mode 100644 index 000000000..a79cb03b2 --- /dev/null +++ b/test/tests/compiler-test.coffee @@ -0,0 +1 @@ +exports.output = "plugin output"; diff --git a/test/tests/connected-tree/a.js b/test/tests/connected-tree/a.js new file mode 100644 index 000000000..2ffbcaa58 --- /dev/null +++ b/test/tests/connected-tree/a.js @@ -0,0 +1,9 @@ +// a.js +var c = require("./c.js"); +var b = require('./b.js'); + +module.exports = { + name: "a", + b: b, + c: c +}; diff --git a/test/tests/connected-tree/b.js b/test/tests/connected-tree/b.js new file mode 100644 index 000000000..0e658df66 --- /dev/null +++ b/test/tests/connected-tree/b.js @@ -0,0 +1,6 @@ +import c from "./c.js"; + +export default { + name: "b", + c: c +}; diff --git a/test/tests/connected-tree/c.js b/test/tests/connected-tree/c.js new file mode 100644 index 000000000..e885e1138 --- /dev/null +++ b/test/tests/connected-tree/c.js @@ -0,0 +1,3 @@ +module.exports = { + name: "c" +};
\ No newline at end of file diff --git a/test/tests/contextual-map-dep.js b/test/tests/contextual-map-dep.js new file mode 100644 index 000000000..c2898baa8 --- /dev/null +++ b/test/tests/contextual-map-dep.js @@ -0,0 +1 @@ +exports.mapdep = 'mapdep'; diff --git a/test/tests/contextual-test/contextual-map.js b/test/tests/contextual-test/contextual-map.js new file mode 100644 index 000000000..c3192b867 --- /dev/null +++ b/test/tests/contextual-test/contextual-map.js @@ -0,0 +1 @@ +module.exports = require('maptest'); diff --git a/test/tests/cs-loader.js b/test/tests/cs-loader.js new file mode 100644 index 000000000..cc24b3fe9 --- /dev/null +++ b/test/tests/cs-loader.js @@ -0,0 +1,3 @@ +exports.translate = function translate(load) { + return load.source.replace(/#/g, ''); +}
\ No newline at end of file diff --git a/test/tests/cs/dep.js b/test/tests/cs/dep.js new file mode 100644 index 000000000..168695856 --- /dev/null +++ b/test/tests/cs/dep.js @@ -0,0 +1 @@ +# language_global = 'cs';
\ No newline at end of file diff --git a/test/tests/cs/main.js b/test/tests/cs/main.js new file mode 100644 index 000000000..e4960c7c9 --- /dev/null +++ b/test/tests/cs/main.js @@ -0,0 +1 @@ +# module.exports = language_global;
\ No newline at end of file diff --git a/test/tests/csp/integrity.js b/test/tests/csp/integrity.js new file mode 100644 index 000000000..0cd357c7a --- /dev/null +++ b/test/tests/csp/integrity.js @@ -0,0 +1,5 @@ +define(function () { + return { + integrity: 'integrity' + } +}); diff --git a/test/tests/csp/nonce.js b/test/tests/csp/nonce.js new file mode 100644 index 000000000..35dee5ee5 --- /dev/null +++ b/test/tests/csp/nonce.js @@ -0,0 +1,3 @@ +module.exports = { + nonce: 'abc' +}; diff --git a/test/tests/csp/nonce2.js b/test/tests/csp/nonce2.js new file mode 100644 index 000000000..1c6556170 --- /dev/null +++ b/test/tests/csp/nonce2.js @@ -0,0 +1,3 @@ +module.exports = { + nonce: 'ab' +}; diff --git a/test/tests/css.css b/test/tests/css.css new file mode 100644 index 000000000..287755162 --- /dev/null +++ b/test/tests/css.css @@ -0,0 +1,3 @@ +body { + background-color: #eee; +} diff --git a/test/tests/css.js b/test/tests/css.js new file mode 100644 index 000000000..c0a3875e2 --- /dev/null +++ b/test/tests/css.js @@ -0,0 +1,3 @@ +exports.instantiate = function(load) { + return { pluginSource: load.source }; +}
\ No newline at end of file diff --git a/test/tests/deep/deep-dep.js b/test/tests/deep/deep-dep.js new file mode 100644 index 000000000..f053ebf79 --- /dev/null +++ b/test/tests/deep/deep-dep.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/tests/deep/deep.js b/test/tests/deep/deep.js new file mode 100644 index 000000000..cb3befa5f --- /dev/null +++ b/test/tests/deep/deep.js @@ -0,0 +1 @@ +require('./deep-dep'); diff --git a/test/tests/default1-dep.js b/test/tests/default1-dep.js new file mode 100644 index 000000000..8771ac87f --- /dev/null +++ b/test/tests/default1-dep.js @@ -0,0 +1 @@ +export var q = 4; diff --git a/test/tests/default1.js b/test/tests/default1.js new file mode 100644 index 000000000..1ff5f0108 --- /dev/null +++ b/test/tests/default1.js @@ -0,0 +1,3 @@ +import q from './default1-dep.js'; +export default 'default1'; +export var d = 'default1';
\ No newline at end of file diff --git a/test/tests/default2.js b/test/tests/default2.js new file mode 100644 index 000000000..db40d327f --- /dev/null +++ b/test/tests/default2.js @@ -0,0 +1 @@ +export default 'default2';
\ No newline at end of file diff --git a/test/tests/default3.js b/test/tests/default3.js new file mode 100644 index 000000000..fd3505e99 --- /dev/null +++ b/test/tests/default3.js @@ -0,0 +1 @@ +export default 'default3';
\ No newline at end of file diff --git a/test/tests/dep.js b/test/tests/dep.js new file mode 100644 index 000000000..20e4f186b --- /dev/null +++ b/test/tests/dep.js @@ -0,0 +1 @@ +define({}); diff --git a/test/tests/duplicateDeps/m1.js b/test/tests/duplicateDeps/m1.js new file mode 100644 index 000000000..77b7efb3b --- /dev/null +++ b/test/tests/duplicateDeps/m1.js @@ -0,0 +1,23 @@ +System.register(["tests/duplicateDeps/m2.js", "tests/duplicateDeps/m2.js", "tests/duplicateDeps/m2.js"], function(exports_1) {
+ var m2_1, m2_2;
+ function foo() {
+ return m2_1.f1() + m2_2.f2();
+ }
+ exports_1("foo", foo);
+ return {
+ setters:[
+ function (_m2_1) {
+ m2_1 = _m2_1;
+ },
+ function (_m2_2) {
+ m2_2 = _m2_2;
+ },
+ function (_m2_3) {
+ var reexports_1 = {};
+ reexports_1["f3"] = _m2_3["f3"];
+ exports_1(reexports_1);
+ }],
+ execute: function() {
+ }
+ }
+});
diff --git a/test/tests/duplicateDeps/m2.js b/test/tests/duplicateDeps/m2.js new file mode 100644 index 000000000..03f71ea8e --- /dev/null +++ b/test/tests/duplicateDeps/m2.js @@ -0,0 +1,13 @@ +System.register([], function(exports_1) {
+ function f1() { return 1; }
+ exports_1("f1", f1);
+ function f2() { return 2; }
+ exports_1("f2", f2);
+ function f3() { return 3; }
+ exports_1("f3", f3);
+ return {
+ setters:[],
+ execute: function() {
+ }
+ }
+});
diff --git a/test/tests/eaa-amd.js b/test/tests/eaa-amd.js new file mode 100644 index 000000000..65843b0f4 --- /dev/null +++ b/test/tests/eaa-amd.js @@ -0,0 +1,3 @@ +define([], function() { + return 'AMD Module'; +});
\ No newline at end of file diff --git a/test/tests/eaa-es6.js b/test/tests/eaa-es6.js new file mode 100644 index 000000000..1a2fd7edc --- /dev/null +++ b/test/tests/eaa-es6.js @@ -0,0 +1 @@ +export default 'ES6 Module';
\ No newline at end of file diff --git a/test/tests/empty-es6.js b/test/tests/empty-es6.js new file mode 100644 index 000000000..c6fa496fa --- /dev/null +++ b/test/tests/empty-es6.js @@ -0,0 +1,3 @@ +(function(global) { + global.emptyES6 = true; +})(typeof window == 'undefined' ? global : window);
\ No newline at end of file diff --git a/test/tests/ep/some-repo/main.js b/test/tests/ep/some-repo/main.js new file mode 100644 index 000000000..a6d27d510 --- /dev/null +++ b/test/tests/ep/some-repo/main.js @@ -0,0 +1 @@ +export var main = 'here'; diff --git a/test/tests/error-loader.js b/test/tests/error-loader.js new file mode 100644 index 000000000..b6b07cd0c --- /dev/null +++ b/test/tests/error-loader.js @@ -0,0 +1 @@ +require('./error.js');
\ No newline at end of file diff --git a/test/tests/error-loader2.js b/test/tests/error-loader2.js new file mode 100644 index 000000000..69b15e06a --- /dev/null +++ b/test/tests/error-loader2.js @@ -0,0 +1 @@ +require('non-existent');
\ No newline at end of file diff --git a/test/tests/error.js b/test/tests/error.js new file mode 100644 index 000000000..ca248d227 --- /dev/null +++ b/test/tests/error.js @@ -0,0 +1 @@ +foo / bar
\ No newline at end of file diff --git a/test/tests/es-module-flag.js b/test/tests/es-module-flag.js new file mode 100644 index 000000000..0ed2e3149 --- /dev/null +++ b/test/tests/es-module-flag.js @@ -0,0 +1,3 @@ +exports.exportName = 'export'; +exports['default'] = 'default export'; +exports.__esModule = true;
\ No newline at end of file diff --git a/test/tests/es-named-import-cjs-cjs.js b/test/tests/es-named-import-cjs-cjs.js new file mode 100644 index 000000000..a7cc4cd32 --- /dev/null +++ b/test/tests/es-named-import-cjs-cjs.js @@ -0,0 +1,3 @@ +exports.cjsFunc = function() { + return 'named export'; +};
\ No newline at end of file diff --git a/test/tests/es-named-import-cjs.js b/test/tests/es-named-import-cjs.js new file mode 100644 index 000000000..f484570c9 --- /dev/null +++ b/test/tests/es-named-import-cjs.js @@ -0,0 +1,2 @@ +import {cjsFunc} from './es-named-import-cjs-cjs.js'; +export var cjsFuncValue = cjsFunc();
\ No newline at end of file diff --git a/test/tests/es6-and-amd.js b/test/tests/es6-and-amd.js new file mode 100644 index 000000000..4c0a87465 --- /dev/null +++ b/test/tests/es6-and-amd.js @@ -0,0 +1,2 @@ +export {default as amd_module} from './eaa-amd.js'; +export {default as es6_module} from './eaa-es6.js';
\ No newline at end of file diff --git a/test/tests/es6-circular1.js b/test/tests/es6-circular1.js new file mode 100644 index 000000000..2cbd289ad --- /dev/null +++ b/test/tests/es6-circular1.js @@ -0,0 +1,10 @@ +import {c} from './es6-circular2.js'; +export var q; +export var r; +export function p() { + if (q) + r = c; + else + q = c; +} +p(); diff --git a/test/tests/es6-circular2.js b/test/tests/es6-circular2.js new file mode 100644 index 000000000..2a6f5c391 --- /dev/null +++ b/test/tests/es6-circular2.js @@ -0,0 +1,3 @@ +export var c = 3; +import { p } from './es6-circular1.js'; +p(); diff --git a/test/tests/es6-cjs-named-export.js b/test/tests/es6-cjs-named-export.js new file mode 100644 index 000000000..378335ccf --- /dev/null +++ b/test/tests/es6-cjs-named-export.js @@ -0,0 +1 @@ +export {someExport} from './cjs-named-export.js';
\ No newline at end of file diff --git a/test/tests/es6-detection1.js b/test/tests/es6-detection1.js new file mode 100644 index 000000000..3fc252f50 --- /dev/null +++ b/test/tests/es6-detection1.js @@ -0,0 +1 @@ +import {q} from './es6-format.js';
\ No newline at end of file diff --git a/test/tests/es6-format.js b/test/tests/es6-format.js new file mode 100644 index 000000000..47b28ed47 --- /dev/null +++ b/test/tests/es6-format.js @@ -0,0 +1,6 @@ +"format es6"; + +class q { +} + + diff --git a/test/tests/es6-import-star-amd.js b/test/tests/es6-import-star-amd.js new file mode 100644 index 000000000..9cf2ff2c0 --- /dev/null +++ b/test/tests/es6-import-star-amd.js @@ -0,0 +1,3 @@ +import * as mod from './es6-loading-amd-dep.js'; + +export var g = mod.default;
\ No newline at end of file diff --git a/test/tests/es6-loading-amd-dep.js b/test/tests/es6-loading-amd-dep.js new file mode 100644 index 000000000..78ecb1bf4 --- /dev/null +++ b/test/tests/es6-loading-amd-dep.js @@ -0,0 +1,3 @@ +define(function() { + return true; +})
\ No newline at end of file diff --git a/test/tests/es6-loading-amd.js b/test/tests/es6-loading-amd.js new file mode 100644 index 000000000..565fdd416 --- /dev/null +++ b/test/tests/es6-loading-amd.js @@ -0,0 +1,9 @@ +System.register(["./es6-loading-amd-dep.js"], function($__export) { + "use strict"; + return { + setters: [function(m) { + $__export("amd", m.default); + }], + execute: function() {} + }; +}); diff --git a/test/tests/es6-plugin.js b/test/tests/es6-plugin.js new file mode 100644 index 000000000..e37de9fce --- /dev/null +++ b/test/tests/es6-plugin.js @@ -0,0 +1,3 @@ +export function fetch() { + return 'module.exports = "plugin";'; +}
\ No newline at end of file diff --git a/test/tests/esm-dep.js b/test/tests/esm-dep.js new file mode 100644 index 000000000..f700e4920 --- /dev/null +++ b/test/tests/esm-dep.js @@ -0,0 +1,5 @@ +export var esmDep = true; + +(function(g) { + g.esmDep = 'esm-dep'; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/esm-with-deps.js b/test/tests/esm-with-deps.js new file mode 100644 index 000000000..55c925513 --- /dev/null +++ b/test/tests/esm-with-deps.js @@ -0,0 +1 @@ +export var p = 5;
\ No newline at end of file diff --git a/test/tests/export-star.js b/test/tests/export-star.js new file mode 100644 index 000000000..31cd2ebac --- /dev/null +++ b/test/tests/export-star.js @@ -0,0 +1,2 @@ +export * from './star-dep.js'; +export var bar = 'bar';
\ No newline at end of file diff --git a/test/tests/foo.js b/test/tests/foo.js new file mode 100644 index 000000000..343cf430b --- /dev/null +++ b/test/tests/foo.js @@ -0,0 +1,10 @@ +System.register("tests/foo.js", [], function($__export) { + "use strict"; + var __moduleName = "foo"; + return { + setters: [], + execute: function() { + $__export('f', 'f'); + } + }; +}); diff --git a/test/tests/global-dep.js b/test/tests/global-dep.js new file mode 100644 index 000000000..3f6511023 --- /dev/null +++ b/test/tests/global-dep.js @@ -0,0 +1,5 @@ +(function(window) { + window.jjQuery = { + v: '1.8.3' + }; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-encapsulation.js b/test/tests/global-encapsulation.js new file mode 100644 index 000000000..b480da8ae --- /dev/null +++ b/test/tests/global-encapsulation.js @@ -0,0 +1,3 @@ +(function(g) { + g.globalName = 'encapsulated global'; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-exports-array.js b/test/tests/global-exports-array.js new file mode 100644 index 000000000..ddfb91a37 --- /dev/null +++ b/test/tests/global-exports-array.js @@ -0,0 +1,5 @@ +A = 'A'; + +B = 'B'; + +C = 'C';
\ No newline at end of file diff --git a/test/tests/global-inaccessible-props.js b/test/tests/global-inaccessible-props.js new file mode 100644 index 000000000..aee7ce02b --- /dev/null +++ b/test/tests/global-inaccessible-props.js @@ -0,0 +1,8 @@ + +(function(window) { + if (!('errorOnAccess' in window)) + throw Error(); + + window.test = 'result of global-inaccessible-props'; + +})(typeof window != 'undefined' ? window : global); diff --git a/test/tests/global-inline-dep.js b/test/tests/global-inline-dep.js new file mode 100644 index 000000000..6873a63b9 --- /dev/null +++ b/test/tests/global-inline-dep.js @@ -0,0 +1,7 @@ +'format global'; +'deps ./global-dep.js'; + + +(function(window) { + window.newDep = jjQuery.v; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-inline-export.js b/test/tests/global-inline-export.js new file mode 100644 index 000000000..0fc07aea5 --- /dev/null +++ b/test/tests/global-inline-export.js @@ -0,0 +1,9 @@ +"format global"; +"exports p.r"; + +(function(window) { + + window.p = { + r: 'r' + }; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-multi-diff.js b/test/tests/global-multi-diff.js new file mode 100644 index 000000000..2b58ae2b1 --- /dev/null +++ b/test/tests/global-multi-diff.js @@ -0,0 +1,3 @@ +foo = "barz"; +baz = "chaz"; +this.zed = "ted";
\ No newline at end of file diff --git a/test/tests/global-multi.js b/test/tests/global-multi.js new file mode 100644 index 000000000..e7f0b5cfc --- /dev/null +++ b/test/tests/global-multi.js @@ -0,0 +1,6 @@ +(function(window) { + window.j$ = window.jjQuery = { + jquery: 'here' + }; +})(typeof window != 'undefined' ? window : global); + diff --git a/test/tests/global-shim-amd.js b/test/tests/global-shim-amd.js new file mode 100644 index 000000000..9754587be --- /dev/null +++ b/test/tests/global-shim-amd.js @@ -0,0 +1,6 @@ +(function(window) { + if (false) + define(function() { + }); + window.test = 'global'; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-shim-config-dep.js b/test/tests/global-shim-config-dep.js new file mode 100644 index 000000000..a7ec1756b --- /dev/null +++ b/test/tests/global-shim-config-dep.js @@ -0,0 +1 @@ +dep = 'shimmed' diff --git a/test/tests/global-shim-config-exports.js b/test/tests/global-shim-config-exports.js new file mode 100644 index 000000000..39553bca8 --- /dev/null +++ b/test/tests/global-shim-config-exports.js @@ -0,0 +1 @@ +var p = 'export' diff --git a/test/tests/global-shim-config.js b/test/tests/global-shim-config.js new file mode 100644 index 000000000..62139f6e3 --- /dev/null +++ b/test/tests/global-shim-config.js @@ -0,0 +1,3 @@ +(function(window) { + window.ME = dep; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global-single-compiled.js b/test/tests/global-single-compiled.js new file mode 100644 index 000000000..1c55c7506 --- /dev/null +++ b/test/tests/global-single-compiled.js @@ -0,0 +1,9 @@ +System.registerDynamic([], false, function($__require, $__exports, $__module) { + var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal($__module.id, null, null); + (function() { + var foo = this["foobar"]; + var foo = 'foo'; + this["foobar"] = foo; + })(); + return _retrieveGlobal(); +})
\ No newline at end of file diff --git a/test/tests/global-single.js b/test/tests/global-single.js new file mode 100644 index 000000000..9f6197b5f --- /dev/null +++ b/test/tests/global-single.js @@ -0,0 +1 @@ +var foo = 'bar';
\ No newline at end of file diff --git a/test/tests/global-with-export.js b/test/tests/global-with-export.js new file mode 100644 index 000000000..656ea6a19 --- /dev/null +++ b/test/tests/global-with-export.js @@ -0,0 +1,5 @@ +(function(window) { + window.q = { + r: 'r' + }; +})(typeof window != 'undefined' ? window : global);
\ No newline at end of file diff --git a/test/tests/global.js b/test/tests/global.js new file mode 100644 index 000000000..ae948f58c --- /dev/null +++ b/test/tests/global.js @@ -0,0 +1,6 @@ +jjQuery = { + v: '2.0..0' +}; +another = { + some: 'thing' +};
\ No newline at end of file diff --git a/test/tests/group-test.js b/test/tests/group-test.js new file mode 100644 index 000000000..61e4eea78 --- /dev/null +++ b/test/tests/group-test.js @@ -0,0 +1,34 @@ +"format register"; + +System.register("group-c", [], function($__export) { + "use strict"; + var __moduleName = "group-c"; + return { + setters: [], + execute: function() { + $__export('default', 'bar'); + } + }; +}); + + + +System.registerDynamic("group-b", ["group-c"], false, function(__require, __exports, __module) { + var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__module.id); + (function() { + this.foo = 'foo'; + }).call(System.global); + return _retrieveGlobal(); +}); + +System.register("group-a", ["./group-b"], function($__export) { + "use strict"; + var __moduleName = "group-a"; + return { + setters: [function(m) {}], + execute: function() {} + }; +}); + + + diff --git a/test/tests/hbs.hbs b/test/tests/hbs.hbs new file mode 100644 index 000000000..6213adcb4 --- /dev/null +++ b/test/tests/hbs.hbs @@ -0,0 +1 @@ +<h1>{{title}}</h1> diff --git a/test/tests/inline-depends-dep.js b/test/tests/inline-depends-dep.js new file mode 100644 index 000000000..9310d31aa --- /dev/null +++ b/test/tests/inline-depends-dep.js @@ -0,0 +1 @@ +window.depValue = 'dep';
\ No newline at end of file diff --git a/test/tests/inline-depends.js b/test/tests/inline-depends.js new file mode 100644 index 000000000..61b318777 --- /dev/null +++ b/test/tests/inline-depends.js @@ -0,0 +1 @@ +window.dep = window.depValue;
\ No newline at end of file diff --git a/test/tests/jquery-named.js b/test/tests/jquery-named.js new file mode 100644 index 000000000..e53799d35 --- /dev/null +++ b/test/tests/jquery-named.js @@ -0,0 +1,3 @@ +define('jquery-named', function() { + return { is: 'jquery' }; +});
\ No newline at end of file diff --git a/test/tests/jquery.js b/test/tests/jquery.js new file mode 100644 index 000000000..e0ec49a53 --- /dev/null +++ b/test/tests/jquery.js @@ -0,0 +1,2 @@ +var a = 'a'; +module.exports = require(a);
\ No newline at end of file diff --git a/test/tests/legacy-plugin.js b/test/tests/legacy-plugin.js new file mode 100644 index 000000000..89fd23f8e --- /dev/null +++ b/test/tests/legacy-plugin.js @@ -0,0 +1,5 @@ +module.exports = function(name, address, fetch, callback, errback) { + fetch(address, function(source) { + callback('exports.plugin = true; ' + source); + }); +} diff --git a/test/tests/loader-scoping.js b/test/tests/loader-scoping.js new file mode 100644 index 000000000..656184c5f --- /dev/null +++ b/test/tests/loader-scoping.js @@ -0,0 +1 @@ +export let loader = System;
\ No newline at end of file diff --git a/test/tests/main-bundle.js b/test/tests/main-bundle.js new file mode 100644 index 000000000..9bf9a306d --- /dev/null +++ b/test/tests/main-bundle.js @@ -0,0 +1,3 @@ +define('jquery', function() { + return { name: 'jquery-bundled' }; +});
\ No newline at end of file diff --git a/test/tests/main-dep.js b/test/tests/main-dep.js new file mode 100644 index 000000000..83e0e77d4 --- /dev/null +++ b/test/tests/main-dep.js @@ -0,0 +1 @@ +exports.dep = 'value';
\ No newline at end of file diff --git a/test/tests/main.js b/test/tests/main.js new file mode 100644 index 000000000..7e6f820a0 --- /dev/null +++ b/test/tests/main.js @@ -0,0 +1 @@ +module.exports = require('./main-dep');
\ No newline at end of file diff --git a/test/tests/map-test-dep.js b/test/tests/map-test-dep.js new file mode 100644 index 000000000..8085c9632 --- /dev/null +++ b/test/tests/map-test-dep.js @@ -0,0 +1 @@ +exports.dep = 'maptest'; diff --git a/test/tests/map-test.js b/test/tests/map-test.js new file mode 100644 index 000000000..e87087e78 --- /dev/null +++ b/test/tests/map-test.js @@ -0,0 +1 @@ +exports.maptest = require('./map-test-dep.js').dep; diff --git a/test/tests/map-test/sub.js b/test/tests/map-test/sub.js new file mode 100644 index 000000000..64dcc8a01 --- /dev/null +++ b/test/tests/map-test/sub.js @@ -0,0 +1 @@ +exports.maptest = 'maptestsub'; diff --git a/test/tests/map-version.js b/test/tests/map-version.js new file mode 100644 index 000000000..56ad56a96 --- /dev/null +++ b/test/tests/map-version.js @@ -0,0 +1 @@ +module.exports = require('./mvd@1.js');
\ No newline at end of file diff --git a/test/tests/meta-deps.js b/test/tests/meta-deps.js new file mode 100644 index 000000000..6bf3b4520 --- /dev/null +++ b/test/tests/meta-deps.js @@ -0,0 +1,21 @@ +(function(global) { + +System.config({ + meta: { + b: { + deps: ['a'] + } + } +}); + +define('a', [], function() { + global.MODULEA = 'a'; +}); + +define('b', [], function() { + return { + a: global.MODULEA + }; +}); + +})(typeof window == 'undefined' ? global : window);
\ No newline at end of file diff --git a/test/tests/meta-override.js b/test/tests/meta-override.js new file mode 100644 index 000000000..b820ec262 --- /dev/null +++ b/test/tests/meta-override.js @@ -0,0 +1,2 @@ +"format global"; +export var p = 'value';
\ No newline at end of file diff --git a/test/tests/mixed-bundle.js b/test/tests/mixed-bundle.js new file mode 100644 index 000000000..58a25c355 --- /dev/null +++ b/test/tests/mixed-bundle.js @@ -0,0 +1,68 @@ +System.register("tree/third", [], function($__export) { + var some; + return { + setters: [], + execute: function() { + some = $__export('some', 'exports'); + } + }; +}); + +System.registerDynamic("tree/cjs", [], true, function(require, exports, __moduleName) { + var global = System.global; + var __define = global.define; + global.define = undefined; + var module = { exports: exports }; + var process = System.get("@@nodeProcess"); + exports.cjs = true; + global.define = __define; + return module.exports; +}); + +System.registerDynamic("tree/jquery", [], false, function(require, exports, __moduleName) { + var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__moduleName); + this.jquery = {}; + + + return _retrieveGlobal(); +}); + +System.register("tree/second", ["./third", "./cjs"], function($__export) { + "use strict"; + var __moduleName = "tree/second"; + var q; + return { + setters: [function() {}, function() {}], + execute: function() { + q = $__export('q', 4); + } + }; +}); + +System.registerDynamic("tree/global", ['./jquery'], false, function(__require, __exports, __moduleName) { + var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__moduleName, "jquery.test"); + "deps ./jquery"; + "exports jquery.test"; + this.jquery = this.jquery || {}; + this.jquery.test = 'output'; + + this["jquery.test"] = jquery.test; + return _retrieveGlobal(); +}); + +System.registerDynamic("tree/amd", ['./global'], false, function() { + return { is: 'amd' }; +}); + + +System.register("tree/first", ["./second", "./amd"], function($__export) { + "use strict"; + var __moduleName = "tree/first"; + var p; + return { + setters: [function() {}, function() {}], + execute: function() { + p = $__export('p', 5); + } + }; +}); diff --git a/test/tests/modA.js b/test/tests/modA.js new file mode 100644 index 000000000..5e9b95304 --- /dev/null +++ b/test/tests/modA.js @@ -0,0 +1,7 @@ +define(function (require, exports, module) { +'use strict'; + + var B = require("tests/lib/modB.js"); + var C = require("./modC.js"); + exports.A = "A"; +}); diff --git a/test/tests/modC.js b/test/tests/modC.js new file mode 100644 index 000000000..00f89c525 --- /dev/null +++ b/test/tests/modC.js @@ -0,0 +1,5 @@ +define(function (require, exports, module) { +'use strict'; + + +}); diff --git a/test/tests/module-name.js b/test/tests/module-name.js new file mode 100644 index 000000000..4076c2b6e --- /dev/null +++ b/test/tests/module-name.js @@ -0,0 +1,8 @@ +System.register([], function(_export, _context) { + return { + setters: [], + execute: function() { + _export('name', _context.id); + } + }; +})
\ No newline at end of file diff --git a/test/tests/module.js b/test/tests/module.js new file mode 100644 index 000000000..45cd96970 --- /dev/null +++ b/test/tests/module.js @@ -0,0 +1,3 @@ +import * as default3 from "./default3.js"; + +export var test = default3.default;
\ No newline at end of file diff --git a/test/tests/multiple-anonymous.js b/test/tests/multiple-anonymous.js new file mode 100644 index 000000000..5e4b93f98 --- /dev/null +++ b/test/tests/multiple-anonymous.js @@ -0,0 +1,14 @@ +define('named-in-anon', function() { + return 'named'; +}); + +define(['named-in-anon'], function(named) { + return { + anon: true, + named: named + }; +}); + +define([], function() { + +});
\ No newline at end of file diff --git a/test/tests/mypackage/index.js b/test/tests/mypackage/index.js new file mode 100644 index 000000000..78b94fe65 --- /dev/null +++ b/test/tests/mypackage/index.js @@ -0,0 +1 @@ +this.mapDep = 'bar'; diff --git a/test/tests/mypackage/lib/bar.js b/test/tests/mypackage/lib/bar.js new file mode 100644 index 000000000..e198b88a4 --- /dev/null +++ b/test/tests/mypackage/lib/bar.js @@ -0,0 +1,2 @@ +bar = 'bar'; +exports = {}; diff --git a/test/tests/mypackage/src/foo.js b/test/tests/mypackage/src/foo.js new file mode 100644 index 000000000..31e546b5a --- /dev/null +++ b/test/tests/mypackage/src/foo.js @@ -0,0 +1,3 @@ +file = 'foo' +if (typeof define != 'undefined') + define({}); diff --git a/test/tests/nameddefine.js b/test/tests/nameddefine.js new file mode 100644 index 000000000..f0a302971 --- /dev/null +++ b/test/tests/nameddefine.js @@ -0,0 +1,14 @@ +var Showdown = { converter: true }; + +// export +if (typeof module !== 'undefined') module.exports = Showdown; + +// stolen from AMD branch of underscore +// AMD define happens at the end for compatibility with AMD loaders +// that don't enforce next-turn semantics on modules. +if (typeof define === 'function' && define.amd) { + define('tests/nameddefine.js', function() { + return Showdown; + }); +} +define('another-define', { named: 'define' }); diff --git a/test/tests/no-default-ext/file.ext b/test/tests/no-default-ext/file.ext new file mode 100644 index 000000000..0194738d0 --- /dev/null +++ b/test/tests/no-default-ext/file.ext @@ -0,0 +1 @@ +exports.ext = 'ext'; diff --git a/test/tests/normalize-hook-test.js b/test/tests/normalize-hook-test.js new file mode 100644 index 000000000..f4d3fb627 --- /dev/null +++ b/test/tests/normalize-hook-test.js @@ -0,0 +1 @@ +"hello world";
\ No newline at end of file diff --git a/test/tests/out.js b/test/tests/out.js new file mode 100644 index 000000000..9eb31e4c1 --- /dev/null +++ b/test/tests/out.js @@ -0,0 +1,19 @@ +"bundle"; +(function() { +var define = System.amdDefine; +define("tests/lib/modD.js", ["require", "exports", "module"], function(require, exports, module) { + 'use strict'; + exports.D = "D"; +}); + +})(); +(function() { +var define = System.amdDefine; +define("tests/lib/modB.js", ["require", "exports", "module", "../modC.js", "./modD.js"], function(require, exports, module) { + 'use strict'; + require('../modC.js'); + require('./modD.js'); + exports.B = "B"; +}); + +})();
\ No newline at end of file diff --git a/test/tests/package-local-alias/index-cjs.js b/test/tests/package-local-alias/index-cjs.js new file mode 100644 index 000000000..0cd8dedcc --- /dev/null +++ b/test/tests/package-local-alias/index-cjs.js @@ -0,0 +1,6 @@ + +var local = require('./local-cjs'); + +exports.q = 'q'; + +exports.fromLocal = local.x; diff --git a/test/tests/package-local-alias/index-default-cjs.js b/test/tests/package-local-alias/index-default-cjs.js new file mode 100644 index 000000000..d0a59da14 --- /dev/null +++ b/test/tests/package-local-alias/index-default-cjs.js @@ -0,0 +1,10 @@ + +var local = require('./local-default-cjs'); + +exports.q = 'q'; + +exports.fromLocal = local; + +var localDirect = require('./local/index-default-cjs.js'); + +exports.fromLocalDirect = localDirect; diff --git a/test/tests/package-local-alias/index-default-esm.js b/test/tests/package-local-alias/index-default-esm.js new file mode 100644 index 000000000..aead1e036 --- /dev/null +++ b/test/tests/package-local-alias/index-default-esm.js @@ -0,0 +1,10 @@ + +import local from './local-default-esm'; + +export var q = 'q'; +export var fromLocal = local; + +import localDirect from './local/index-default-esm.js'; + +export var fromLocalDirect = localDirect; + diff --git a/test/tests/package-local-alias/index-esm.js b/test/tests/package-local-alias/index-esm.js new file mode 100644 index 000000000..809c99695 --- /dev/null +++ b/test/tests/package-local-alias/index-esm.js @@ -0,0 +1,5 @@ + +import {x} from './local-esm'; + +export var q = 'q'; +export var fromLocal = x;
\ No newline at end of file diff --git a/test/tests/package-local-alias/local/index-cjs.js b/test/tests/package-local-alias/local/index-cjs.js new file mode 100644 index 000000000..af02af190 --- /dev/null +++ b/test/tests/package-local-alias/local/index-cjs.js @@ -0,0 +1 @@ +exports.x = 'x'; diff --git a/test/tests/package-local-alias/local/index-default-cjs.js b/test/tests/package-local-alias/local/index-default-cjs.js new file mode 100644 index 000000000..ee03c3617 --- /dev/null +++ b/test/tests/package-local-alias/local/index-default-cjs.js @@ -0,0 +1 @@ +module.exports = 'x'; diff --git a/test/tests/package-local-alias/local/index-default-esm.js b/test/tests/package-local-alias/local/index-default-esm.js new file mode 100644 index 000000000..d35f42cc0 --- /dev/null +++ b/test/tests/package-local-alias/local/index-default-esm.js @@ -0,0 +1,2 @@ + +export default 'x'; diff --git a/test/tests/package-local-alias/local/index-esm.js b/test/tests/package-local-alias/local/index-esm.js new file mode 100644 index 000000000..5039a381e --- /dev/null +++ b/test/tests/package-local-alias/local/index-esm.js @@ -0,0 +1 @@ +export var x = 'x'; diff --git a/test/tests/path/deep.js b/test/tests/path/deep.js new file mode 100644 index 000000000..e254c491a --- /dev/null +++ b/test/tests/path/deep.js @@ -0,0 +1 @@ +module.exports = 'path'; diff --git a/test/tests/plugin-dep.js b/test/tests/plugin-dep.js new file mode 100644 index 000000000..4485e45e4 --- /dev/null +++ b/test/tests/plugin-dep.js @@ -0,0 +1,8 @@ +System.register([], function($__export) { + return { + setters: [], + execute: function() { + $__export('p', 5); + } + }; +});
\ No newline at end of file diff --git a/test/tests/plugin@1.2.3/plugin.js b/test/tests/plugin@1.2.3/plugin.js new file mode 100644 index 000000000..741d6e0f6 --- /dev/null +++ b/test/tests/plugin@1.2.3/plugin.js @@ -0,0 +1,3 @@ +exports.translate = function(load) { + load.source += '\nexports.versionedPlugin = true;'; +}
\ No newline at end of file diff --git a/test/tests/reflection.js b/test/tests/reflection.js new file mode 100644 index 000000000..765dfe816 --- /dev/null +++ b/test/tests/reflection.js @@ -0,0 +1 @@ +export var myname = __moduleName; diff --git a/test/tests/register-circular1.js b/test/tests/register-circular1.js new file mode 100644 index 000000000..178980f73 --- /dev/null +++ b/test/tests/register-circular1.js @@ -0,0 +1,24 @@ +System.register(["./register-circular2.js"], function($__export) { + "use strict"; + var c, + q, + r; + function p() { + if (q) + $__export("r", r = c); + else + $__export("q", q = c); + } + $__export("p", p); + return { + setters: [function(m) { + c = m.c; + }], + execute: function() { + c = 5; + q = $__export("q", q); + r = $__export("r", r); + p(); + } + }; +});
\ No newline at end of file diff --git a/test/tests/register-circular2.js b/test/tests/register-circular2.js new file mode 100644 index 000000000..5b661b81d --- /dev/null +++ b/test/tests/register-circular2.js @@ -0,0 +1,14 @@ +System.register(["./register-circular1.js"], function($__export) { + "use strict"; + var c, + p; + return { + setters: [function(m) { + p = m.p; + }], + execute: function() { + c = $__export("c", 3); + p(); + } + }; +});
\ No newline at end of file diff --git a/test/tests/register-default-extension.js b/test/tests/register-default-extension.js new file mode 100644 index 000000000..0ab2b012a --- /dev/null +++ b/test/tests/register-default-extension.js @@ -0,0 +1,8 @@ +System.register('custom/file.ext', [], function(_export) { + return { + setters: [], + execute: function() { + _export('custom', 'ext'); + } + }; +});
\ No newline at end of file diff --git a/test/tests/register-regex-2.js b/test/tests/register-regex-2.js new file mode 100644 index 000000000..3715b11e6 --- /dev/null +++ b/test/tests/register-regex-2.js @@ -0,0 +1,15 @@ +/** + * @file file comment + * ... + */ + +/** + * module comment + * ... + */ +System.register([], function() { + return { + setters: [], + execute: function() {} + }; +});
\ No newline at end of file diff --git a/test/tests/register-regex.js b/test/tests/register-regex.js new file mode 100644 index 000000000..847e818fd --- /dev/null +++ b/test/tests/register-regex.js @@ -0,0 +1,18 @@ +//// /collection/ +//import 'test/background/collection/clientErrors.spec'; +//import 'test/background/collection/playlistItems.spec'; +//import 'test/background/collection/playlists.spec'; +//import 'test/background/collection/searchResults.spec'; +//import 'test/background/collection/videos.spec'; +//import 'test/background/collection/streamItems.spec'; + +//// /model/ +//import 'test/background/model/activePlaylistManager.spec'; +//import 'test/background/model/clientErrorManager.spec'; +//import 'test/background/model/dataSource.spec'; +//import 'test/background/model/playlistItem.spec'; +//import 'test/background/model/playlistItems.spec'; +//import 'test/background/model/relatedVideosManager.spec'; +//import 'test/background/model/signInManager.spec'; +//import 'test/background/model/user.spec'; +//import 'test/background/model/youTubeV3API.spec';
\ No newline at end of file diff --git a/test/tests/registerdynamic-main.js b/test/tests/registerdynamic-main.js new file mode 100644 index 000000000..dbd630a1d --- /dev/null +++ b/test/tests/registerdynamic-main.js @@ -0,0 +1,11 @@ +System.register(["./registerdynamic-notbundled.js"], function(_export) { + var dependency; + return { + setters: [function(_dependency) { + dependency = _dependency['default']; + }], + execute: function() { + _export("dependency", dependency); + } + } +}); diff --git a/test/tests/registerdynamic-notbundled.js b/test/tests/registerdynamic-notbundled.js new file mode 100644 index 000000000..3406df504 --- /dev/null +++ b/test/tests/registerdynamic-notbundled.js @@ -0,0 +1,5 @@ +System.registerDynamic([], true, function(require, exports, module) { + module.exports = function() { + return 'ok'; + }; +}); diff --git a/test/tests/reldynamic.js b/test/tests/reldynamic.js new file mode 100644 index 000000000..99b5202a8 --- /dev/null +++ b/test/tests/reldynamic.js @@ -0,0 +1,5 @@ + + +export function dynamicLoad() { + return System.import('./reldynamicdep.js', __moduleName); +} diff --git a/test/tests/reldynamicdep.js b/test/tests/reldynamicdep.js new file mode 100644 index 000000000..96da4b8e9 --- /dev/null +++ b/test/tests/reldynamicdep.js @@ -0,0 +1 @@ +export var dynamic = 'module'; diff --git a/test/tests/shared-dep-bundles/a.js b/test/tests/shared-dep-bundles/a.js new file mode 100644 index 000000000..76aef0ec9 --- /dev/null +++ b/test/tests/shared-dep-bundles/a.js @@ -0,0 +1,33 @@ +"format register"; + +System.register("lib/shared-dep", [], function($__export) { + "use strict"; + var __moduleName = "lib/shared-dep"; + function shared() {} + $__export("default", shared); + return { + setters: [], + execute: function() { + ; + } + }; +}); + + + +System.register("lib/a", ["./shared-dep"], function($__export) { + "use strict"; + var __moduleName = "lib/a"; + var shared; + return { + setters: [function(m) { + shared = m.default; + }], + execute: function() { + } + }; +}); + + + +//# sourceMappingURL=a.js.map
\ No newline at end of file diff --git a/test/tests/shared-dep-bundles/b.js b/test/tests/shared-dep-bundles/b.js new file mode 100644 index 000000000..eec0f0bf4 --- /dev/null +++ b/test/tests/shared-dep-bundles/b.js @@ -0,0 +1,33 @@ +"format register"; + +System.register("lib/shared-dep", [], function($__export) { + "use strict"; + var __moduleName = "lib/shared-dep"; + function shared() {} + $__export("default", shared); + return { + setters: [], + execute: function() { + ; + } + }; +}); + + + +System.register("lib/b", ["./shared-dep"], function($__export) { + "use strict"; + var __moduleName = "lib/b"; + var shared; + return { + setters: [function(m) { + shared = m.default; + }], + execute: function() { + } + }; +}); + + + +//# sourceMappingURL=b.js.map
\ No newline at end of file diff --git a/test/tests/shim-map-test-dep.js b/test/tests/shim-map-test-dep.js new file mode 100644 index 000000000..409cf392a --- /dev/null +++ b/test/tests/shim-map-test-dep.js @@ -0,0 +1 @@ +shimmapdep = 'depvalue'
\ No newline at end of file diff --git a/test/tests/shim-package/shim-map-test.js b/test/tests/shim-package/shim-map-test.js new file mode 100644 index 000000000..3dc9d9e8a --- /dev/null +++ b/test/tests/shim-package/shim-map-test.js @@ -0,0 +1 @@ +(typeof window != 'undefined' ? window : global).shimdep = shimmapdep;
\ No newline at end of file diff --git a/test/tests/some-json.json b/test/tests/some-json.json new file mode 100644 index 000000000..ee68c7e15 --- /dev/null +++ b/test/tests/some-json.json @@ -0,0 +1,3 @@ +{ + "some": "json" +} diff --git a/test/tests/some-text.txt b/test/tests/some-text.txt new file mode 100644 index 000000000..9ce617009 --- /dev/null +++ b/test/tests/some-text.txt @@ -0,0 +1 @@ +this is some text diff --git a/test/tests/star-dep.js b/test/tests/star-dep.js new file mode 100644 index 000000000..0b7981c28 --- /dev/null +++ b/test/tests/star-dep.js @@ -0,0 +1 @@ +export var foo = 'foo';
\ No newline at end of file diff --git a/test/tests/subcontextual-map/submodule.js b/test/tests/subcontextual-map/submodule.js new file mode 100644 index 000000000..ffc2d7fe5 --- /dev/null +++ b/test/tests/subcontextual-map/submodule.js @@ -0,0 +1,3 @@ +define(['dep'], function(dep) { + return dep; +});
\ No newline at end of file diff --git a/test/tests/subcontextual-mapdep.js b/test/tests/subcontextual-mapdep.js new file mode 100644 index 000000000..ad8c9d6d6 --- /dev/null +++ b/test/tests/subcontextual-mapdep.js @@ -0,0 +1 @@ +module.exports = 'submapdep';
\ No newline at end of file diff --git a/test/tests/test.css b/test/tests/test.css new file mode 100644 index 000000000..e56b63dfe --- /dev/null +++ b/test/tests/test.css @@ -0,0 +1 @@ +this is css
\ No newline at end of file diff --git a/test/tests/testpkg/depcache-test.js b/test/tests/testpkg/depcache-test.js new file mode 100644 index 000000000..d88fb1bde --- /dev/null +++ b/test/tests/testpkg/depcache-test.js @@ -0,0 +1 @@ +(typeof window != 'undefined' ? window : global).depCacheTest = 'passed'; diff --git a/test/tests/testpkg/dir/index.js b/test/tests/testpkg/dir/index.js new file mode 100644 index 000000000..cef6cd572 --- /dev/null +++ b/test/tests/testpkg/dir/index.js @@ -0,0 +1,2 @@ +require('./self-load.js'); +module.exports = 'dirindex';
\ No newline at end of file diff --git a/test/tests/testpkg/dir/self-load.js b/test/tests/testpkg/dir/self-load.js new file mode 100644 index 000000000..c6a24bda6 --- /dev/null +++ b/test/tests/testpkg/dir/self-load.js @@ -0,0 +1,2 @@ +exports.a = require('..'); +exports.b = require('../');
\ No newline at end of file diff --git a/test/tests/testpkg/dir2/index.json b/test/tests/testpkg/dir2/index.json new file mode 100644 index 000000000..07bd1b14d --- /dev/null +++ b/test/tests/testpkg/dir2/index.json @@ -0,0 +1,3 @@ +{ + "json": "index" +}
\ No newline at end of file diff --git a/test/tests/testpkg/env-module-browser.js b/test/tests/testpkg/env-module-browser.js new file mode 100644 index 000000000..e36fe2f1b --- /dev/null +++ b/test/tests/testpkg/env-module-browser.js @@ -0,0 +1 @@ +module.exports = 'browser';
\ No newline at end of file diff --git a/test/tests/testpkg/env-module.js b/test/tests/testpkg/env-module.js new file mode 100644 index 000000000..3b25aeee1 --- /dev/null +++ b/test/tests/testpkg/env-module.js @@ -0,0 +1 @@ +module.exports = 'not browser';
\ No newline at end of file diff --git a/test/tests/testpkg/index.js b/test/tests/testpkg/index.js new file mode 100644 index 000000000..2fc521784 --- /dev/null +++ b/test/tests/testpkg/index.js @@ -0,0 +1 @@ +exports.prop = 'value';
\ No newline at end of file diff --git a/test/tests/testpkg/interpolate.js b/test/tests/testpkg/interpolate.js new file mode 100644 index 000000000..d93d44f21 --- /dev/null +++ b/test/tests/testpkg/interpolate.js @@ -0,0 +1 @@ +module.exports = 'interpolated!';
\ No newline at end of file diff --git a/test/tests/testpkg/json.js b/test/tests/testpkg/json.js new file mode 100644 index 000000000..278833a81 --- /dev/null +++ b/test/tests/testpkg/json.js @@ -0,0 +1,4 @@ +exports.translate = function(load) { + load.metadata.format = 'cjs'; + return 'module.exports = ' + load.source; +};
\ No newline at end of file diff --git a/test/tests/testpkg/json.json b/test/tests/testpkg/json.json new file mode 100644 index 000000000..0acdfb14b --- /dev/null +++ b/test/tests/testpkg/json.json @@ -0,0 +1,3 @@ +{ + "prop": "value" +}
\ No newline at end of file diff --git a/test/tests/testpkg/polate.js b/test/tests/testpkg/polate.js new file mode 100644 index 000000000..af567b6bf --- /dev/null +++ b/test/tests/testpkg/polate.js @@ -0,0 +1 @@ +module.exports = 'polate';
\ No newline at end of file diff --git a/test/tests/testpkg/self-load.js b/test/tests/testpkg/self-load.js new file mode 100644 index 000000000..1c5617d42 --- /dev/null +++ b/test/tests/testpkg/self-load.js @@ -0,0 +1,2 @@ +exports.a = require('.'); +exports.b = require('./');
\ No newline at end of file diff --git a/test/tests/testpkg/self.js b/test/tests/testpkg/self.js new file mode 100644 index 000000000..c543a0725 --- /dev/null +++ b/test/tests/testpkg/self.js @@ -0,0 +1 @@ +module.exports = require('testpkg/json');
\ No newline at end of file diff --git a/test/tests/testpkg/system.json b/test/tests/testpkg/system.json new file mode 100644 index 000000000..b2092752c --- /dev/null +++ b/test/tests/testpkg/system.json @@ -0,0 +1,28 @@ +{ + "README": "This is not encouraging a system.json, which is a bad idea.", + + "main": ["wrong-main"], + "format": "cjs", + "defaultExtension": "js", + "meta": { + "*.json": { "loader": "json" }, + "noext": { "alias": "./json.json" }, + "test.ts": true + }, + "map": { + "json": "./json.js", + "./json": "./json.json", + "./dir/": "./dir/index", + "./dir2.js": "./dir2/index.json", + "./dir/test": "global-test", + "./env-module": { + "browser": "./env-module-browser.js" + }, + "p": "./polate.js", + "./conditional1": "./interpolate.js", + "./conditional2": "./inter#{p}.js" + }, + "depCache": { + "./dir2/index.json": ["../depcache-test"] + } +}
\ No newline at end of file diff --git a/test/tests/testpkg/test.ts b/test/tests/testpkg/test.ts new file mode 100644 index 000000000..4edba8a31 --- /dev/null +++ b/test/tests/testpkg/test.ts @@ -0,0 +1 @@ +module.exports = 'ts';
\ No newline at end of file diff --git a/test/tests/testpkg2.json b/test/tests/testpkg2.json new file mode 100644 index 000000000..1aae9f17b --- /dev/null +++ b/test/tests/testpkg2.json @@ -0,0 +1,6 @@ +{ + "main": { + "browser": "./asdf.asdf", + "~browser": "./asdf.asdf" + } +}
\ No newline at end of file diff --git a/test/tests/testpkg2/asdf.asdf.js b/test/tests/testpkg2/asdf.asdf.js new file mode 100644 index 000000000..93c2cdd62 --- /dev/null +++ b/test/tests/testpkg2/asdf.asdf.js @@ -0,0 +1,3 @@ +define({ + asdf: 'asdf' +});
\ No newline at end of file diff --git a/test/tests/typescript.ts b/test/tests/typescript.ts new file mode 100644 index 000000000..1cd9b2985 --- /dev/null +++ b/test/tests/typescript.ts @@ -0,0 +1 @@ +module.exports = 'typescript';
\ No newline at end of file diff --git a/test/tests/umd-dep.js b/test/tests/umd-dep.js new file mode 100644 index 000000000..9a690b9c5 --- /dev/null +++ b/test/tests/umd-dep.js @@ -0,0 +1,3 @@ +define({ + dep: 'hi' +})
\ No newline at end of file diff --git a/test/tests/umd.js b/test/tests/umd.js new file mode 100644 index 000000000..7faad2ba9 --- /dev/null +++ b/test/tests/umd.js @@ -0,0 +1,10 @@ +(function (root, factory) { + if (typeof define === 'function' && define.amd) + define(['./umd-dep.js'], function(dep) { + return (root.amdWebGlobal = factory(dep)); + }); + else + root.amdWebGlobal = factory(root.dep); +}(this, function(dep) { + return { d: dep.dep }; +})); diff --git a/test/tests/versioned@2.0.3.js b/test/tests/versioned@2.0.3.js new file mode 100644 index 000000000..c5f522445 --- /dev/null +++ b/test/tests/versioned@2.0.3.js @@ -0,0 +1 @@ +exports.version = '2.3.4'; diff --git a/test/tests/wildcard-test/2.js b/test/tests/wildcard-test/2.js new file mode 100644 index 000000000..4d3891f0c --- /dev/null +++ b/test/tests/wildcard-test/2.js @@ -0,0 +1 @@ +export var q = {}; diff --git a/test/tests/wildcard-test/2/sub.js b/test/tests/wildcard-test/2/sub.js new file mode 100644 index 000000000..05cded75a --- /dev/null +++ b/test/tests/wildcard-test/2/sub.js @@ -0,0 +1 @@ +export var sub = {}; diff --git a/test/tests/wildcard-test/first.js b/test/tests/wildcard-test/first.js new file mode 100644 index 000000000..f2ddf5c35 --- /dev/null +++ b/test/tests/wildcard-test/first.js @@ -0,0 +1 @@ +export var p = {}; diff --git a/test/tests/with-global-deps.js b/test/tests/with-global-deps.js new file mode 100644 index 000000000..4c5addac0 --- /dev/null +++ b/test/tests/with-global-deps.js @@ -0,0 +1 @@ +var newGlobal = $$$;
\ No newline at end of file diff --git a/test/tests/with-runtime-babel.js b/test/tests/with-runtime-babel.js new file mode 100644 index 000000000..4dca494cb --- /dev/null +++ b/test/tests/with-runtime-babel.js @@ -0,0 +1,16 @@ +System.register([], function (_export) { + "use strict"; + + var c; + return { + setters: [], + execute: function () { + c = _export("c", function c() { + babelHelpers.classCallCheck(this, c); + + babelHelpers.get(Object.getPrototypeOf(c.prototype), "constructor", this).call(this); + }); + new c(); + } + }; +});
\ No newline at end of file diff --git a/test/tests/with-runtime-traceur.js b/test/tests/with-runtime-traceur.js new file mode 100644 index 000000000..d86a1dea7 --- /dev/null +++ b/test/tests/with-runtime-traceur.js @@ -0,0 +1,14 @@ +System.register([], function($__export) { + "use strict"; + var __moduleName = "test"; + var c; + return { + setters: [], + execute: function() { + c = $__export("c", (function() { + var c = function c() {}; + return ($traceurRuntime.createClass)(c, {}, {}); + }())); + } + }; +}); diff --git a/test/tests/worker-babel.js b/test/tests/worker-babel.js new file mode 100644 index 000000000..74c741309 --- /dev/null +++ b/test/tests/worker-babel.js @@ -0,0 +1,14 @@ +importScripts('../../dist/system.src.js'); + +System.paths['babel'] = '../../node_modules/babel-core/browser.js'; + +System.transpiler = 'babel'; + +System.import('es6-and-amd.js').then(function(m) { + postMessage({ + amd: m.amd_module, + es6: m.es6_module + }); +}, function(err) { + console.error(err); +}); diff --git a/test/tests/worker-traceur.js b/test/tests/worker-traceur.js new file mode 100644 index 000000000..30902cf40 --- /dev/null +++ b/test/tests/worker-traceur.js @@ -0,0 +1,12 @@ +importScripts('../../dist/system.src.js'); + +System.paths['traceur'] = '../../node_modules/traceur/bin/traceur.js'; + +System.import('es6-and-amd.js').then(function(m) { + postMessage({ + amd: m.amd_module, + es6: m.es6_module + }); +}, function(err) { + console.error(err); +}); diff --git a/test/tests/worker-typescript.js b/test/tests/worker-typescript.js new file mode 100644 index 000000000..7bbf0c231 --- /dev/null +++ b/test/tests/worker-typescript.js @@ -0,0 +1,16 @@ +importScripts('../../dist/system.src.js'); + +System.paths['typescript'] = '../../node_modules/typescript/lib/typescript.js'; +System.meta['typescript'] = { format: 'global', exports: 'ts' }; +System.transpiler = 'typescript'; + +System.normalizeSync('test'); + +System.import('es6-and-amd.js').then(function(m) { + postMessage({ + amd: m.amd_module, + es6: m.es6_module + }); +}, function(err) { + console.error(err); +}); diff --git a/test/tests/wrapper.js b/test/tests/wrapper.js new file mode 100644 index 000000000..9a8eb0328 --- /dev/null +++ b/test/tests/wrapper.js @@ -0,0 +1 @@ +export * from './default1.js';
\ No newline at end of file diff --git a/test/tests/zero@0.js b/test/tests/zero@0.js new file mode 100644 index 000000000..0050f500b --- /dev/null +++ b/test/tests/zero@0.js @@ -0,0 +1 @@ +module.exports = '0';
\ No newline at end of file |