Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Exercise 12 RPNCalculator test #14

Open
tmconrad001 opened this issue Feb 7, 2014 · 0 comments
Open

Problem with Exercise 12 RPNCalculator test #14

tmconrad001 opened this issue Feb 7, 2014 · 0 comments

Comments

@tmconrad001
Copy link

"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
aliceFung referenced this issue in aliceFung/learn_ruby Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant