test: Add chaos tests for number input, decimals, and leading zeros

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 18:24:56 -06:00
committed by Tanner
parent 7a3e5cd868
commit 8de4d70c8b
+52
View File
@@ -457,6 +457,58 @@ test('Backspace', () => {
checkDisplay('0'); checkDisplay('0');
}); });
test('Number input chaos: decimals and backspace', () => {
// Multiple decimals
press('1.2.3');
checkDisplay('1.23', 'Second decimal point should be ignored');
press('R'); press('R');
// Multiple leading decimals
press('..123');
checkDisplay('0.123', 'Multiple leading decimal points should result in 0.123');
press('R'); press('R');
// Backspace over decimal and re-add
press('1.23B');
checkDisplay('1.2', 'Backspace once');
press('B');
checkDisplay('1.', 'Backspace twice');
press('.');
checkDisplay('1.', 'Adding decimal again should have no effect');
press('B');
checkDisplay('1', 'Backspace a third time');
press('.');
checkDisplay('1.', 'Should be able to add decimal back');
press('45');
checkDisplay('1.45', 'Can add numbers after new decimal');
press('.');
checkDisplay('1.45', 'Another decimal should be ignored');
});
test('Number input chaos: leading zeros', () => {
press('01');
checkDisplay('1', 'Leading zero on integer should be replaced');
press('R'); press('R');
press('000123');
checkDisplay('123', 'Multiple leading zeros on integer should be replaced');
press('R'); press('R');
press('0.123');
checkDisplay('0.123', 'Single zero before decimal is kept');
press('R'); press('R');
press('00.123');
checkDisplay('0.123', 'Multiple zeros before decimal are collapsed to one');
press('R'); press('R');
press('123');
press('R'); // C
checkDisplay(0, 'Clear should result in 0');
press('007');
checkDisplay('7', 'Can input number with leading zeros after a clear');
});
test('Repeated equals', () => { test('Repeated equals', () => {
press('2+3='); press('2+3=');
checkDisplay('5'); checkDisplay('5');