A simple calculator demonstrating TDD and OO design principles along with a simplistic MVC pattern applied to the command-line interface.
Demonstrates that it is possible to lay a reliable and extensible foundation even with the most basic functionality and environment.
The goal of this exercise is to implement a command-line calculator which uses reverse polish
notation (RPN).
Reverse Polish notation (RPN) is a mathematical notation in which every operator
follows all of its operands, in contrast to Polish notation (PN), which puts the operator
before its operands. It is also known as postfix notation. It does not need any
parentheses as long as each operator has a fixed number of operands.
- Ruby
$ rspec
$ ruby index.rb
- Syntax about testing capturing stdin / stdout
- Referred to a copy of the exceedingly simple and unfinished 'card game of war' program I wrote more than a year and a half ago as a learning exercise.
- Resolve unexpected error when using 'pry' gem:
- Difference between $stdout and STDOUT in Ruby:
- Git syntax foo for squashing into the first commit:
- Mock user input (object receives :gets not $stdin)
- Rspec Mocks
- Find a way to load a file multiple times in one spec file in order to maintain segregation between tests
- Tricks for testing methods with until loops
- Private constants
- Efficient way to generate basic extended list of character input for testing (reference includes benchmarks on various approaches)
- That CTRL-D sends 'end-of-file' not a Signal and syntax for testing it
- Clean equivalent to "drop" for end of an array (sadly, there isn't one)
- Ruby array syntax for writing recursive Calculation.compute method
- Programmatically determine the number of operands an operation takes
- Updating to pry-nav
- Testing errors with Rspec
- Ruby syntax for custom errors
- Apparently, the standard for floating point arithmetic is that you can divide by zero! (sort of)
- Wikipedia Reverse Polish Notation (for independent test cases)
- Ruby syntax for recursing through a file directory
- Plain Ruby syntax for something like Rails' .blank?