     assert Enum.to_list(Stream.take_while(nats, &(&1 <= 5))) == [1, 2, 3, 4, 5]
 
     stream = Stream.drop(1..100, 5)
-    assert Stream.take_while(stream, &(&1 < 11)) |> Enum.to_list == [6, 7, 8, 9, 10]
+    assert Stream.take_while(stream, &(&1 < 11)) |> Enum.to_list() == [6, 7, 8, 9, 10]
   end
 
   test "timer/1" do
     stream = Stream.timer(10)
-    now = :os.timestamp
+    now = :os.timestamp()
     assert Enum.to_list(stream) == [0]
-    assert :timer.now_diff(:os.timestamp, now) > 10000
+    assert :timer.now_diff(:os.timestamp(), now) > 10000
   end
 
   test "unfold/2" do
-    stream = Stream.unfold(10, fn x -> if x > 0, do: {x, x-1} end)
+    stream = Stream.unfold(10, fn x -> if x > 0, do: {x, x - 1} end)
     assert Enum.take(stream, 5) == [10, 9, 8, 7, 6]
-    stream = Stream.unfold(5, fn x -> if x > 0, do: {x, x-1} end)
+    stream = Stream.unfold(5, fn x -> if x > 0, do: {x, x - 1} end)
     assert Enum.to_list(stream) == [5, 4, 3, 2, 1]
   end
 
   test "unfold/2 only calculates values if needed" do
-    stream = Stream.unfold(1, fn x -> if x > 0, do: {x, x-1}, else: throw(:boom) end)
+    stream = Stream.unfold(1, fn x -> if x > 0, do: {x, x - 1}, else: throw(:boom) end)
     assert Enum.take(stream, 1) == [1]
 
-    stream = Stream.unfold(5, fn x -> if x > 0, do: {x, x-1} end)
+    stream = Stream.unfold(5, fn x -> if x > 0, do: {x, x - 1} end)
     assert Enum.to_list(Stream.take(stream, 2)) == [5, 4]
   end
 
   test "unfold/2 is zippable" do
-    stream = Stream.unfold(10, fn x -> if x > 0, do: {x, x-1} end)
-    list   = Enum.to_list(stream)
+    stream = Stream.unfold(10, fn x -> if x > 0, do: {x, x - 1} end)
+    list = Enum.to_list(stream)
     assert Enum.zip(list, list) == Enum.zip(stream, stream)
   end
 
   test "uniq/1 & uniq/2" do
-    assert Stream.uniq([1, 2, 3, 2, 1]) |> Enum.to_list == [1, 2, 3]
+    assert Stream.uniq([1, 2, 3, 2, 1]) |> Enum.to_list() == [1, 2, 3]
   end
 
   test "uniq_by/2" do
-    assert Stream.uniq_by([{1, :x}, {2, :y}, {1, :z}], fn {x, _} -> x end) |> Enum.to_list ==
-           [{1, :x}, {2, :y}]
-
-    assert Stream.uniq_by([a: {:tea, 2}, b: {:tea, 2}, c: {:coffee, 1}], fn {_, y} -> y end) |> Enum.to_list ==
-           [a: {:tea, 2}, c: {:coffee, 1}]
+    assert Stream.uniq_by([{1, :x}, {2, :y}, {1, :z}], fn {x, _} -> x end) |> Enum.to_list() ==
+             [{1, :x}, {2, :y}]
+
+    assert Stream.uniq_by([a: {:tea, 2}, b: {:tea, 2}, c: {:coffee, 1}], fn {_, y} -> y end)
+           |> Enum.to_list() == [a: {:tea, 2}, c: {:coffee, 1}]
   end
 
   test "zip/2" do
     concat = Stream.concat(1..3, 4..6)
-    cycle  = Stream.cycle([:a, :b, :c])
-    assert Stream.zip(concat, cycle) |> Enum.to_list ==
-           [{1, :a}, {2, :b}, {3, :c}, {4, :a}, {5, :b}, {6, :c}]
+    cycle = Stream.cycle([:a, :b, :c])
+
+    assert Stream.zip(concat, cycle) |> Enum.to_list() ==
+             [{1, :a}, {2, :b}, {3, :c}, {4, :a}, {5, :b}, {6, :c}]
   end
 
   test "zip/1" do
     concat = Stream.concat(1..3, 4..6)
-    cycle  = Stream.cycle([:a, :b, :c])
-    assert Stream.zip([concat, cycle]) |> Enum.to_list ==
-           [{1, :a}, {2, :b}, {3, :c}, {4, :a}, {5, :b}, {6, :c}]
+    cycle = Stream.cycle([:a, :b, :c])
+
+    assert Stream.zip([concat, cycle]) |> Enum.to_list() ==
+             [{1, :a}, {2, :b}, {3, :c}, {4, :a}, {5, :b}, {6, :c}]
 
     assert_raise FunctionClauseError, fn ->
       enum_of_enums = Stream.cycle([[1, 2], [:a, :b]])

  end

  test "transform/4 closes on errors with inner enum" do
    stream = Stream.transform(1..10, fn -> :acc end,
                              fn x, acc -> {x..x+2, acc} end,
                              fn :acc -> Process.put(:stream_transform, true) end)

    Process.put(:stream_transform, false)
    stream = Stream.map(stream, fn x -> if x > 2, do: throw(:error), else: x end)

  end

  test "flat_map/2 with inner flat_map/2" do
    stream =
      Stream.flat_map(1..5, fn x ->
        Stream.flat_map([x], fn x ->
          x..(x * x)
        end)
        |> Stream.map(&(&1 * 1))
      end)

    assert Enum.take(stream, 5) == [1, 2, 3, 4, 3]
  end
