Requirement – single operations

So, the plan is to support add, subtract, multiply and divide operations. As explained in the kata presentation, in RPN the operator is located at the end of the expression.

That means a - b is represented as a b -, and the same applies to the other operators: addition +,  multiplication *,  and division /.

Let's add one of each of the supported operations to our tests:

@Testpublic void addOperationReturnsCorrectValue() {  assertThat(reversePolishNotation.compute("1 2 +")).isEqualTo(3);}@Testpublic void subtractOperationReturnsCorrectValue() {  assertThat(reversePolishNotation.compute("2 1 -")).isEqualTo(1);}@Testpublic void multiplyOperationReturnsCorrectValue() { assertThat(reversePolishNotation.compute("2 ...

Get Test-Driven Java Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.