Created
August 15, 2018 02:44
-
-
Save thiagokokada/83bc221e64bd93030f80d54cf25e2b1e 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
describe "+ 1.0 * 5" do | |
defmodule FakeIO do | |
defdelegate puts(message), to: IO | |
def gets("operation(1)> "), do: "+ 1.0" | |
def gets("operation(2)> "), do: "* 5" | |
def gets(_), do: "= 0.0" | |
end | |
test "accumulator should be 5.0" do | |
run = fn -> | |
Calculator.interpret(0.0, 1, FakeIO) | |
|> Calculator.interpret(2, FakeIO) | |
|> Calculator.interpret(3, FakeIO) | |
end | |
assert capture_io(run) =~ "5.0" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment