Last active
August 15, 2018 02:30
-
-
Save thiagokokada/906059587de786a59afef561a784cf08 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
defmodule CalculatorTest do | |
use ExUnit.Case | |
import ExUnit.CaptureIO | |
doctest Calculator | |
describe "+ 1.0" do | |
defmodule FakeIO do | |
defdelegate puts(message), to: IO | |
def gets("operation> "), do: "+ 1.0" | |
end | |
test "accumulator should be 1.0" do | |
run = fn -> | |
# Simulate two loops of our REPL since the accumulator is | |
# printed at the start of the call from interpret | |
Calculator.interpret(0.0, FakeIO) | |
|> Calculator.interpret(FakeIO) | |
end | |
assert capture_io(run) =~ "1.0" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment