Commit 66c4a807 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #176 from dagar/master

fixes #169 - allow a negative step in xrange
parents 0db55807 9031f39f
......@@ -43,8 +43,12 @@ public:
static bool xrangeIteratorHasnextUnboxed(Box* s) __attribute__((visibility("default"))) {
assert(s->cls == xrange_iterator_cls);
BoxedXrangeIterator* self = static_cast<BoxedXrangeIterator*>(s);
assert(self->xrange->step > 0);
return self->cur < self->xrange->stop;
if (self->xrange->step > 0) {
return self->cur < self->xrange->stop;
} else {
return self->cur > self->xrange->stop;
}
}
static Box* xrangeIteratorHasnext(Box* s) __attribute__((visibility("default"))) {
......
......@@ -6,3 +6,12 @@
for i in xrange(1000):
print i
for i in xrange(10, 1, -1):
print i
for i in xrange(10, -10, -3):
print i
for i in xrange(0):
print i
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment