Skip to content

Problem with Exercise 12 RPNCalculator test #14

Description

@tmconrad001

"resolves operator precedence unambiguously" test tries doing two consecutive calculations without resetting the calculator. Basically, it is testing whether:
2+3_((1 + 2) * 3)==1+(2_3)

A fix would to be to require a method that resets the calculator and use that between the tests, or create a new instance of RPNCalculator before the test.

Relevant Code in rpn_calculator_spec.rb:

it "resolves operator precedence unambiguously" do
    #1 2 + 3 * => (1 + 2) * 3
    calculator.push(1)
    calculator.push(2)
    calculator.plus
    calculator.push(3)
    calculator.times
    calculator.value.should == (1+2)*3

    ####
    #Tom Conrad: Error here.  Calculator has
    #to be reset.
    ####

    #1 2 3 * + => 1 + (2 * 3)
    calculator.push(1)
    calculator.push(2)
    calculator.push(3)
    calculator.times
    calculator.plus
    calculator.value.should == 1+(2*3)
  end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions