@@ -467,13 +467,13 @@ defmodule StreamTest do
467
467
assert r1 != r2
468
468
end
469
469
470
- test "resource/3 closes on errors" do
470
+ test "resource/3 closes on outer errors" do
471
471
stream = Stream . resource ( fn -> 1 end ,
472
- fn acc -> { [ acc ] , acc + 1 } end ,
473
- fn _ -> Process . put ( :stream_resource , true ) end )
472
+ fn 2 -> throw ( :error )
473
+ acc -> { [ acc ] , acc + 1 } end ,
474
+ fn 2 -> Process . put ( :stream_resource , true ) end )
474
475
475
476
Process . put ( :stream_resource , false )
476
- stream = Stream . map ( stream , fn x -> if x > 2 , do: throw ( :error ) , else: x end )
477
477
assert catch_throw ( Enum . to_list ( stream ) ) == :error
478
478
assert Process . get ( :stream_resource )
479
479
end
@@ -570,13 +570,13 @@ defmodule StreamTest do
570
570
assert Process . get ( :stream_transform )
571
571
end
572
572
573
- test "transform/4 closes on errors" do
573
+ test "transform/4 closes on outer errors" do
574
574
stream = Stream . transform ( 1 .. 10 , fn -> 0 end ,
575
- fn x , acc -> { [ x + acc ] , x } end ,
575
+ fn 3 , _ -> throw ( :error )
576
+ x , acc -> { [ x + acc ] , x } end ,
576
577
fn 2 -> Process . put ( :stream_transform , true ) end )
577
578
578
579
Process . put ( :stream_transform , false )
579
- stream = Stream . map ( stream , fn x -> if x > 2 , do: throw ( :error ) , else: x end )
580
580
assert catch_throw ( Enum . to_list ( stream ) ) == :error
581
581
assert Process . get ( :stream_transform )
582
582
end
@@ -640,7 +640,7 @@ defmodule StreamTest do
640
640
641
641
test "transform/4 closes on errors with inner enum" do
642
642
stream = Stream . transform ( 1 .. 10 , fn -> :acc end ,
643
- fn x , acc -> { [ x .. x + 2 ] , acc } end ,
643
+ fn x , acc -> { x .. x + 2 , acc } end ,
644
644
fn :acc -> Process . put ( :stream_transform , true ) end )
645
645
646
646
Process . put ( :stream_transform , false )
@@ -652,7 +652,7 @@ defmodule StreamTest do
652
652
test "transform/4 is zippable with inner enum" do
653
653
stream = Stream . transform ( 1 .. 20 , fn -> :inner end ,
654
654
fn 10 , acc -> { :halt , acc }
655
- x , acc -> { [ x .. x + 2 ] , acc }
655
+ x , acc -> { x .. x + 2 , acc }
656
656
end ,
657
657
fn :inner -> Process . put ( :stream_transform , true ) end )
658
658
0 commit comments