1 | #!/usr/bin/env python2
|
2 | """
|
3 | val_ops_test.py: Tests for val_ops.py
|
4 | """
|
5 | from __future__ import print_function
|
6 |
|
7 | import unittest
|
8 |
|
9 | from _devbuild.gen.value_asdl import value
|
10 | from ysh import val_ops # module under test
|
11 |
|
12 |
|
13 | class IteratorTest(unittest.TestCase):
|
14 |
|
15 | def testIterator(self):
|
16 | a = ['a', 'b']
|
17 |
|
18 | it = val_ops.ArrayIter(a)
|
19 | self.assertEqual('a', it.FirstValue().s)
|
20 | it.Next()
|
21 |
|
22 | self.assertEqual('b', it.FirstValue().s)
|
23 | it.Next()
|
24 |
|
25 | self.assertEqual(None, it.FirstValue())
|
26 |
|
27 | mylist = value.List([value.Str('x'), value.Str('y')])
|
28 |
|
29 | it = val_ops.ListIterator(mylist)
|
30 | self.assertEqual('x', it.FirstValue().s)
|
31 | x = it.Next()
|
32 |
|
33 | self.assertEqual('y', it.FirstValue().s)
|
34 | x = it.Next()
|
35 |
|
36 | self.assertEqual(None, it.FirstValue())
|
37 |
|
38 |
|
39 | if __name__ == '__main__':
|
40 | unittest.main()
|