public void TestCyclicPointer01() { DebugRunner fsr = new DebugRunner(core); // Execute and verify the main script in a debug session fsr.PreStart( @" class Obj { x : var; constructor Obj() { x = null; } } p = Obj.Obj(); p.x = p; // Assign the member x to its own 'this' pointer. This creates a cycle m = p.x; "); DebugRunner.VMState vms = fsr.StepOver(); vms = fsr.StepOver(); vms = fsr.StepOver(); // Test the heap contains a cycle Assert.IsTrue(ProtoCore.Utils.HeapUtils.IsHeapCyclic(core)); }
private void RunWithDebuggerGuts() // On background thread, no UI access. { try { switch (workerParams.RequestedRunMode) { case RunMode.RunTo: workerParams.CurrentVmState = debugRunner.Run(); break; case RunMode.StepNext: workerParams.CurrentVmState = debugRunner.StepOver(); break; case RunMode.StepIn: workerParams.CurrentVmState = debugRunner.Step(); break; case RunMode.StepOut: workerParams.CurrentVmState = debugRunner.StepOut(); break; default: { string runMode = workerParams.RequestedRunMode.ToString(); throw new InvalidOperationException("Unsupported RunMode: " + runMode); } } } catch (Exception exception) { switch (exception.GetType().ToString()) { case "ProtoScript.Runners.DebugRunner+EndofScriptException": case "ProtoScript.Runners.DebugRunner.EndofScriptException": case "ProtoScript.Runners.DebugRunner+RunnerNotInitied": workerParams.ExecutionEnded = true; break; default: workerParams.ExecException = exception; break; } } }
internal static ProtoCore.Core DebugRunnerStepOver(string code, out RuntimeCore runtimeCore) { //Internal setup ProtoCore.Core core; DebugRunner fsr; ProtoScript.Config.RunConfiguration runnerConfig; // Specify some of the requirements of IDE. var options = new ProtoCore.Options(); options.ExecutionMode = ProtoCore.ExecutionMode.Serial; options.SuppressBuildOutput = false; options.GCTempVarsOnDebug = false; string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\"; options.IncludeDirectories.Add(testPath); core = new ProtoCore.Core(options); core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core)); core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core)); runnerConfig = new ProtoScript.Config.RunConfiguration(); runnerConfig.IsParrallel = false; fsr = new DebugRunner(core); DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper()); CLRModuleType.ClearTypes(); //Run fsr.PreStart(code, runnerConfig); DebugRunner.VMState vms = null; while (!fsr.isEnded) { vms = fsr.StepOver(); } runtimeCore = fsr.runtimeCore; return(core); }
public void RunPropertyChangedTest() { string code = @"import (Foo from ""ProtoTest.dll""); foo = Foo.GetInstance(); id = foo.ID; t = 1; "; runner_.PreStart(code, runconfig_); Foo fooSingleton = Foo.GetInstance(); fooSingleton.ID = 101; DebugRunner.VMState vms = runner_.StepOver(); vms = runner_.StepOver(); vms = runner_.StepOver(); Obj val = GetWatchValue(core_, @"id"); Assert.IsTrue((Int64)val.Payload == 101); // As Foo implements INotifyPropertyChanged interface, the property // change notification should be propagated back to DS virtual // machine so that all DS objects that depend on that property // should be updated. fooSingleton.ID = 202; // So it is expected to reexecute "id = foo.ID", that is line 3. vms = runner_.StepOver(); Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); // Expect 'id' has been updated to 202 vms = runner_.StepOver(); val = GetWatchValue(core_, @"id"); Assert.IsTrue((Int64)val.Payload == 202); }