mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-06-07 17:29:31 +00:00
3.5.2, fixed tests
This commit is contained in:
parent
9885853cea
commit
14589815c4
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "8bitworkshop",
|
"name": "8bitworkshop",
|
||||||
"version": "3.5.1",
|
"version": "3.5.2",
|
||||||
"author": "Steven Hugg",
|
"author": "Steven Hugg",
|
||||||
"description": "8bitworkshop.com",
|
"description": "8bitworkshop.com",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
declare var localforage;
|
declare var localforage;
|
||||||
|
|
||||||
export function createNewPersistentStore(storeid:string) {
|
export function createNewPersistentStore(storeid:string, callback?) {
|
||||||
var store = localforage.createInstance({
|
var store = localforage.createInstance({
|
||||||
name: "__" + storeid,
|
name: "__" + storeid,
|
||||||
version: 2.0
|
version: 2.0
|
||||||
});
|
});
|
||||||
|
if (callback != null) { callback(store); } // for tests only
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,117 +12,90 @@ var prj = require("gen/ide/project.js");
|
||||||
|
|
||||||
var test_platform_id = "_TEST";
|
var test_platform_id = "_TEST";
|
||||||
|
|
||||||
describe('Store', function() {
|
describe('Store', function () {
|
||||||
it('Should convert from local storage', function(done) {
|
|
||||||
localStorage.clear();
|
|
||||||
localStorage.setItem('_TEST/test', 'a');
|
|
||||||
localStorage.setItem('_TEST/local/test', 'b');
|
|
||||||
assert.equal(2, localMods);
|
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
|
||||||
assert.equal('true', localItems['__migrated__TEST']);
|
|
||||||
store.getItem('test', function(err, result) {
|
|
||||||
if (err) done(err);
|
|
||||||
// did it convert?
|
|
||||||
assert.equal(result, 'a');
|
|
||||||
assert.equal(7, localMods);
|
|
||||||
// did we not mess with original storage?
|
|
||||||
assert.equal(localStorage.getItem('_TEST/test'), 'a');
|
|
||||||
assert.equal(localStorage.getItem('_TEST/local/test'), 'b');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should load local project', function(done) {
|
it('Should load local project', function (done) {
|
||||||
localStorage.clear();
|
var store = mstore.createNewPersistentStore(test_platform_id);
|
||||||
localStorage.setItem('_TEST/local/test', 'a');
|
store.setItem('local/test', 'a');
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
|
|
||||||
var worker = {};
|
var worker = {};
|
||||||
var platform = {};
|
var platform = {};
|
||||||
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
||||||
var remote = [];
|
var remote = [];
|
||||||
project.callbackGetRemote = function(path, success, datatype) {
|
project.callbackGetRemote = function (path, success, datatype) {
|
||||||
remote.push(path);
|
remote.push(path);
|
||||||
success();
|
success();
|
||||||
};
|
};
|
||||||
project.loadFiles(['local/test','test']).then((result) => {
|
project.loadFiles(['local/test', 'test']).then((result) => {
|
||||||
assert.deepEqual(["presets/_TEST/test"], remote);
|
assert.deepEqual(["presets/_TEST/test"], remote);
|
||||||
assert.deepEqual([ { path: 'local/test', filename: 'local/test', data: 'a', link:true } ], result);
|
assert.deepEqual([{ path: 'local/test', filename: 'local/test', data: 'a', link: true }], result);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should build linked project', function(done) {
|
it('Should build linked project', function (done) {
|
||||||
localStorage.clear();
|
var msgs = [];
|
||||||
localItems['__migrated__TEST'] = 'true';
|
var expectmsgs = [
|
||||||
var msgs = [];
|
true,
|
||||||
var expectmsgs = [
|
{ preload: 'dasm', platform: '_TEST' },
|
||||||
true,
|
{
|
||||||
{ preload: 'dasm', platform: '_TEST' },
|
buildsteps: [
|
||||||
{
|
{ path: "test.a", platform: "_TEST", tool: "dasm", mainfile: true, files: ["test.a"] },
|
||||||
buildsteps: [
|
],
|
||||||
{ path: "test.a", platform: "_TEST", tool: "dasm", mainfile:true, files:["test.a"] },
|
updates: [
|
||||||
],
|
{ path: "test.a", data: " lda #0" }
|
||||||
updates: [
|
]
|
||||||
{ path: "test.a", data: " lda #0" }
|
}
|
||||||
]
|
];
|
||||||
}
|
var store = mstore.createNewPersistentStore(test_platform_id);
|
||||||
];
|
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, (store) => {
|
|
||||||
var worker = {
|
var worker = {
|
||||||
postMessage: function(m) { msgs.push(m); },
|
postMessage: function (m) { msgs.push(m); },
|
||||||
};
|
};
|
||||||
var platform = {
|
var platform = {
|
||||||
getToolForFilename: function(fn) { return 'dasm'; },
|
getToolForFilename: function (fn) { return 'dasm'; },
|
||||||
};
|
};
|
||||||
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
||||||
project.callbackBuildStatus = function(b) { msgs.push(b) };
|
project.callbackBuildStatus = function (b) { msgs.push(b) };
|
||||||
project.updateFile('test.a', ' lda #0');
|
project.updateFile('test.a', ' lda #0');
|
||||||
project.setMainFile('test.a');
|
project.setMainFile('test.a');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
project.updateFile('test.a', ' lda #1'); // don't send twice (yet)
|
project.updateFile('test.a', ' lda #1'); // don't send twice (yet)
|
||||||
assert.deepEqual(msgs, expectmsgs);
|
assert.deepEqual(msgs, expectmsgs);
|
||||||
store.getItem('test.a', function(err, result) {
|
store.getItem('test.a', function (err, result) {
|
||||||
assert.equal(null, err);
|
assert.equal(null, err);
|
||||||
assert.equal(' lda #1', result);
|
assert.equal(' lda #1', result);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}, 1);
|
}, 1);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// lines: [ { line: 3, offset: 61440, insns: 'a9 00', iscode: true } ] }
|
// lines: [ { line: 3, offset: 61440, insns: 'a9 00', iscode: true } ] }
|
||||||
|
|
||||||
it('Should build asm project', function(done) {
|
it('Should build asm project', function (done) {
|
||||||
localStorage.clear();
|
var msgs = [];
|
||||||
localItems['__migrated__TEST'] = 'true';
|
var store = mstore.createNewPersistentStore(test_platform_id);
|
||||||
var msgs = [];
|
|
||||||
var store = mstore.createNewPersistentStore(test_platform_id, (store) => {
|
|
||||||
var worker = {
|
var worker = {
|
||||||
};
|
};
|
||||||
var platform = {
|
var platform = {
|
||||||
};
|
};
|
||||||
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
|
||||||
project.callbackBuildStatus = function(b) { msgs.push(b) };
|
project.callbackBuildStatus = function (b) { msgs.push(b) };
|
||||||
var buildresult = {
|
var buildresult = {
|
||||||
listings: {
|
listings: {
|
||||||
test: {
|
test: {
|
||||||
lines: [ { line: 3, offset: 61440, insns: 'a9 00', iscode: true } ]
|
lines: [{ line: 3, offset: 61440, insns: 'a9 00', iscode: true }]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
worker.onmessage({data:buildresult});
|
worker.onmessage({ data: buildresult });
|
||||||
assert.deepEqual([false], msgs);
|
assert.deepEqual([false], msgs);
|
||||||
var lst = buildresult.listings.test;
|
var lst = buildresult.listings.test;
|
||||||
console.log(lst);
|
console.log(lst);
|
||||||
assert.deepEqual({line:3,offset:61440}, lst.sourcefile.findLineForOffset(61440+15, 15));
|
assert.deepEqual({ line: 3, offset: 61440 }, lst.sourcefile.findLineForOffset(61440 + 15, 15));
|
||||||
assert.equal(null, lst.sourcefile.findLineForOffset(61440+16, 15));
|
assert.equal(null, lst.sourcefile.findLineForOffset(61440 + 16, 15));
|
||||||
assert.equal(null, lst.sourcefile.findLineForOffset(61440+1, 0));
|
assert.equal(null, lst.sourcefile.findLineForOffset(61440 + 1, 0));
|
||||||
assert.equal(null, lst.sourcefile.findLineForOffset(61440-1, 16));
|
assert.equal(null, lst.sourcefile.findLineForOffset(61440 - 1, 16));
|
||||||
assert.equal(1, lst.sourcefile.lineCount());
|
assert.equal(1, lst.sourcefile.lineCount());
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user