Skip to content

Latest commit

 

History

History
141 lines (112 loc) · 9.05 KB

testing.md

File metadata and controls

141 lines (112 loc) · 9.05 KB

Testing and verify

bun test
bun run test:watch
bun verify

verify = oxlint + oxfmt --check + tsc + tsc:app + Jest (212 tests as of 2026-08-22).

Tests live in src/tests/. Native modules are stubbed in jest.setup.js (AsyncStorage, FlashList → FlatList, expo-updates, safe area, etc.).

Philosophy

Focus on store/session correctness for every math mode the app exposes, plus critical UI wiring — not full visual snapshot coverage. Calculator and bitwise behavior are tested by driving the Zustand store (sessionTestHarness.ts) the same way keypad actions would.

Test files

File What it covers
intMath.test.ts mask/range/parse/display/copy for all bases and word sizes
mathModes.test.ts Parametrized calc + bitwise matrix (bases × word sizes × signed)
calcSession.test.ts Calc keypad sequences, precedence, overflow, history on =
bitwiseSession.test.ts NOT/shift/NEG, AND/OR/XOR, hex entry, bit grid, word size
settingsSession.test.ts Theme/defaults persistence, loadSettings, resetApp, URL constants
history.test.ts AsyncStorage load/save, per-category cap (300), total cap (600)
settingsUi.test.tsx Settings → History nav, Linking.openURL, History FlashList rows
bootstrapApp.test.ts OTA sync then loadSettings order
App.test.tsx Splash + bootstrapApp on mount
updatesController.test.ts OTA check/fetch/skip/fail paths (mocked expo-updates)
storeVersion.test.ts Installed version helper
theme.test.ts Light/dark semantic tokens
appStore.test.ts Store wiring smoke
CustomSplashScreen.test.tsx Splash backgrounds

Calculator — scenario samples (calcSession.test.ts)

Store-driven tests (calcKeys.press(...)) with 8-bit signed — representative flows; the full mode matrix is in mathModes.test.ts + intMath.test.ts:

Scenario Input / action Expected
Basic add 10+1= value 11, history entry
Precedence 2+3×4= 14
Parentheses (2+3)×4= 20
Auto-close paren (5+2= 7
Hex base base 16, 2A+1= 43
Word mask 200+100= 44
Signed overflow 127+1= 128, lastOverflow true
Sticky overflow 127+1−1= 127, overflow stays true
Intermediate fold 80×4÷4= 16, overflow true
Divide by zero 5÷0= divError, value 0
Incomplete 5+ then = toast “Incomplete expression”
AC after eval tokens [], value 0
Backspace 123 ⌫ then = 12
Ans 5+5= then +Ans= 20
Cross-tab calc 15= then bitwise NOT shared value updated

Controller unit tests (applyEvaluate, tapDigit, tapOp, tapAC, tapAns, tapBack) cover div-zero patch, 255×255 mask, and intermediate folding.

Calculator — mode matrix (mathModes.test.ts + intMath.test.ts)

Mode Covered
Input bases DEC/BIN/OCT/HEX Yes
Word sizes 8 / 16 / 32 / 64 Yes
Signed overflow at max + 1 Yes
Unsigned wrap at max + 1 Yes
Mixed-base expressions Yes
Unary minus Yes
Ans in hex Yes
Word shrink mid-session Yes
Empty evaluate Yes

Calculator — remaining non-math gaps

Gap Notes
Clipboard copy (BaseRows) formatCopyValue covered in intMath; UI press not mocked
Full CalculatorScreen render Optional smoke

Bitwise — covered inputs / expected results

Scenario Action Expected
NOT seed 111 → NOT 0x90
SHL overflow 0x80 SHL overflow, value 0
SHR after SHL overflow overflow cleared
NEG at −128 0x80 NEG overflow, value 0x80
AND/OR/XOR F0 op 0F 0, 0xFF, 0xF0 respectively
Pending op switch AND → OR mid-entry pending OR, value unchanged
Hex → operand FF AND 0F operand 0x0F
Hex overflow 1FF on 8-bit toast Max 8-bit
Bit toggle bit 0 on 0 value 1
Bit toggle + pending op F0 AND toggle bit 0 operand 1, value F0
Word shrink 16-bit 0x1FF → 8-bit 0xFF, mask toast
Cross-tab calc 10= OR 5 15

Bitwise — mode matrix (mathModes.test.ts)

Mode Covered
Word sizes 8 / 16 / 32 / 64 Yes
NOT / SHL / SHR / NEG per word size Yes
AND / OR / XOR per word size Yes
Top-bit toggle per word size Yes
Hex entry overflow per word size Yes
Calc ↔ bitwise shared value per size Yes

Bitwise — remaining non-math gaps

Gap Notes
operandWarn UI toast Store flag tested; UI not mocked
BitwiseScreen render Optional smoke

Settings / history / boot

Area Covered Gap
Theme persist + reset preserves light Yes Save failure toast
Launch defaults → session on loadSettings Yes Corrupt JSON in storage
History caps Yes UI empty states (only via buildHistoryListRows in settings test)
Settings UI → History nav Yes (mocked navigation) Full stack integration without mocks
External URLs Yes Linking failure toast
bootstrapApp order Yes —

OTA / app shell

Area Covered Gap
syncOtaUpdate paths Yes —
App splash + bootstrap Yes SPLASH_MIN_MS timing edge
Custom splash theme Yes —

Summary

Math correctness is tested at the store + intMath layer for every user-facing mode: all four calc input bases, all four word sizes, signed and unsigned overflow semantics, all bitwise unary/binary ops, mixed-base expressions, and calc ↔ bitwise value sharing — each with explicit expected numeric answers.

Still outside the math gate: clipboard button wiring (formatting logic is tested), corrupt storage, and unmocked navigation. Those do not affect evaluated results.

Release gate: bun verify (212 tests).