public void TestInterpreterChain() { var p = new MockProcess (); var i1 = new Interpreter (p, null); var i2 = new Interpreter (p, i1); i2.ops.Add (new LoadConstant (anInteger)); i2.ops.Add (new Return ()); i2.Resume (); Assert.AreEqual (i1, p.i); var peek = i1.stack.Peek (); Assert.AreEqual (typeof(NativeInteger), peek.GetType ()); Assert.AreEqual (anInteger, ((NativeInteger)peek).Value); }
public void TestInterpreterSumLambda() { var p = new MockProcess (); var i = new Interpreter (p, null); for (int x = 0; x < 1000; x++) { i.ops.Add (new LoadConstant (2)); i.ops.Add (new LoadConstant (3)); i.ops.Add (new SumLambda ()); i.Resume (); i.stack.Pop (); } var peek = i.stack.Peek (); Assert.AreEqual (typeof(NativeInteger), peek.GetType ()); Assert.AreEqual (5, ((NativeInteger)peek).Value); }
public void TestLoadStore() { var p = new MockProcess(); var i = new Interpreter(p, null); i.ops.Add(new LoadConstant(anInteger)); i.ops.Add(new StoreLocalVar("temp")); i.ops.Add(new LoadLocalVar("temp")); i.Resume(); Assert.AreEqual(typeof(NativeInteger), i.stack.Peek().GetType()); Assert.AreEqual(anInteger, ((NativeInteger) i.stack.Peek()).Value); }