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