![Test Coverage](https://camo.githubusercontent.com/3246bc785f2020872f999db7a6e45976139c72740dee3102d41221099724af4c/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a6f6d636f64652f747363616c632f6261646765732f636f7665726167652e737667)
Demo (https://jomcode.github.io/tscalc/)
calculator:: input * state -> state
Input |
Result |
Next State |
Zero |
Nothing. |
ZeroState |
NonZeroDigit |
Append digit to new accumulator. |
AccumulatorState |
Operation |
If pending op, calculate and create next pending from input. Else create pending op. |
ComputedState |
Equals |
Compute from pending op. No resulting pending ops created. |
ComputedState |
Clear |
Nothing. |
ZeroState |
Input |
Result |
Next State |
Zero |
Append zero to accumulator. |
AccumulatorState |
NonZeroDigit |
Append digit to accumulator. |
AccumulatorState |
Operation |
If pending op, update display with OperationResult. If successful, create pending op. |
ComputedState |
Equals |
Compute from pending op. No resulting pending ops created. |
ComputedState |
Clear |
Clear any pending and go to ZeroState. |
ZeroState |
Input |
Result |
Next State |
Zero |
Go to ZeroState with current pending op if exists. |
ZeroState |
NonZeroDigit |
Append digit to new accumulator. Keep pending op if exists. |
AccumulatorState |
Operation |
Replace any pending op with new one from input. |
ComputedState |
Equals |
Clear pending op. |
ComputedState |
Clear |
Clear any pending and go to ZeroState. |
ZeroState |
Input |
Result |
Next State |
All Except Clear |
Nothing. |
ErrorState |
Clear |
Clear any pending and go to ZeroState. |
ZeroState |
- generic tests corrections
- ng2 tests
Either
tests
- make tests more descriptive
- refactor tests to be less brittle
- decimal?
- negate?
- square rt?