Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
TypeScript tests all running pending release
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 17, 2015
1 parent 4cd9efe commit cf64131
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 deletions.
8 changes: 8 additions & 0 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Trace.prototype.getAllLoadRecords = function(name, curLoads) {
curLoads = curLoads || {};

if (name == '@empty')
return;
return curLoads;

var self = this;

Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions test/arithmetic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
7 changes: 1 addition & 6 deletions test/fixtures/test-tree/first.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@ import './amd.js';
import './component.jsx!./jsx.js';

export var p = 5;
export class test extends Object {
constructor() {
super();
q;
}
}
q;
6 changes: 6 additions & 0 deletions test/fixtures/test-tree/runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class test extends Object {
constructor() {
super();
q;
}
}
16 changes: 16 additions & 0 deletions test/test-build.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
</script>
<script>
Expand Down
32 changes: 19 additions & 13 deletions test/test-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@ function testPhantom(html) {
spawn('node_modules/.bin/mocha-phantomjs', [html], { stdio: 'inherit' })
.on('close', function(code) {
if (code !== 0)
reject(Error('Phantom test failed'));
reject(Error('Phantom test failed ' + html + ' failed.'));
else
resolve();
});
});
}

function doTests(transpiler) {
builder.reset();
builder.config(cfg);
builder.config({ transpiler: transpiler });

test('In-memory build', function() {
builder.reset();
builder.config(cfg);
builder.config({ transpiler: transpiler });
return builder.build('first.js', { sourceMaps: true, minify: minify })
.then(function(output) {
fs.writeFileSync('test/output/memory-test.js', inline(output));
})
});
});

test('Multi-format tree build', function() {
builder.reset();
builder.config(cfg);
builder.config({ transpiler: transpiler });

return builder.build('first.js', 'test/output/tree-build.js', { sourceMaps: true, minify: minify, globalDefs: { DEBUG: false } })
.then(function() {
Expand Down Expand Up @@ -133,12 +136,15 @@ function doTests(transpiler) {
.then(function() {
return builder.build('cjs-globals.js', 'test/output/cjs-globals.js');
})

.then(function() {
return builder.build('runtime.js', 'test/output/runtime.js');
})
})
.then(function () {
return testPhantom('test/test-build.html');
})
['catch'](function(err) {
console.log(err);
throw err;
});
});
Expand All @@ -158,16 +164,10 @@ function doTests(transpiler) {
return builder.buildSFX('toamd1', 'test/output/sfx.js', { runtime: true, minify: minify, globalDefs: { DEBUG: false } })
.then(function() {
return testPhantom('test/test-sfx.html');
})
});
});
}

/* suite('Test tree builds - TypeScript', function() {
doTests('typescript');
}); */

suite('Test tree builds - Traceur', function() {

doTests('traceur');
Expand All @@ -180,6 +180,12 @@ suite('Test tree builds - Babel', function() {

});

/* suite('Test tree builds - TypeScript', function() {
doTests('typescript');
}); */

suite('Bundle Format', function() {
test('Test AMD format', function() {
return Promise.resolve()
Expand Down

0 comments on commit cf64131

Please sign in to comment.