Fix iterating over an empty list.

This commit is contained in:
Bob Nystrom
2014-02-14 17:24:06 -08:00
parent e519ecbc49
commit ca7ff222fe
4 changed files with 25 additions and 22 deletions
+3
View File
@@ -5,3 +5,6 @@ IO.print(a.iterate(1)) // expect: 2
IO.print(a.iterate(2)) // expect: 3
IO.print(a.iterate(3)) // expect: false
IO.print(a.iterate(-1)) // expect: false
// Nothing to iterate in an empty list.
IO.print([].iterate(null)) // expect: false
@@ -13,3 +13,6 @@ IO.print(d) // expect: [1, 2, 3, 4, 5, 6]
IO.print(e) // expect: [1, 2, 3]
IO.print(f) // expect: [1, 2, 3]
IO.print(g) // expect: []
// Doesn't modify original list.
IO.print(a) // expect: [1, 2, 3]