feat: Replace percent button with Pi button, update logic and tests

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 17:50:55 -06:00
committed by Tanner
parent 98fdddac5d
commit 3937109edb
2 changed files with 30 additions and 13 deletions
+17 -1
View File
@@ -330,7 +330,6 @@ const unaryOps = {
'r': { name: 'sqrt', fn: Math.sqrt },
's': { name: 'x^2', fn: (a) => a * a },
'i': { name: '1/x', fn: (a) => 1 / a },
'%': { name: '%', fn: (a) => a / 100 },
};
for (const op in unaryOps) {
@@ -501,5 +500,22 @@ test('Negative zero handling', () => {
checkDisplay(-0);
});
test('Pi button', () => {
press('p');
checkDisplay(Math.PI);
press('*2=');
checkDisplay(Math.PI * 2);
});
test('Pi replaces current number entry', () => {
press('123p');
checkDisplay(Math.PI);
});
test('Operation with Pi', () => {
press('5*p=');
checkDisplay(5 * Math.PI);
});
// Run all the defined tests
runTests();