public void DecompileGetConstants() { Block block = new Block(); block.CompileGetConstant(1); block.CompileGetConstant("foo"); BlockDecompiler decompiler = new BlockDecompiler(block); var result = decompiler.Decompile(); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("GetConstant 1", result[0]); Assert.AreEqual("GetConstant \"foo\"", result[1]); }
public void DecompileGetIntegerConstantAsString() { Block block = new Block(); block.CompileGetConstant(1); BlockDecompiler decompiler = new BlockDecompiler(block); var result = decompiler.DecompileAsString(); Assert.IsNotNull(result); Assert.AreEqual("{ GetConstant 1 }", result); }
public void DecompileGetIntegerConstant() { Block block = new Block(); block.CompileGetConstant(1); BlockDecompiler decompiler = new BlockDecompiler(block); var result = decompiler.Decompile(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("GetConstant 1", result[0]); }
public void CompileAndExecuteNewDotNetObject() { Block block; block = new Block(); block.CompileGetDotNetType("System.IO.FileInfo"); block.CompileGetConstant("FooBar.txt"); block.CompileSend("!new:"); block.CompileByteCode(ByteCode.ReturnPop); object obj = block.Execute(null, null); Assert.IsNotNull(obj); Assert.IsInstanceOfType(obj, typeof(System.IO.FileInfo)); }
public void CompileGlobal() { Block block; block = new Block(); block.CompileGetConstant(10); block.CompileSet("Global"); Assert.AreEqual("Global", block.GetGlobalName(0)); }
public void CompileAndRunWithGlobal() { Block block; block = new Block(); block.CompileGetConstant(10); block.CompileSet("Global"); Machine machine = new Machine(); block.Execute(machine, null); Assert.AreEqual(10, machine.GetGlobalObject("Global")); }