Esempio n. 1
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);
 }
Esempio n. 2
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);
 }
Esempio n. 3
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());
 }
Esempio n. 4
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);
 }
Esempio 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")));
 }
Esempio n. 6
0
 @Test
 public void testInt() throws JellyException {
   Future<ExecutionContext> f = this.runtime.eval("test", Int.mkInt(0));
   ExecutionContext ctx = f.get();
   assertEquals(0, ctx.sp);
   assertEquals(((Int) ctx.s[0]).i, 0);
 }
Esempio n. 7
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);
 }
Esempio n. 8
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);
 }
Esempio n. 9
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);
 }
Esempio n. 10
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);
 }
Esempio n. 11
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()));
 }
Esempio n. 12
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);
 }
Esempio n. 13
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");
 }
Esempio n. 14
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");
 }
Esempio n. 15
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");
 }
Esempio n. 16
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);
 }
Esempio n. 17
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);
   }
 }
Esempio n. 18
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);
   }
 }
Esempio n. 19
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);
 }
Esempio n. 20
0
 @Test
 public void testPrintEmptyList() throws JellyException {
   String funId = IdUtils.qualify(this.prn, "printEmptyList");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   f.get();
 }