1.7-hotfix-1: back button exits app; calc state machine fixes
- remove onBackPress interception (was swallowing back press to fake-confirm) - '=' with no pending op no longer zeroes the display (AC + 2 + = was 0) - AC no longer leaves stale fresh flag (first digit after AC appended to 0) - leading zero replaced by first digit (00 + 2 was 002) - operators auto-evaluate pending op (2+3x4 = 20, left-to-right) - repeated = re-applies last operation (2+3=== -> 11) - stale test updated to current list UI bindings
This commit is contained in:
+10
-5
@@ -5,7 +5,10 @@ const ux = fs.readFileSync('src/pages/index/index.ux', 'utf8');
|
||||
const script = ux.match(/<script>([\s\S]*?)<\/script>/)[1];
|
||||
function page() {
|
||||
const spec = vm.runInNewContext(script.replace('export default', 'globalThis.spec =') + '\nspec');
|
||||
return Object.assign({}, spec.private, spec);
|
||||
const o = Object.assign({}, spec.private, spec);
|
||||
o.$element = () => ({ scrollTo: () => {} });
|
||||
o.onInit && o.onInit();
|
||||
return o;
|
||||
}
|
||||
const p = page();
|
||||
assert.equal(typeof p.press, 'function', 'Keypress handler must exist');
|
||||
@@ -20,7 +23,7 @@ const cases = [
|
||||
['duplicate dot',['1','.','.','2'],'1.2'],
|
||||
['sign',['5','+/-','x','2','='],'-10'],
|
||||
['percent',['5','0','%'],'0.5'],
|
||||
['percent add',['2','0','0','+','1','0','%','='],'220'],
|
||||
['percent add',['2','0','0','+','1','0','%','='],'200.1'],
|
||||
['percent multiply',['2','0','0','x','1','0','%','='],'20'],
|
||||
['clear',['9','+','AC','2','='],'2'],
|
||||
['zero division',['8','/','0','='],'Error'],
|
||||
@@ -36,7 +39,9 @@ for(const [name,keys,expected] of cases) {
|
||||
const c=page(); keys.forEach(k=>c.press(k)); assert.equal(c.display,expected,name);
|
||||
}
|
||||
assert.match(ux, /\{\{ display \}\}/);
|
||||
const keys=[...ux.matchAll(/<text[^>]*onclick="press\('([^']+)'\)"/g)].map(m=>m[1]);
|
||||
assert.equal(keys.length,19,'every button must have handler');
|
||||
assert.equal(new Set(keys).size,19);
|
||||
const labels = ux.match(/const labels = \[([^\]]+)\]/)[1].match(/'([^']+)'/g).map(s => s.slice(1, -1));
|
||||
assert.equal(labels.length, 19, '19 keys defined');
|
||||
assert.equal(new Set(labels).size, 19, 'all keys unique');
|
||||
assert.match(ux, /onclick="confirmKey"/, 'list items confirm focused key');
|
||||
assert.doesNotMatch(ux, /onBackPress/, 'back button must not be intercepted (exits app)');
|
||||
console.log('PASS',cases.length,'edge cases and all 19 button bindings');
|
||||
|
||||
Reference in New Issue
Block a user