From cf6413136a353bbf350b57a24044c9b0d5c7d4d1 Mon Sep 17 00:00:00 2001 From: guybedford Date: Mon, 17 Aug 2015 16:25:32 +0200 Subject: [PATCH] TypeScript tests all running pending release --- lib/builder.js | 8 ++++++++ lib/trace.js | 4 ++-- test/arithmetic.js | 6 +++--- test/fixtures/test-tree/first.js | 7 +------ test/fixtures/test-tree/runtime.js | 6 ++++++ test/test-build.html | 16 +++++++++++++++ test/test-build.js | 32 ++++++++++++++++++------------ 7 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 test/fixtures/test-tree/runtime.js diff --git a/lib/builder.js b/lib/builder.js index c68e551..ed5fd33 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -253,6 +253,7 @@ Builder.prototype.trace = function(expression) { var namedRegisterRegEx = /(System\.register(Dynamic)?|define)\(('[^']+'|"[^"]+")/g; Builder.prototype.traceModule = function(moduleName) { + var loader = this.loader; var self = this; @@ -267,6 +268,13 @@ Builder.prototype.traceModule = function(moduleName) { }) .then(function(loads) { loader.global.System = System; + + if (moduleName == '@empty') + return { + moduleName: moduleName, + tree: loads + }; + // if it is a bundle, we just use a regex to extract the list of loads // as null records for subtraction arithmetic use only var thisLoad = loads[moduleName]; diff --git a/lib/trace.js b/lib/trace.js index b5a7cae..3c9ee93 100644 --- a/lib/trace.js +++ b/lib/trace.js @@ -86,7 +86,7 @@ Trace.prototype.getAllLoadRecords = function(name, curLoads) { curLoads = curLoads || {}; if (name == '@empty') - return; + return curLoads; var self = this; @@ -95,7 +95,7 @@ Trace.prototype.getAllLoadRecords = function(name, curLoads) { name = getCanonicalName(loader, normalized); if (curLoads[name]) - return; + return curLoads; return self.getLoadRecord(normalized) .then(function(load) { diff --git a/test/arithmetic.js b/test/arithmetic.js index dece139..ad2b1fd 100644 --- a/test/arithmetic.js +++ b/test/arithmetic.js @@ -36,9 +36,9 @@ suite('Bundle Expressions', function() { builder.trace('*.js - [amd-*] - [sfx-format-*]') .then(function(tree) { assert.deepEqual(Object.keys(tree).sort(), [ - 'Buffer.js', 'amd.js', 'cjs-globals.js', 'cjs.js', 'component.jsx!jsx.js', 'first.js', - 'global-inner.js', 'global-outer.js', 'global.js', 'jquery.js', 'jsx.js', 'plugin.js', 'second.js', - 'some.js!plugin.js', 'text-plugin.js', 'text.txt!text-plugin.js', 'third.js', 'umd.js']); + 'Buffer.js', 'amd.js', 'babel', 'cjs-globals.js', 'cjs.js', 'component.jsx!jsx.js', 'first.js', + 'global-inner.js', 'global-outer.js', 'global.js', 'jquery.js', 'jsx.js', 'plugin.js', 'runtime.js', + 'second.js', 'some.js!plugin.js', 'text-plugin.js', 'text.txt!text-plugin.js', 'third.js', 'umd.js']); }) .then(done, done); }); diff --git a/test/fixtures/test-tree/first.js b/test/fixtures/test-tree/first.js index b59f062..cff93ba 100644 --- a/test/fixtures/test-tree/first.js +++ b/test/fixtures/test-tree/first.js @@ -5,9 +5,4 @@ import './amd.js'; import './component.jsx!./jsx.js'; export var p = 5; -export class test extends Object { - constructor() { - super(); - q; - } -} \ No newline at end of file +q; \ No newline at end of file diff --git a/test/fixtures/test-tree/runtime.js b/test/fixtures/test-tree/runtime.js new file mode 100644 index 0000000..9612eff --- /dev/null +++ b/test/fixtures/test-tree/runtime.js @@ -0,0 +1,6 @@ +export class test extends Object { + constructor() { + super(); + q; + } +} \ No newline at end of file diff --git a/test/test-build.html b/test/test-build.html index 58862d8..9ffd79c 100644 --- a/test/test-build.html +++ b/test/test-build.html @@ -200,6 +200,22 @@ }) .catch(done); }); + + test('Runtime', function(done) { + System['import']('output/runtime.js').then(function() { + return System['import']('runtime.js'); + }) + .then(function(m) { + ok(m.test); + done(); + }) + .catch(function(e) { + // traceur runtime doesn't load in PhantomJS + if (e.toString().match(/Attempted to assign to readonly/)) + return done(); + done(e); + }); + }); });