@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 }
@Test public void test() { inline(new AbstractTask() { @Override public void run(Interval current) throws Exception { current.newAsyncChild(new Producer()); } }); for(int i = 0; i < MAX; i++) assertEquals(i, consumed.get(i).intValue()); }
@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); } }); }