Пример #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
Пример #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
Пример #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
Пример #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
Пример #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()
Пример #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
Пример #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()
Пример #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()
Пример #9
0
 def test_window_doesnt_break(self):
     _ = ms.stream(range(10)).window(n=2).drain()
Пример #10
0
 def test_drain(self):
     _ = ms.stream([1, 2, 3, 4]).tap(tap_func)
     _.drain()
Пример #11
0
 def test_list(self):
     _ = list(ms.stream([1, 2, 3, 4]).tap(tap_func))
Пример #12
0
 def test_empty_reduce(self):
     try:
         _ = ms.stream([]).reduce(sum_reduction)
     except ms.IllegalStreamOperationException:
         pass
Пример #13
0
 def test_drain(self):
     _ = ms.stream([1, 2, 3, 4])
     _.drain()
Пример #14
0
 def test_list_casting(self):
     _ = list(ms.stream([1, 2, 3, 4]))
Пример #15
0
 def test_initializer(self):
     _ = ms.stream([1]).reduce(sum_reduction, initializer=1)
     assert _ is 2
Пример #16
0
 def test_empty(self):
     _ = ms.stream([]).chunk(6).drain()
Пример #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(_)
Пример #18
0
 def test_less_than_n(self):
     _ = ms.stream([1,2,3,4,5]).chunk(6).drain()
Пример #19
0
 def test_chunk(self):
     _ = ms.stream([1,2,3,4,5]).chunk(2).drain()
Пример #20
0
 def test_cast_to_iter(self):
     _ = ms.stream([1, 2, 3, 4])
     _ = iter(_)
Пример #21
0
 def test_larger_stride_than_window_doesnt_break(self):
     _ = ms.stream(range(10)).window(n=2, stride=4).drain()
Пример #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))
Пример #23
0
 def test_sum_reduce(self):
     _ = ms.stream([1, 2, 3, 4, 5]).reduce(sum_reduction)
     assert _ is 15
Пример #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()
Пример #25
0
 def test_reduce_with_one_element(self):
     _ = ms.stream([1]).reduce(sum_reduction)
     assert _ is 1
Пример #26
0
 def test_larger_window_than_stream_doesnt_break(self):
     _ = ms.stream(range(5)).window(n=10).drain()
Пример #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 _ ]
Пример #28
0
 def test_next(self):
     _ = ms.stream([1, 2, 3, 4])
     while next(_, None) is not None:
         continue
Пример #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()
Пример #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)