def test_taking_while_doctest(self): result = [] crt.consume(crt.taking_while(lambda x: x < 5)( crt.append(result)), range(1000)) self.assertListEqual( result, list(range(5)))
def test_filtering_doctest(self): result = [] f = crt.filtering(lambda x: x % 2 == 0) crt.consume(f(crt.append(result)), range(10)) self.assertListEqual( result, [x for x in range(10) if x % 2 == 0])
def test_mapping_doctest(self): result = [] m = crt.mapping(lambda x: x * 2) crt.consume(m(crt.append(result)), range(10)) self.assertListEqual( result, [x * 2 for x in range(10)])
def test_mapcatting_doctest(self): result = [] m = crt.mapcatting(lambda x: reversed(x)) crt.consume(m(crt.append(result)), [(3, 2, 1, 0), (6, 5, 4), (9, 8, 7)]) self.assertListEqual( result, list(range(10)))
def test_taking_while_doctest(self): result = [] crt.consume( crt.taking_while(lambda x: x < 5)(crt.append(result)), range(1000)) self.assertListEqual(result, list(range(5)))
def test_mapcatting_doctest(self): result = [] m = crt.mapcatting(lambda x: reversed(x)) crt.consume(m(crt.append(result)), [(3, 2, 1, 0), (6, 5, 4), (9, 8, 7)]) self.assertListEqual(result, list(range(10)))
def test_filtering_doctest(self): result = [] f = crt.filtering(lambda x: x % 2 == 0) crt.consume(f(crt.append(result)), range(10)) self.assertListEqual(result, [x for x in range(10) if x % 2 == 0])
def test_mapping_doctest(self): result = [] m = crt.mapping(lambda x: x * 2) crt.consume(m(crt.append(result)), range(10)) self.assertListEqual(result, [x * 2 for x in range(10)])