     test "streams an enumerable with fun and bad supervisor fun" do
       Process.flag(:trap_exit, true)
 
-      assert {{%RuntimeError{message: "bad"}, _stacktrace}, _mfa} =
-               catch_exit(
-                 fn _i -> raise "bad" end
-                 |> Task.Supervisor.async_stream(1..4, &sleep_and_return_ancestor/1, @opts)
-                 |> Stream.run()
-               )
-
-      refute_received _
-
-      assert {{:noproc, _stacktrace}, _mfa} =
-               catch_exit(
-                 fn _i -> :not_a_supervisor end
-                 |> Task.Supervisor.async_stream(1..4, &sleep_and_return_ancestor/1, @opts)
-                 |> Stream.run()
-               )
+      stream =
+        fn _i -> raise "bad" end
+        |> Task.Supervisor.async_stream(1..4, &sleep_and_return_ancestor/1, @opts)
+
+      assert {{%RuntimeError{message: "bad"}, _stacktrace}, _mfa} = catch_exit(Stream.run(stream))
+
+      refute_received _
+
+      stream =
+        fn _i -> :not_a_supervisor end
+        |> Task.Supervisor.async_stream(1..4, &sleep_and_return_ancestor/1, @opts)
+
+      assert {{:noproc, _stacktrace}, _mfa} = catch_exit(Stream.run(stream))
 
       refute_received _
     end

    parent = self()
    fun = fn -> wait_and_send(parent, :done) end
    task = Task.Supervisor.async_nolink(config[:supervisor], fun)

    assert Task.Supervisor.children(config[:supervisor]) == [task.pid]

    # Assert the struct

    end

    test "shuts down unused tasks", %{supervisor: supervisor} do
      collection = [0, :infinity, :infinity, :infinity]

      assert supervisor
             |> Task.Supervisor.async_stream(collection, &sleep/1, @opts)
             |> Enum.take(1) == [ok: 0]

      assert Process.info(self(), :links) == {:links, [supervisor]}
    end

    test "shuts down unused tasks without leaking messages", %{supervisor: supervisor} do
      collection = [0, :infinity, :infinity, :infinity]

      assert supervisor
             |> Task.Supervisor.async_stream(collection, &sleep/1, @opts)
             |> Enum.take(1) == [ok: 0]

      refute_received _
