1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2026-04-19 08:27:40 +00:00

createNewPersistentStore() calls callback whether or not it converted

This commit is contained in:
Steven Hugg
2019-05-03 18:58:35 -04:00
parent 02ec5c7d04
commit 95feff49da
3 changed files with 75 additions and 72 deletions
+44 -42
View File
@@ -53,7 +53,7 @@ describe('Store', function() {
localStorage.setItem('_TEST/test', 'a');
localStorage.setItem('_TEST/local/test', 'b');
assert.equal(2, localMods);
var store = mstore.createNewPersistentStore(test_platform_id, function() {
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);
@@ -71,7 +71,7 @@ describe('Store', function() {
it('Should load local project', function(done) {
localStorage.clear();
localStorage.setItem('_TEST/local/test', 'a');
var store = mstore.createNewPersistentStore(test_platform_id, function() {
var store = mstore.createNewPersistentStore(test_platform_id, function(store) {
var worker = {};
var platform = {};
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
@@ -105,23 +105,24 @@ describe('Store', function() {
]
}
];
var store = mstore.createNewPersistentStore(test_platform_id);
var worker = {
postMessage: function(m) { msgs.push(m); },
};
var platform = {
getToolForFilename: function(fn) { return 'dasm'; },
};
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
project.callbackBuildStatus = function(b) { msgs.push(b) };
project.updateFile('test.a', ' lda #0');
project.setMainFile('test.a');
project.updateFile('test.a', ' lda #1'); // don't send twice (yet)
assert.deepEqual(msgs, expectmsgs);
store.getItem('test.a', function(err, result) {
assert.equal(null, err);
assert.equal(' lda #1', result);
done();
var store = mstore.createNewPersistentStore(test_platform_id, (store) => {
var worker = {
postMessage: function(m) { msgs.push(m); },
};
var platform = {
getToolForFilename: function(fn) { return 'dasm'; },
};
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
project.callbackBuildStatus = function(b) { msgs.push(b) };
project.updateFile('test.a', ' lda #0');
project.setMainFile('test.a');
project.updateFile('test.a', ' lda #1'); // don't send twice (yet)
assert.deepEqual(msgs, expectmsgs);
store.getItem('test.a', function(err, result) {
assert.equal(null, err);
assert.equal(' lda #1', result);
done();
});
});
});
@@ -131,30 +132,31 @@ describe('Store', function() {
localStorage.clear();
localItems['__migrated__TEST'] = 'true';
var msgs = [];
var store = mstore.createNewPersistentStore(test_platform_id);
var worker = {
};
var platform = {
};
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
project.callbackBuildStatus = function(b) { msgs.push(b) };
var buildresult = {
listings: {
test: {
lines: [ { line: 3, offset: 61440, insns: 'a9 00', iscode: true } ]
var store = mstore.createNewPersistentStore(test_platform_id, (store) => {
var worker = {
};
var platform = {
};
var project = new prj.CodeProject(worker, test_platform_id, platform, store);
project.callbackBuildStatus = function(b) { msgs.push(b) };
var buildresult = {
listings: {
test: {
lines: [ { line: 3, offset: 61440, insns: 'a9 00', iscode: true } ]
}
}
}
};
worker.onmessage({data:buildresult});
assert.deepEqual([false], msgs);
var lst = buildresult.listings.test;
console.log(lst);
assert.equal(3, lst.sourcefile.findLineForOffset(61440+15, 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, 16));
assert.equal(1, lst.sourcefile.lineCount());
done();
};
worker.onmessage({data:buildresult});
assert.deepEqual([false], msgs);
var lst = buildresult.listings.test;
console.log(lst);
assert.equal(3, lst.sourcefile.findLineForOffset(61440+15, 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, 16));
assert.equal(1, lst.sourcefile.lineCount());
done();
});
});
});