[Test]public void testMakeSureThatJsrWhichCallsItselfDoesNotRecurseForever() { Block main = new Block("main"); Block sub = new Block("sub"); main.addOp(new JMP(0, sub)); main.addOp(new JMP(0, sub)); sub.addOp(new RetSub(1)); sub.addNextBlock(main); Stack2Turing converter = new Stack2Turing(main); converter.translate(); // Assert no exceptions and that we don't get into infinite recursion }
[Test]public void testJSRMultiBlock() { Block main = new Block("main"); Block sub = new Block("sub"); Block sub1 = new Block("sub1"); Block sub2 = new Block("sub2"); sub.addNextBlock(sub1); sub1.addNextBlock(sub2); main.addOp(new JMP(0, sub)); Stack2Turing converter = new Stack2Turing(main); converter.translate(); // Assert no exceptions }
[Test]public void testJSRSingleBlock() { Block main = new Block("main"); Block sub = new Block("sub"); main.addOp(new Load(0, new Variable("this", ClrType.Object, false, false))); main.addOp(new JMP(0, sub)); main.addOp(new PutField(0, new FieldInfo(null, "a", ClrType.Int32, false, false, false))); sub.addOp(new Load(0, new Constant(1, ClrType.Int32))); sub.addOp(new Return(0, ClrType.Void)); Stack2Turing converter = new Stack2Turing(main); IList<Operation> operations = converter.translate(); Assert.AreEqual(1, operations.Count); Assert.AreEqual("null::a{System.Int32} <- 1{System.Int32}", operations[0].ToString()); }