Пример #1
0
 async def main():
     ch = self.chan(1, xf.take_while(lambda x: x != 2))
     for i in range(4):
         ch.f_put(i)
     ch.close()
     self.assertEqual(await a_list(ch), [0, 1])
     self.assertEqual(len(ch._puts), 0)
Пример #2
0
 def test_complete(self):
     xform = xf.comp(xf.take_while(lambda x: x < 4), xf.partition_all(2))
     dropped = list(xf.xiter(xform, [1, 2, 3, 4, 5]))
     self.assertEqual(list(dropped), [(1, 2), (3,)])
Пример #3
0
 def test_pred_ignored_after_first_drop(self):
     xform = xf.take_while(lambda x: x < 0)
     taken = list(xf.xiter(xform, [-1, -2, 3, -4, -5]))
     self.assertEqual(taken, [-1, -2])
Пример #4
0
 def test_arity_zero(self):
     self.assertEqual(xf.take_while(None)(lambda: 'success')(), 'success')
Пример #5
0
 def test_take_none(self):
     taken = list(xf.xiter(xf.take_while(lambda x: x < 0), [1, 2, 3, 4]))
     self.assertEqual(taken, [])