Exemplo n.º 1
0
 @Test
 public void testHandle() throws JellyException {
   String funId = IdUtils.qualify(this.exn, "handle");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(6, ((Int) ctx.getWhnf()).i);
 }
Exemplo n.º 2
0
 @Test
 public void testPolyInt() throws JellyException {
   String funId = IdUtils.qualify(this.poly, "polyInt");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(42, ((Int) ctx.getWhnf()).i);
 }
Exemplo n.º 3
0
 @Test
 public void testTrickyMatch1() throws JellyException {
   String funId = IdUtils.qualify(this.bar, "trickyMatch1");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(-1, ((Int) ctx.getWhnf()).i);
 }
Exemplo n.º 4
0
 @Test
 public void testPrintFalse() throws JellyException {
   String funId = IdUtils.qualify(this.prn, "printFalse");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(TyCon.mkzTyCon(0), ctx.getWhnf());
 }
Exemplo n.º 5
0
 @Test
 public void testBigIntArith() throws JellyException {
   String funId = IdUtils.qualify(this.foo, "bigIntArith");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   assertTrue(
       ((BigInt) f.get().getWhnf(0)).i.equals(new BigInteger("335385764583214543694543533")));
 }
Exemplo n.º 6
0
 @Test
 public void testQuickSum() throws JellyException {
   String funId = IdUtils.qualify(this.baz, "quickSum");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(21, ((Int) ctx.getWhnf()).i);
 }
Exemplo n.º 7
0
 @Test
 public void testAddInt() throws JellyException {
   String funId = IdUtils.qualify(this.baz, "addInt");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(3, ((Int) ctx.s[0]).i);
 }
Exemplo n.º 8
0
 @Test
 public void testPolyDbl() throws JellyException {
   String funId = IdUtils.qualify(this.poly, "polyDbl");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(Math.PI, ((Double) ctx.getWhnf()).d);
 }
Exemplo n.º 9
0
 @Test
 public void testBottomCatched() throws JellyException {
   String funId = IdUtils.qualify(this.exn, "bottomCatched");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals("Ok", ((Str) ctx.getWhnf()).s);
 }
Exemplo n.º 10
0
 @Test
 public void testWhnfUpd() throws JellyException {
   String funId = IdUtils.qualify(this.baz, "whnfUpd");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(0, ((TyCon) ctx.s[0]).getTag());
   assertTrue(App.class.isAssignableFrom(((TyCon) ctx.s[0]).getNodes()[0].getClass()));
 }
Exemplo n.º 11
0
 @Test
 public void testNApp() throws JellyException {
   String funId = IdUtils.qualify(this.foo, "nApp");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(ctx.sp, 0);
   assertEquals(((Int) ctx.s[0]).i, 2);
 }
Exemplo n.º 12
0
 @Test
 public void testMain() throws JellyException {
   String funId = IdUtils.qualify(this.foo, "main");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(ctx.sp, 0);
   assertEquals(((Code) ctx.s[0]).getFunctionName(), "id");
 }
Exemplo n.º 13
0
 @Test
 public void testApp() throws JellyException {
   String funId = IdUtils.qualify(this.foo, "app");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(ctx.sp, 1);
   assertEquals(((Int) ctx.s[0]).i, 1);
   assertEquals(((Code) ctx.s[1]).getFunctionName(), "swap");
 }
Exemplo n.º 14
0
 @Test
 public void testTooFewArgs() throws JellyException {
   String funId = IdUtils.qualify(this.bar, "whnfTest");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   assertEquals(ctx.sp, 1);
   assertEquals(((Int) ctx.s[0]).i, 1);
   assertEquals(((Code) ctx.s[1]).getFunctionName(), "_const");
 }
Exemplo n.º 15
0
 @Test
 public void testTrickyMatch() throws JellyException {
   String funId = IdUtils.qualify(this.bar, "trickyMatch");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   ExecutionContext ctx = f.get();
   TyCon t = (TyCon) ctx.getWhnf();
   assertEquals(0, t.getTag());
   assertEquals(1, ((Int) t.getNodes()[0]).i);
   assertEquals(2, ((Int) t.getNodes()[1]).i);
 }
Exemplo n.º 16
0
 @Test
 public void testBottom() {
   try {
     String funId = IdUtils.qualify(this.exn, "bottom");
     Future<ExecutionContext> f = this.runtime.eval(funId);
     f.get();
     assertTrue(false);
   } catch (JellyException e) {
     assertTrue(e.getCause() instanceof JellyRuntimeException);
   }
 }
Exemplo n.º 17
0
 @Test
 public void testRaise() {
   String funId = IdUtils.qualify(this.exn, "raise");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   try {
     // f.get() must raise an exception
     f.get();
     assertTrue(false);
   } catch (JellyException e) {
     // We expect to get here
     assertTrue(e.getCause() instanceof JellyRuntimeException);
   }
 }
Exemplo n.º 18
0
 @Test
 public void testTorture1() throws JellyException {
   String funId = IdUtils.qualify(this.foo, "startTorture1");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   assertTrue(((Int) f.get().getWhnf(0)).i == 1);
 }
Exemplo n.º 19
0
 @Test
 public void testPrintEmptyList() throws JellyException {
   String funId = IdUtils.qualify(this.prn, "printEmptyList");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   f.get();
 }