Iterators { public static Iterator<Integer> intRangeE(final int start, final int end) { return new Iter<Integer>() { private int i = start; @Override public boolean hasNext() { return i < end; } @Override public Integer next() { if (hasNext()) { int r = i; i++; return r; } else { throw new NoSuchElementException(); } } }; } private  Iterators(); static Iterator<Integer> intRangeE(final int start, final int end); static Iterator<A> constant(final A a);  }
@Test public void testIntRangeE1() { assertFalse(intRangeE(0, 0).hasNext()); assertTrue(intRangeE(0, 1).hasNext()); assertEquals(10, toList(intRangeE(0, 10)).size()); }
@Test(expected = NoSuchElementException.class) public void testIntRangeE2() { intRangeE(0, 0).next(); }