예제 #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();
 }