static void TestContainer() { { var testbox = new TestBox(); testbox.RunFile("Map.pho") .CheckGlobalVarMatchKind("map", ValueKind.NativeClassInstance) .CheckGlobalVarMatchValue("x", 1678) .CheckGlobalVarMatchValue("c", 1) .CheckGlobalVarMatchKind("sugar", ValueKind.NativeClassInstance) .CheckGlobalVarMatchValue("sugarlen", 2) .CheckGlobalVarMatchValue("sugarA", 12345) .CheckGlobalVarMatchValue("sugarB", "world"); } { var testbox = new TestBox(); testbox.RunFile("Array.pho") .CheckGlobalVarMatchKind("arr", ValueKind.NativeClassInstance) .CheckGlobalVarMatchValue("x", 120) .CheckGlobalVarMatchValue("g", 120) .CheckGlobalVarMatchValue("count", 1) .CheckGlobalVarMatchKind("v", ValueKind.Nil) .CheckGlobalVarMatchValue("ok", false) .CheckGlobalVarMatchKind("sugar", ValueKind.NativeClassInstance) .CheckGlobalVarMatchValue("sugarlen", 2) .CheckGlobalVarMatchValue("sugar1", 1) .CheckGlobalVarMatchValue("sugar2", 2); } }
static void TestDelegateExecute() { new TestBox().RegisterRunFile(delegate(Executable exe) { exe.RegisterNativeClass(typeof(DelegateTest), "DelegateTest"); }, "Delegate.pho") .CheckGlobalVarMatchValue("a", 3); { var testbox = new TestBox(); testbox.CompileFile("Execute.pho"); //testbox.VM.ShowDebugInfo = Test; var retValue = testbox.VM.Execute(testbox.Exe, "main", "foo", new object[] { 1, 2 }, 2); if (retValue.Length != 2) { testbox.Error("ret value not match"); } if ((System.Int32)retValue[0] != 3) { testbox.Error("ret value not match"); } if (!retValue[1].GetType().IsClass) { testbox.Error("ret value not match"); } } }