示例#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)