-
-
Save anonymous/7d85de129207afa820e3bc42552a9199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculator | |
attr_reader :mode, :last | |
def initialize(mode=:real) | |
@mode = mode | |
end | |
def mode=(mode) | |
@mode = mode | |
@last = 0 | |
end | |
def add(a, b) | |
@last = a + b | |
end | |
end | |
class CalculatorTest < MiniTest::Test | |
def test_store_last_result | |
calc = Calculator.new | |
assert_equal 0, calc.last | |
calc.add 1,2 | |
assert_equal 3, calc.last | |
end | |
end | |
=begin | |
1) Failure: | |
CalculatorTest#test_store_last_result [calc.rb:22]: | |
Expected: 0 | |
Actual: nil | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment