Пример #1
0
        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);
        }
Пример #2
0
        internal static ProtoCore.Core DebugRunnerRunOnly(string code, out RuntimeCore runtimeCore)
        {
            ProtoCore.Core core;
            DebugRunner    fsr;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode     = ProtoCore.ExecutionMode.Serial;
            options.GCTempVarsOnDebug = false;

            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            options.IncludeDirectories.Add(testPath);

            core = new ProtoCore.Core(options);
            core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));

            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code);
            DebugRunner.VMState vms = null;

            vms         = fsr.Run();
            runtimeCore = fsr.runtimeCore;
            return(core);
        }
Пример #3
0
        internal static ProtoCore.Core DebugRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(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;

            vms = fsr.Run();

            return(core);
        }
        //Test "SomeNulls()"
        public void ComputeReducedParams()
        {
            string code =
                @"
                      a = {1,2};
                      b = {3,4};
                  "                                                                                     ;

            //Run
            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;
            vms = fsr.Run();
            var mirror             = vms.mirror;
            List <StackValue> args = new List <StackValue>();

            args.Add(mirror.GetRawFirstValue("a"));
            args.Add(mirror.GetRawFirstValue("b"));
            List <ReplicationInstruction> ris = new List <ReplicationInstruction>();

            ris.Add(
                new ReplicationInstruction()
            {
                ZipIndecies = new List <int> {
                    0, 1
                },
                Zipped = true
            }
                );
            List <List <StackValue> > combin = ProtoCore.Lang.Replication.Replicator.ComputeAllReducedParams(args, ris, core);

            Assert.IsTrue(combin[0][0].opdata == 1);
            Assert.IsTrue(combin[0][1].opdata == 3);
            Assert.IsTrue(combin[1][0].opdata == 2);
            Assert.IsTrue(combin[1][1].opdata == 4);
        }
Пример #5
0
        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));
        }
Пример #6
0
        public void ComputeReducedParams()
        {
            // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4115
            string code =
                @"
                      a = [1,2];
                      b = [3,4];
                  ";

            //Run
            fsr.PreStart(code);
            DebugRunner.VMState vms = null;
            vms = fsr.Run();
            var mirror             = vms.mirror;
            List <StackValue> args = new List <StackValue>();

            args.Add(mirror.GetRawFirstValue("a"));
            args.Add(mirror.GetRawFirstValue("b"));
            List <ReplicationInstruction> ris = new List <ReplicationInstruction>();

            ris.Add(
                new ReplicationInstruction()
            {
                ZipIndecies = new List <int> {
                    0, 1
                },
                Zipped = true
            }
                );
            runtimeCore = fsr.runtimeCore;
            List <List <StackValue> > combin = ProtoCore.Lang.Replication.Replicator.ComputeAllReducedParams(args, ris, runtimeCore);

            Assert.IsTrue(combin[0][0].IntegerValue == 1);
            Assert.IsTrue(combin[0][1].IntegerValue == 3);
        }
Пример #7
0
        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);
        }
Пример #8
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/ Dictionary <int, List <string> > map, bool watchNestedMode = false)
        {
            //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;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }


            core = new ProtoCore.Core(options);

            // Use the InjectionExecutive to overload POP and POPM
            // as we still need the symbol names and line nos. in debug mode for comparisons
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            fsr.PreStart(code, runnerConfig);

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int    lineAtPrevBreak = -1;
            string symbolName      = null;

            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode    opCode = OpCode.NONE;
                DebugInfo debug  = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug  = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (core.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, ci);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            core.Cleanup();
        }