blob: e00c03773fc8f6a204099ea8feca8f47a8388c08 [file] [log] [blame]
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/**
* @assertion bool isNotEmpty
* @description Checks that [isNotEmpty] returns [false] if [Iterator] is empty
* or [true] otherwise.
* @author iarkh@unipro.ru
*/
import "../../../Utils/expect.dart";
import "dart:collection";
class NaturalIterator implements Iterator<int> {
int limit;
int _current = 0;
NaturalIterator(this.limit);
bool moveNext() {
if (_current < limit) {
_current++;
return true;
} else {
return false;
}
}
int get current => _current;
}
class MyIterable extends Object with IterableMixin {
int _limit;
MyIterable(this._limit);
Iterator<int> get iterator {
return new NaturalIterator(_limit);
}
}
main() {
Expect.isTrue(new MyIterable(0).isEmpty);
Expect.isFalse(new MyIterable(10).isEmpty);
}