@Test
  public void testIllegalToCreateChildEvenWithEdgeToEnd() {
    final AtomicInteger integer = new AtomicInteger();
    try {
      Intervals.inline(
          new AbstractTask("a") {
            @Override
            public void run(Interval subinterval) {
              final Interval a = subinterval.newAsyncChild(new TestInterval.IncTask("a", integer));

              subinterval.newAsyncChild(
                  new AbstractTask("b") {
                    @Override
                    public void run(Interval current) {
                      a.newAsyncChild(new TestInterval.IncTask("a1", integer, 10));
                    }
                  });
            }
          });
      Assert.fail();
    } catch (RethrownException e) {
      Assert.assertTrue(e.getCause() instanceof IntervalException.MustHappenBefore);
    }
    Assert.assertEquals(1, integer.get()); // a should execute
  }
 private void addIllegalEdge(Point from, Point to, Class<? extends IntervalException> err) {
   try {
     Intervals.addHb(from, to);
     Assert.fail("No error");
   } catch (IntervalException e) {
     Assert.assertEquals("Wrong class", err, e.getClass());
   }
 }
		@Override
		public void run(Interval subinterval) {
			Interval prevConsumer = null;
			for(int i = 0; i < MAX; i++) {
				Interval consumer = subinterval.newAsyncChild(new Consumer(i));
				Intervals.addHbIfNotNull(prevConsumer, consumer);
				prevConsumer = consumer;
			}
		}
  @Test
  public void testCE() {
    Intervals.inline(
        new AbstractTask("a") {
          @Override
          public String toString() {
            return "a";
          }

          @Override
          public void run(Interval a) {
            Interval a1 = a.newAsyncChild(new EmptyTask("a1"));
            Interval a12 = a1.newAsyncChild(new EmptyTask("a1"));
            addIllegalEdge(a12.getEnd(), a1.getStart(), IntervalException.Cycle.class);
          }
        });
  }
 private void addLegalEdge(Point from, Point to) {
   Intervals.addHb(from, to);
 }