示例#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);
 }
示例#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);
 }
示例#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());
 }
示例#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);
 }
示例#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")));
 }
示例#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);
 }
示例#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);
 }
示例#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);
 }
示例#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);
 }
示例#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);
 }
示例#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()));
 }
示例#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);
 }
示例#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");
 }
示例#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");
 }
示例#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");
 }
示例#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);
 }
示例#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);
   }
 }
示例#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);
   }
 }
示例#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);
 }
示例#20
0
 @Test
 public void testPrintEmptyList() throws JellyException {
   String funId = IdUtils.qualify(this.prn, "printEmptyList");
   Future<ExecutionContext> f = this.runtime.eval(funId);
   f.get();
 }