def test_no_cycling(self):
     it = declarations.Iterator([1, 2], cycle=False)
     self.assertEqual(1, utils.evaluate_declaration(it, force_sequence=0))
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=1))
     self.assertRaises(StopIteration,
                       utils.evaluate_declaration,
                       it,
                       force_sequence=2)
Ejemplo n.º 2
0
 def test_reset_no_cycling(self):
     it = declarations.Iterator([1, 2], cycle=False)
     self.assertEqual(1, it.evaluate(0, None, False))
     self.assertEqual(2, it.evaluate(1, None, False))
     self.assertRaises(StopIteration, it.evaluate, 2, None, False)
     it.reset()
     self.assertEqual(1, it.evaluate(0, None, False))
     self.assertEqual(2, it.evaluate(1, None, False))
     self.assertRaises(StopIteration, it.evaluate, 2, None, False)
Ejemplo n.º 3
0
 def test_reset_cycle(self):
     it = declarations.Iterator([1, 2])
     self.assertEqual(1, utils.evaluate_declaration(it, force_sequence=0))
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=1))
     self.assertEqual(1, utils.evaluate_declaration(it, force_sequence=2))
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=3))
     self.assertEqual(1, utils.evaluate_declaration(it, force_sequence=4))
     it.reset()
     self.assertEqual(1, utils.evaluate_declaration(it, force_sequence=5))
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=6))
Ejemplo n.º 4
0
 def test_reset_cycle(self):
     it = declarations.Iterator([1, 2])
     self.assertEqual(1, it.evaluate(0, None, False))
     self.assertEqual(2, it.evaluate(1, None, False))
     self.assertEqual(1, it.evaluate(2, None, False))
     self.assertEqual(2, it.evaluate(3, None, False))
     self.assertEqual(1, it.evaluate(4, None, False))
     it.reset()
     self.assertEqual(1, it.evaluate(5, None, False))
     self.assertEqual(2, it.evaluate(6, None, False))
Ejemplo n.º 5
0
 def test_initial_reset(self):
     it = declarations.Iterator([1, 2])
     it.reset()
Ejemplo n.º 6
0
 def test_getter(self):
     it = declarations.Iterator([(1, 2), (1, 3)], getter=lambda p: p[1])
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=0))
     self.assertEqual(3, utils.evaluate_declaration(it, force_sequence=1))
     self.assertEqual(2, utils.evaluate_declaration(it, force_sequence=2))
     self.assertEqual(3, utils.evaluate_declaration(it, force_sequence=3))
Ejemplo n.º 7
0
 def test_getter(self):
     it = declarations.Iterator([(1, 2), (1, 3)], getter=lambda p: p[1])
     self.assertEqual(2, it.evaluate(0, None, False))
     self.assertEqual(3, it.evaluate(1, None, False))
     self.assertEqual(2, it.evaluate(2, None, False))
     self.assertEqual(3, it.evaluate(3, None, False))