Skip to content

Instantly share code, notes, and snippets.

@thiagokokada
Created August 15, 2018 02:44
Show Gist options
  • Save thiagokokada/83bc221e64bd93030f80d54cf25e2b1e to your computer and use it in GitHub Desktop.
Save thiagokokada/83bc221e64bd93030f80d54cf25e2b1e to your computer and use it in GitHub Desktop.
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