use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.
the class CatchTest method testCatch2.
@Test
public void testCatch2() {
results.clear();
try {
Fiber co = new Fiber((String) null, null, new Callable1());
exec(co);
results.add("B");
exec(co);
results.add("D");
exec(co);
} finally {
System.out.println(results);
}
assertEquals(5, results.size());
assertEquals(Arrays.asList("A", "B", "C", "D", "E"), results);
}
use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.
the class CatchTest method testCatch.
@Test
public void testCatch() {
results.clear();
try {
Fiber co = new Fiber((String) null, null, new Runnable1());
exec(co);
results.add("B");
exec(co);
results.add("D");
exec(co);
results.add("E");
exec(co);
results.add("F");
exec(co);
results.add("G");
exec(co);
results.add("I");
} finally {
System.out.println(results);
}
assertEquals(13, results.size());
assertEquals(Arrays.asList("A", "B", "C", "D", "cnt=0", "E", "not thrown", "F", "cnt=1", "G", "called second time", "H", "I"), results);
}
use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.
the class DoubleTest method testDouble.
@Test
public void testDouble() {
Fiber co = new Fiber((String) null, null, this);
TestsHelper.exec(co);
assertEquals(0, result, 1e-8);
boolean res = TestsHelper.exec(co);
assertEquals(1, result, 1e-8);
assertEquals(res, true);
}
use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.
the class FinallyTest method testFinally.
@Test
public void testFinally() {
results.clear();
try {
Fiber co = new Fiber((String) null, null, this);
exec(co);
results.add("B");
exec(co);
results.add("D");
exec(co);
results.add("H");
exec(co);
} finally {
System.out.println(results);
}
assertEquals(9, results.size());
assertEquals("A", results.get(0));
assertEquals("B", results.get(1));
assertEquals("C", results.get(2));
assertEquals("D", results.get(3));
assertEquals("E", results.get(4));
assertEquals("F", results.get(5));
assertEquals("G", results.get(6));
assertEquals("H", results.get(7));
assertEquals("I", results.get(8));
}
use of co.paralleluniverse.fibers.Fiber in project quasar by puniverse.
the class InstrumentationOptimizerTest method testDontSkipForwardsWithLoopBefore.
@Test
public void testDontSkipForwardsWithLoopBefore() throws InterruptedException, SuspendExecution, ExecutionException {
new Fiber(new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
dontSkipForwardsWithLoopBefore();
}
}).start().join();
assertFalse(isOptimized("skipForwardsWithLoopBefore"));
}
Aggregations