From 08b32e0102cb2bb7658ac6168e810be46cb562cc Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 2 Jul 2018 16:48:17 -0600 Subject: [PATCH] fixed vicdual skeleton test --- package.json | 2 +- presets/vicdual/{pc437.c => cp437.c} | 0 presets/vicdual/skeleton.sdcc | 2 +- test/cli/testworker.js | 23 +++++++++++++++++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) rename presets/vicdual/{pc437.c => cp437.c} (100%) diff --git a/package.json b/package.json index 4fac35b8..ee484f90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "8bitworkshop", - "version": "1.0.0", + "version": "2.2.0", "author": "Steven Hugg", "dependencies": {}, "devDependencies": { diff --git a/presets/vicdual/pc437.c b/presets/vicdual/cp437.c similarity index 100% rename from presets/vicdual/pc437.c rename to presets/vicdual/cp437.c diff --git a/presets/vicdual/skeleton.sdcc b/presets/vicdual/skeleton.sdcc index a7a3c9b4..4694abab 100644 --- a/presets/vicdual/skeleton.sdcc +++ b/presets/vicdual/skeleton.sdcc @@ -132,7 +132,7 @@ void putstring(byte x, byte y, const char* string) { } // PC font (code page 437) -//#link "pc437.c" +//#link "cp437.c" extern byte font8x8[0x100][8]; const char BOX_CHARS[8] = { 218, 191, 192, 217, 196, 196, 179, 179 }; diff --git a/test/cli/testworker.js b/test/cli/testworker.js index 98447fb7..12bf951b 100644 --- a/test/cli/testworker.js +++ b/test/cli/testworker.js @@ -14,6 +14,18 @@ function compile(tool, code, platform, callback, outlen, nlines, nerrors) { doBuild(msgs, callback, outlen, nlines, nerrors); } +function compileFiles(tool, files, platform, callback, outlen, nlines, nerrors) { + var msg = {updates:[], buildsteps:[]}; + for (var fn of files) { + var text = ab2str(fs.readFileSync('presets/'+platform+'/'+fn)); + msg.updates.push({path:fn, data:text}); + msg.buildsteps.push({path:fn, platform:platform, tool:tool}); + } + doBuild([msg], callback, outlen, nlines, nerrors); +} + + + function doBuild(msgs, callback, outlen, nlines, nerrors) { var msgcount = msgs.length; global.postMessage = function(msg) { @@ -29,9 +41,10 @@ function doBuild(msgs, callback, outlen, nlines, nerrors) { nlines = [nlines]; //console.log(msg.listings, nlines); var i = 0; - for (var key in msg.listings) { + var lstkeys = Object.keys(msg.listings); + lstkeys.sort(); + for (var key of lstkeys) { var listing = msg.listings[key]; - //console.log(listing); assert.equal(listing.lines.length, nlines[i++], "listing lines"); } } @@ -101,10 +114,12 @@ describe('Worker', function() { it('should compile SDCC w/ include', function(done) { compile('sdcc', '#include \nvoid main() {\nstrlen(0);\n}\n', 'mw8080bw', done, 8192, 2, 0); }); + /* it('should compile vicdual skeleton', function(done) { var csource = ab2str(fs.readFileSync('presets/vicdual/skeleton.sdcc')); compile('sdcc', csource, 'vicdual', done, 16416, 45, 0); }); + */ it('should compile mw8080 skeleton', function(done) { var csource = ab2str(fs.readFileSync('presets/mw8080bw/skeleton.sdcc')); compile('sdcc', csource, 'mw8080bw', done, 8192, 84, 0); @@ -220,6 +235,10 @@ describe('Worker', function() { var msgs = [m, m, m2]; doBuild(msgs, done, 8192, [1,1], 0); }); + it('should compile vicdual skeleton', function(done) { + var files = ['skeleton.sdcc', 'cp437.c']; + compileFiles('sdcc', files, 'vicdual', done, 16416, [0,45], 0); + }); // TODO: test if compile, errors, then compile same file });