mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-04-20 15:16:38 +00:00
better output listing parse
This commit is contained in:
+18
-12
@@ -59,40 +59,46 @@ global.postMessage = null;
|
||||
|
||||
includeInThisContext("src/worker/workermain.js");
|
||||
|
||||
function compile(tool, code, callback, outlen, nlines, nerrors) {
|
||||
function compile(tool, code, platform, callback, outlen, nlines, nerrors) {
|
||||
global.postMessage = function(msg) {
|
||||
if (msg.listing.errors && msg.listing.errors.length) {
|
||||
console.log(msg.listing.errors);
|
||||
assert.equal(nerrors, msg.listing.errors.length, "errors");
|
||||
if (msg.errors && msg.errors.length) {
|
||||
console.log(msg.errors);
|
||||
assert.equal(nerrors, msg.errors.length, "errors");
|
||||
} else {
|
||||
assert.equal(nerrors||0, 0, "errors");
|
||||
assert.equal(msg.output.length, outlen, "output binary");
|
||||
assert.equal(msg.listing.lines.length, nlines, "listing lines");
|
||||
assert.equal(msg.lines.length, nlines, "listing lines");
|
||||
}
|
||||
callback(null, msg);
|
||||
};
|
||||
global.onmessage({
|
||||
data:{code:code, tool:tool}
|
||||
data:{code:code, platform:platform, tool:tool}
|
||||
});
|
||||
}
|
||||
|
||||
describe('Worker', function() {
|
||||
it('should assemble DASM', function(done) {
|
||||
compile('dasm', '\tprocessor 6502\n\torg $f000\nfoo lda #0\n', done, 2, 1);
|
||||
compile('dasm', '\tprocessor 6502\n\torg $f000\nfoo lda #0\n', 'vcs', done, 2, 1);
|
||||
});
|
||||
it('should assemble ACME', function(done) {
|
||||
compile('acme', 'foo: lda #0\n', 'vcs', done, 2, 0); // TODO
|
||||
});
|
||||
it('should compile PLASMA', function(done) {
|
||||
compile('plasm', 'word x = 0', done, 5, 0);
|
||||
compile('plasm', 'word x = 0', 'apple2', done, 5, 0);
|
||||
});
|
||||
it('should compile CC65', function(done) {
|
||||
compile('cc65', '#include <stdio.h>\nint main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', done, 2947, 4);
|
||||
compile('cc65', '#include <stdio.h>\nint main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'apple2', done, 2947, 4);
|
||||
});
|
||||
it('should NOT assemble Z80ASM', function(done) {
|
||||
compile('z80asm', 'ddwiuweq', done, 0, 0, 1);
|
||||
compile('z80asm', 'ddwiuweq', 'none', done, 0, 0, 1);
|
||||
});
|
||||
it('should assemble Z80ASM', function(done) {
|
||||
compile('z80asm', '\tMODULE test\n\tXREF _puts\n\tld hl,$0000\n\tret\n', done, 4, 2, 0);
|
||||
compile('z80asm', '\tMODULE test\n\tXREF _puts\n\tld hl,$0000\n\tret\n', 'none', done, 4, 2, 0);
|
||||
});
|
||||
it('should NOT compile SDCC', function(done) {
|
||||
compile('sdcc', 'foobar', 'none', done, 0, 0, 1);
|
||||
});
|
||||
it('should compile SDCC', function(done) {
|
||||
compile('sdcc', 'int main(int argc) {\nint x=1; int y=2;\nreturn x+y+argc;\n}', done, 16, 8, 0);
|
||||
compile('sdcc', 'int main(int argc) {\nint x=1; int y=2;\nreturn x+y+argc;\n}', 'none', done, 16, 2, 0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user