Skip to content

Commit 4c77ebf

Browse files
committed
Adding one more test for StopIteration.
1 parent 433a6d7 commit 4c77ebf

File tree

1 file changed

+25
-0
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests

1 file changed

+25
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_list.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,28 @@ def __index__(self):
355355

356356
a.insert(False, -1)
357357
self.assertEqual([-1,0,1], a)
358+
359+
def testStopIteration(self):
360+
l = [1.0]
361+
i = l.__iter__()
362+
i.__next__()
363+
self.assertRaises(StopIteration, i.__next__)
364+
l.append(2.0)
365+
self.assertRaises(StopIteration, i.__next__)
366+
l.append('a')
367+
self.assertRaises(StopIteration, i.__next__)
368+
369+
l = []
370+
i = l.__iter__()
371+
self.assertRaises(StopIteration, i.__next__)
372+
l.append(2.0)
373+
self.assertRaises(StopIteration, i.__next__)
374+
375+
l = ['a']
376+
i = l.__iter__()
377+
i.__next__()
378+
self.assertRaises(StopIteration, i.__next__)
379+
l.append('b')
380+
self.assertRaises(StopIteration, i.__next__)
381+
l.append(3)
382+
self.assertRaises(StopIteration, i.__next__)

0 commit comments

Comments
 (0)