【发布时间】:2018-09-27 22:33:43
【问题描述】:
如何测试以下代码?
["one", "two", "three"]) |> Enum.each(&IO.puts(&1))
one
two
three
:ok
我的测试目前看起来像这样,但失败了,因为 IO.puts 返回 :ok 而不是字符串,并且可能不包括完整字符串中的换行符。
assert ["one", "two", "three"]) |> Enum.each(&IO.puts(&1)) == """
one
two
three
"""
也许IO.puts 是这个用例的错误函数。如果是这样,我可以使用什么替代方案?
提前致谢。
【问题讨论】: