   test "flat_map/2 does not intercept wrapped lazy enumeration" do
     # flat_map returns a lazy enumeration that does not halt
     assert [1, 2, 3, -1, -2]
-           |> Stream.flat_map(fn x -> Stream.map([x, x+1], & &1) end)
+           |> Stream.flat_map(fn x -> Stream.map([x, x + 1], & &1) end)
            |> Stream.take_while(fn x -> x >= 0 end)
-           |> Enum.to_list == [1, 2, 2, 3, 3, 4]
+           |> Enum.to_list() == [1, 2, 2, 3, 3, 4]
 
     # flat_map returns a lazy enumeration that does halts
     assert [1, 2, 3, -1, -2]
-           |> Stream.flat_map(fn x -> Stream.take_while([x, x+1, x+2], &(&1 <= x + 1)) end)
+           |> Stream.flat_map(fn x -> Stream.take_while([x, x + 1, x + 2], &(&1 <= x + 1)) end)
            |> Stream.take_while(fn x -> x >= 0 end)
-           |> Enum.to_list == [1, 2, 2, 3, 3, 4]
+           |> Enum.to_list() == [1, 2, 2, 3, 3, 4]
 
     # flat_map returns a lazy enumeration that does halts wrapped in an enumerable
     assert [1, 2, 3, -1, -2]
-           |> Stream.flat_map(fn x -> Stream.concat([x], Stream.take_while([x+1, x+2], &(&1 <= x + 1))) end)
+           |> Stream.flat_map(fn x ->
+                Stream.concat([x], Stream.take_while([x + 1, x + 2], &(&1 <= x + 1)))
+              end)
            |> Stream.take_while(fn x -> x >= 0 end)
-           |> Enum.to_list == [1, 2, 2, 3, 3, 4]
+           |> Enum.to_list() == [1, 2, 2, 3, 3, 4]
   end
 
   test "flat_map/2 is zippable" do
-    stream = [1, 2, 3, -1, -2]
-             |> Stream.flat_map(fn x -> Stream.map([x, x+1], & &1) end)
-             |> Stream.take_while(fn x -> x >= 0 end)
-    list   = Enum.to_list(stream)
+    stream =
+      [1, 2, 3, -1, -2]
+      |> Stream.flat_map(fn x -> Stream.map([x, x + 1], & &1) end)
+      |> Stream.take_while(fn x -> x >= 0 end)
+
+    list = Enum.to_list(stream)
     assert Enum.zip(list, list) == Enum.zip(stream, stream)
   end
 
   test "flat_map/2 does not leave inner stream suspended" do
-    stream = Stream.flat_map [1, 2, 3],
-      fn i ->
-        Stream.resource(fn -> i end,
-                        fn acc -> {[acc], acc + 1} end,
-                        fn _ -> Process.put(:stream_flat_map, true) end)
-      end
+    stream =
+      Stream.flat_map([1, 2, 3], fn i ->
+        Stream.resource(fn -> i end, fn acc -> {[acc], acc + 1} end, fn _ ->
+          Process.put(:stream_flat_map, true)
+        end)
+      end)
 
     Process.put(:stream_flat_map, false)
     assert stream |> Enum.take(3) == [1, 2, 3]

  test "map_every/3" do
    assert 1..10
           |> Stream.map_every(2, &(&1 * 2))
           |> Enum.to_list == [2, 2, 6, 4, 10, 6, 14, 8, 18, 10]

    assert 1..10
           |> Stream.map_every(3, &(&1 * 2))
           |> Enum.to_list == [2, 2, 3, 8, 5, 6, 14, 8, 9, 20]

    assert 1..10
           |> Stream.drop(2)
           |> Stream.map_every(2, &(&1 * 2))
           |> Stream.drop(1)
           |> Enum.to_list == [4, 10, 6, 14, 8, 18, 10]

    assert 1..5
           |> Stream.map_every(0, &(&1 * 2))
           |> Enum.to_list == [1, 2, 3, 4, 5]

    assert []
           |> Stream.map_every(10, &(&1 * 2))
           |> Enum.to_list == []

    assert_raise FunctionClauseError, fn ->
      Stream.map_every(1..10, -1, &(&1 * 2))

  end

  test "cycle/1 with inner stream" do
    assert [1, 2, 3] |> Stream.take(2) |> Stream.cycle() |> Enum.take(4) == [1, 2, 1, 2]
  end

  test "dedup/1 is lazy" do
    assert lazy?(Stream.dedup([1, 2, 3]))
  end

  test "dedup/1" do
    assert Stream.dedup([1, 1, 2, 1, 1, 2, 1]) |> Enum.to_list() == [1, 2, 1, 2, 1]
    assert Stream.dedup([2, 1, 1, 2, 1]) |> Enum.to_list() == [2, 1, 2, 1]
    assert Stream.dedup([1, 2, 3, 4]) |> Enum.to_list() == [1, 2, 3, 4]
    assert Stream.dedup([1, 1.0, 2.0, 2]) |> Enum.to_list() == [1, 1.0, 2.0, 2]
    assert Stream.dedup([]) |> Enum.to_list() == []

    assert Stream.dedup([nil, nil, true, {:value, true}]) |> Enum.to_list() ==
             [nil, true, {:value, true}]

    assert Stream.dedup([nil]) |> Enum.to_list() == [nil]
  end

  test "dedup_by/2" do
    assert Stream.dedup_by([{1, :x}, {2, :y}, {2, :z}, {1, :x}], fn {x, _} -> x end)
           |> Enum.to_list() == [{1, :x}, {2, :y}, {1, :x}]
  end

  test "drop/2" do
