Skip to content

Commit 35a75f8

Browse files
committed
add test for MatchesIterator that would have caught bug introduced in <<cset e8f9e8f910fd>>
1 parent d301c82 commit 35a75f8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bpython/test/test_repl.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,28 @@ def test_forward(self):
5252
self.history.forward()
5353
self.assertEqual(self.history.forward(), '#999')
5454

55+
def test_MatchesIterator(self):
56+
matches = ['bobby', 'bobbies', 'bobberina']
5557

58+
matches_iterator = repl.MatchesIterator(
59+
current_word='bob',
60+
matches=matches)
5661

62+
# should be falsey before we enter (i.e. 'not active')
63+
self.assertEqual(bool(matches_iterator), False)
64+
65+
matched = []
66+
for i, x in enumerate(matches_iterator):
67+
matched.append(x)
68+
if i == 8:
69+
break
70+
71+
self.assertEqual(matched, matches * 3)
72+
73+
# should be truthy once we have an active match
74+
self.assertEqual(bool(matches_iterator), True)
75+
76+
self.assertEqual(matches_iterator.current(), (matches * 3)[-1])
5777

5878
if __name__ == '__main__':
5979
unittest.main()

0 commit comments

Comments
 (0)