Exemplo n.º 1
0
 def test_next(self):
     _ = ms.stream([1,2,3,4,5]).flatmap(double)
     while next(_, None) is not None:
         continue
     _ = ms.stream([1, 2, 3, 4, 5]).flatmap(repeat_n_times, n = 2)
     while next(_, None) is not None:
         continue
Exemplo n.º 2
0
    def test_next_from_map(self):
        _ = ms.stream([1, 2, 3, 4]).map(add_one)
        while next(_, None) is not None:
            continue

        _ = ms.stream([1, 2, 3, 4]).map(add, 1)
        while next(_, None) is not None:
            continue
Exemplo n.º 3
0
    def test_n2_s2_window_works_to_spec(self):
        stream = ms.stream(range(10)).window(n=2, stride=2)

        computed = [*stream]
        expected = [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]

        assert computed == expected
Exemplo n.º 4
0
    def test_n2_s3_window_works_to_spec(self):
        stream = ms.stream(range(10)).window(n=2, stride=3)

        computed = [*stream]
        expected = [(0, 1), (3, 4), (6, 7), (9)]

        assert computed == expected
Exemplo n.º 5
0
 def test_001(self):
     _ = ms.stream([1, 2, 3, 4, 5])
     _ = _.map(add,1)\
             .map(add_one)\
             .flatmap( double)\
             .flatmap(repeat_n_times,  n = 2)
     _.drain()
Exemplo n.º 6
0
    def test_n2_window_works_to_specification(self):
        stream = ms.stream(range(10)).window(n=2)

        computed = [*stream]
        expected = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7),
                    (7, 8), (8, 9)]

        assert computed == expected
Exemplo n.º 7
0
    def test_MaFiTaFlTkTpDr(self):
        _ = ms.stream(range(20))

        _.map(add_one)\
            .filter(lambda x: x%2 == 0)\
            .take(3)\
            .flatmap(triplicate)\
            .take(8)\
            .tap(no_op)

        _.drain()
Exemplo n.º 8
0
    def test_drain_a_map(self):
        _ = ms.stream([1, 2, 3, 4]).map(add_one)
        _.drain()

        _ = ms.stream([1, 2, 3, 4]).map(add, 1)
        _.drain()
Exemplo n.º 9
0
 def test_window_doesnt_break(self):
     _ = ms.stream(range(10)).window(n=2).drain()
Exemplo n.º 10
0
 def test_drain(self):
     _ = ms.stream([1, 2, 3, 4]).tap(tap_func)
     _.drain()
Exemplo n.º 11
0
 def test_list(self):
     _ = list(ms.stream([1, 2, 3, 4]).tap(tap_func))
Exemplo n.º 12
0
 def test_empty_reduce(self):
     try:
         _ = ms.stream([]).reduce(sum_reduction)
     except ms.IllegalStreamOperationException:
         pass
Exemplo n.º 13
0
 def test_drain(self):
     _ = ms.stream([1, 2, 3, 4])
     _.drain()
Exemplo n.º 14
0
 def test_list_casting(self):
     _ = list(ms.stream([1, 2, 3, 4]))
Exemplo n.º 15
0
 def test_initializer(self):
     _ = ms.stream([1]).reduce(sum_reduction, initializer=1)
     assert _ is 2
Exemplo n.º 16
0
 def test_empty(self):
     _ = ms.stream([]).chunk(6).drain()
Exemplo n.º 17
0
 def test_list_casting(self):
     _ = ms.stream([1,2,3,4,5]).flatmap(double)
     _ = list(_)
     _ = ms.stream([1, 2, 3, 4, 5]).flatmap(repeat_n_times, n = 2)
     _ = list(_)
Exemplo n.º 18
0
 def test_less_than_n(self):
     _ = ms.stream([1,2,3,4,5]).chunk(6).drain()
Exemplo n.º 19
0
 def test_chunk(self):
     _ = ms.stream([1,2,3,4,5]).chunk(2).drain()
Exemplo n.º 20
0
 def test_cast_to_iter(self):
     _ = ms.stream([1, 2, 3, 4])
     _ = iter(_)
Exemplo n.º 21
0
 def test_larger_stride_than_window_doesnt_break(self):
     _ = ms.stream(range(10)).window(n=2, stride=4).drain()
Exemplo n.º 22
0
 def test_map_to_list(self):
     _ = list(ms.stream([1, 2, 3, 4]).map(add_one))
     _ = list(ms.stream([1, 2, 3, 4]).map(add, 1))
Exemplo n.º 23
0
 def test_sum_reduce(self):
     _ = ms.stream([1, 2, 3, 4, 5]).reduce(sum_reduction)
     assert _ is 15
Exemplo n.º 24
0
 def test_drain(self):
     _ = ms.stream([1,2,3,4,5]).flatmap(double)
     _.drain()
     _ = ms.stream([1, 2, 3, 4, 5]).flatmap(repeat_n_times, n = 2)
     _.drain()
Exemplo n.º 25
0
 def test_reduce_with_one_element(self):
     _ = ms.stream([1]).reduce(sum_reduction)
     assert _ is 1
Exemplo n.º 26
0
 def test_larger_window_than_stream_doesnt_break(self):
     _ = ms.stream(range(5)).window(n=10).drain()
Exemplo n.º 27
0
 def test_for_loop(self):
     _ = ms.stream([1,2,3,4,5]).flatmap(double)
     _ = [x for x in _ ]
     _ = ms.stream([1, 2, 3, 4, 5]).flatmap(repeat_n_times, n = 2)
     _ = [x for x in _ ]
Exemplo n.º 28
0
 def test_next(self):
     _ = ms.stream([1, 2, 3, 4])
     while next(_, None) is not None:
         continue
Exemplo n.º 29
0
 def test_embedded(self):
     stream_1 = ms.stream(range(10))
     stream_2 = ms.stream(stream_1)
     stream_3 = ms.stream(stream_2)
     stream_3.drain()
Exemplo n.º 30
0
 def test_compose_a_map(self):
     _ = ms.stream([1, 2, 3, 4]).map(add_one)
     _ = ms.stream([1, 2, 3, 4]).map(add, 1)