Example #1
0
 def test_complete(self):
     xform = xf.comp(xf.take_last(3), xf.partition_all(2))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])), [(2, 3), (4,)])
Example #2
0
 def test_reduced(self):
     xform = xf.comp(xf.take_last(4), xf.take(2))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5, 6, 7])), [4, 5])
Example #3
0
 def test_arity_zero(self):
     self.assertEqual(xf.take_last(1)(lambda: 'success')(), 'success')
Example #4
0
 def test_empty(self):
     xform = xf.take_last(2)
     self.assertEqual(list(xf.xiter(xform, [])), [])
Example #5
0
 def test_n_neg(self):
     xform = xf.take_last(-1)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [])
Example #6
0
 def test_n_fraction(self):
     xform = xf.take_last(2.5)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])), [4, 5])
Example #7
0
 def test_n_too_small(self):
     xform = xf.take_last(2)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])), [4, 5])
Example #8
0
 def test_n_too_large(self):
     xform = xf.take_last(5)
     self.assertEqual(list(xf.xiter(xform, [1, 2])), [1, 2])