@@ -25,6 +25,37 @@ defmodule StreamTest do
2525 assert Enum . to_list ( stream ) == [ 3 , 5 , 7 ]
2626 end
2727
28+ test :concat_1 do
29+ stream = Stream . concat ( [ 1 .. 3 , [ ] , [ 4 , 5 , 6 ] , [ ] , 7 .. 9 ] )
30+ assert is_function ( stream )
31+
32+ assert Enum . to_list ( stream ) == [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
33+ assert Enum . take ( stream , 5 ) == [ 1 , 2 , 3 , 4 , 5 ]
34+
35+ stream = Stream . concat ( [ 1 .. 3 , [ 4 , 5 , 6 ] , Stream . cycle ( 7 .. 100 ) ] )
36+ assert is_function ( stream )
37+
38+ assert Enum . take ( stream , 13 ) == [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 ]
39+ end
40+
41+ test :concat_2 do
42+ stream = Stream . concat ( 1 .. 3 , 4 .. 6 )
43+ assert is_function ( stream )
44+ assert Stream . cycle ( stream ) |> Enum . take ( 16 ) == [ 1 , 2 , 3 , 4 , 5 , 6 , 1 , 2 , 3 , 4 , 5 , 6 , 1 , 2 , 3 , 4 ]
45+
46+ stream = Stream . concat ( 1 .. 3 , [ ] )
47+ assert is_function ( stream )
48+ assert Stream . cycle ( stream ) |> Enum . take ( 5 ) == [ 1 , 2 , 3 , 1 , 2 ]
49+
50+ stream = Stream . concat ( 1 .. 6 , Stream . cycle ( 7 .. 9 ) )
51+ assert is_function ( stream )
52+ assert Stream . drop ( stream , 3 ) |> Enum . take ( 13 ) == [ 4 , 5 , 6 , 7 , 8 , 9 , 7 , 8 , 9 , 7 , 8 , 9 , 7 ]
53+
54+ stream = Stream . concat ( Stream . cycle ( 1 .. 3 ) , Stream . cycle ( 4 .. 6 ) )
55+ assert is_function ( stream )
56+ assert Enum . take ( stream , 13 ) == [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 ]
57+ end
58+
2859 test :cycle do
2960 stream = Stream . cycle ( [ 1 , 2 , 3 ] )
3061 assert is_function ( stream )
0 commit comments