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
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
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
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
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()
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
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()
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()
def test_window_doesnt_break(self): _ = ms.stream(range(10)).window(n=2).drain()
def test_drain(self): _ = ms.stream([1, 2, 3, 4]).tap(tap_func) _.drain()
def test_list(self): _ = list(ms.stream([1, 2, 3, 4]).tap(tap_func))
def test_empty_reduce(self): try: _ = ms.stream([]).reduce(sum_reduction) except ms.IllegalStreamOperationException: pass
def test_drain(self): _ = ms.stream([1, 2, 3, 4]) _.drain()
def test_list_casting(self): _ = list(ms.stream([1, 2, 3, 4]))
def test_initializer(self): _ = ms.stream([1]).reduce(sum_reduction, initializer=1) assert _ is 2
def test_empty(self): _ = ms.stream([]).chunk(6).drain()
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(_)
def test_less_than_n(self): _ = ms.stream([1,2,3,4,5]).chunk(6).drain()
def test_chunk(self): _ = ms.stream([1,2,3,4,5]).chunk(2).drain()
def test_cast_to_iter(self): _ = ms.stream([1, 2, 3, 4]) _ = iter(_)
def test_larger_stride_than_window_doesnt_break(self): _ = ms.stream(range(10)).window(n=2, stride=4).drain()
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))
def test_sum_reduce(self): _ = ms.stream([1, 2, 3, 4, 5]).reduce(sum_reduction) assert _ is 15
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()
def test_reduce_with_one_element(self): _ = ms.stream([1]).reduce(sum_reduction) assert _ is 1
def test_larger_window_than_stream_doesnt_break(self): _ = ms.stream(range(5)).window(n=10).drain()
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 _ ]
def test_next(self): _ = ms.stream([1, 2, 3, 4]) while next(_, None) is not None: continue
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()
def test_compose_a_map(self): _ = ms.stream([1, 2, 3, 4]).map(add_one) _ = ms.stream([1, 2, 3, 4]).map(add, 1)