@Test
public void testLazyMap() {

  final boolean[] applied = {false};
  IteratorMonadic<Integer> im = mlazy(asList(1, 2, 3, 4, 5))
          .map(new Function<Integer, Integer>() {
            @Override
            public Integer apply(Integer i) {
              applied[0] = true;
              return i * i;
            }
          })
          .map(new Function<Integer, Integer>() {
            @Override
            public Integer apply(Integer i) {
              applied[0] = true;
              return i + i;
            }
          });
  assertFalse(applied[0]);
  im.value();
  assertFalse(applied[0]);
  List<Integer> eval = im.eval();
  assertTrue(applied[0]);
  assertArrayEquals(new Integer[]{2, 8, 18, 32, 50}, eval.toArray(new Integer[]{}));
  // test empty input
  assertTrue(Collections.toList(
          mlazy(Collections.<Integer>nil()).map(Functions.<Integer>identity()).value()
  ).isEmpty());
}