Пример #1
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();

            // Assuming current directory in test/debug mode is "...\Dynamo\bin\AnyCPU\Debug"
            ExecutionMirror mirror = runner.LoadAndExecute(@"..\..\..\test\core\dsevaluation\DSFiles\test.ds", core);

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Пример #2
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"C:\Users\Yu\dev\github\test.ds", core);

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Пример #3
0
 public void Setup()
 {
     core = new ProtoCore.Core(new ProtoCore.Options());
     core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
     core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
     coreRunner = new ProtoScript.Runners.ProtoScriptTestRunner();
 }
Пример #4
0
        public void T033_Defect_1467187_Update_In_class_collection_property_2()
        {
            String code =
                @"
class B
{    
    a1 : int;
    a2 : double[];
    constructor B (a:int, b : double[])    
    {        
        a1 = a;
        a2 = b;
    }
}
b1 = B.B ( 1, {1.0, 2.0} );
test1 = b1.a2[0];
b1.a2[0] = b1.a2[1];
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("test1", 2.0);
        }
Пример #5
0
        public void T032_Defect_1467335_Update_In_class_Constructor()
        {
            String code =
                @"
class A
{
    b : int[] = { 0, 1, 2, 3 };
    
    def foo (i:int ) 
    {
        b[i] = b[i] + 1;
        return = b;
    }

}

i = 1..2;
e1 = A.A().foo(i);
i = 0..2;
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("e1", new Object[] { new Object[] { 1, 1, 2, 3 }, new Object[] { 1, 2, 2, 3 }, new Object[] { 1, 2, 3, 3 } });
        }
Пример #6
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code, out RuntimeCore runtimeCore)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = 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));

            fsr = new ProtoScriptTestRunner();

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

            //Run

            fsr.Execute(code, core, out runtimeCore);

            return core;
        }
Пример #7
0
        public void TestCompilerAndRuntimeComponent01()
        {

            String code =
@"
a = 10;
";
            // Compile core
            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();

            // Compiler instance
            ProtoCore.DSASM.Executable dsExecutable;
            bool compileSucceeded = runner.CompileMe(code, core, out dsExecutable);
            Assert.IsTrue(compileSucceeded == true);
            
            // Pass compile data to the runtime 
            RuntimeCore runtimeCore = new RuntimeCore(core.Heap);
            runtimeCore.SetProperties(core.Options, dsExecutable);

            // Runtime
            ExecutionMirror mirror = runner.ExecuteMe(runtimeCore);
            Obj o = mirror.GetValue("a");
Пример #8
0
        internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code,
            Dictionary<int, List<string>> map, string geometryFactory,
            string persistentManager, out ExecutionMirror mirror, out RuntimeCore runtimeCoreOut)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            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.WatchTestMode = true;

            // 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()"
            includePath = Path.GetDirectoryName(includePath);
            options.IncludeDirectories.Add(includePath);

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            core = new ProtoCore.Core(options);

            core.Configurations.Add(ConfigurationKeys.GeometryXmlProperties, true);
            //core.Configurations.Add(ConfigurationKeys.GeometryFactory, geometryFactory);
            //core.Configurations.Add(ConfigurationKeys.PersistentManager, persistentManager);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            //core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.BuildStatus.MessageHandler = fs;

            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;

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

            //Run

            mirror = fsr.Execute(code, core, out runtimeCoreOut);

            //sw.Close();

            return core;
        }
Пример #9
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif

#if __RUN_TESTFILE
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"D:\jun\AutodeskResearch\git\designscript\Scripts\jun.ds", core);
#else
            // Insert test cases here

            //ProtoTest.LiveRunner.MicroFeatureTests test = new ProtoTest.LiveRunner.MicroFeatureTests();
            //test.Setup();
            //test.TestPythonCodeExecution();

            ProtoTest.Associative.MicroFeatureTests test = new ProtoTest.Associative.MicroFeatureTests();
            test.Setup();
           test.TestUpdateRedefinition01();

            //IntegrationTests.IncrementingTraceTests test = new IntegrationTests.IncrementingTraceTests();
            //test.Setup();
            //test.IntermediateValueIncrementerIDTestUpdate1DReplicated();

            //ProtoFFITests.CSFFIDispose test = new ProtoFFITests.CSFFIDispose();
            //test.Setup();
            //test.IntermediateValueIncrementerIDTestUpdate1DReplicated();
           // test.Dispose_FFITarget_Overridden();

            //ProtoTest.EventTests.PropertyChangedNotifyTest test = new ProtoTest.EventTests.PropertyChangedNotifyTest();
            //test.Setup();
            //test.RunPropertyChangedNegative();
            

#endif

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Пример #10
0
        private void InitRunner(Options options)
        {
            graphCompiler = GraphToDSCompiler.GraphCompiler.CreateInstance();
            graphCompiler.SetCore(GraphUtilities.GetCore());
            runner = new ProtoScriptTestRunner();

            executionOptions = options;
            InitOptions();
            InitCore();


            taskQueue = new Queue <Task>();

            workerThread = new Thread(new ThreadStart(TaskExecMethod));
            workerThread.IsBackground = true;
            workerThread.Start();

            staticContext = new ProtoCore.CompileTime.Context();
        }
Пример #11
0
        static void Run(string filename, bool verbose)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine("Cannot find file " + filename);
                return;
            }
            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
            core.Options.DumpByteCode = verbose;
            core.Options.Verbose = verbose;
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(filename, core);
        }
Пример #12
0
        public void T033_Defect_1467187_Update_In_class_collection_property_3()
        {
            String code =
                @"
class Point
{
    X : double[];
    
    constructor ByCoordinates( x : double[] )
    {
        X = x;
    
    } 
    def foo ( y :double[])
    {
        X = y + 1;
        [Imperative]
        {
           count = 0;
           for (i in y)
           {
               X[count] = y[count] + X[count];
               count = count + 1;
           }
        }
        return = true;
    }    
    
}

p1 = Point.ByCoordinates({0,0,0,0});
test = p1.X;
dummy = p1.foo({1,1,1,1});
p1.X[0..1] = -1;
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String          errmsg = "DNL-1467401 Rev 4347 : Update issue with collection property in nested imperative scope";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("test", new Object[] { -1, -1, 2, 2 });
        }
Пример #13
0
        public void T031_Defect_1467302()
        {
            String code =
                @"
def foo ( a : int[] ) 
{
    b = a;
    b[0] = b[1] + 1;
    return = b;
}

a = { 0, 1, 2};
e1 = foo(a);
a = { 1, 2};
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("e1", new Object[] { 3, 2 });
        }
Пример #14
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif
#if __RUN_TESTFILE

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


            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"defectverify.ds", core);

#else

            ProtoTest.GraphCompiler.MicroFeatureTests test = new ProtoTest.GraphCompiler.MicroFeatureTests();
            test.Setup();
            test.GraphILTest_Assign02();
            
#endif
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Пример #15
0
        public ProtoVMState PreStart(String source, Dictionary<string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.WebRunner = false;
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;

            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(RunnerCore));
            RunnerCore.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(RunnerCore));

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

            //Validity.Assert(null == ExecutionContext);
            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            //Validity.Assert(null == Runner);
            Runner = new ProtoScriptTestRunner();

            // TODO Jun: Implement run and halt at the first instruction
            //ProtoCore.DSASM.Mirror.ExecutionMirror mirror = null; // runner.Execute(executionContext, RunnerCore);

            return new ProtoVMState(RunnerCore);
        }
Пример #16
0
        public ProtoVMState PreStart(String source, Dictionary <string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(RunnerCore));
            RunnerCore.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(RunnerCore));

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

            //Validity.Assert(null == ExecutionContext);
            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            //Validity.Assert(null == Runner);
            Runner = new ProtoScriptTestRunner();

            // TODO Jun: Implement run and halt at the first instruction
            //ProtoCore.DSASM.Mirror.ExecutionMirror mirror = null; // runner.Execute(executionContext, RunnerCore);

            return(new ProtoVMState(RunnerCore));
        }
Пример #17
0
        public void T033_Defect_1467187_Update_In_class_collection_property()
        {
            String code =
                @"
class Point
{
    X : double;
    
    constructor ByCoordinates( x : double )
    {
        X = x;
    
    } 
def foo ( y )
{
    [Imperative]
    {
        X = y + 1;
    }
    return = true;
}    
    
}

p1 = Point.ByCoordinates(1);
test = p1.X;
dummy = p1.foo(2);
//expected test to update to '3'
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("test", 3.0);
        }
Пример #18
0
        public void T032_Defect_1467335_Update_In_class_Constructor()
        {
            String code =
            @"
            class A
            {
            b : int[] = { 0, 1, 2, 3 };

            def foo (i:int )
            {
            b[i] = b[i] + 1;
            return = b;
            }

            }

            i = 1..2;
            e1 = A.A().foo(i);
            i = 0..2;
            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("e1", new Object[] { new Object[] { 1, 1, 2, 3 }, new Object[] { 1, 2, 2, 3 }, new Object[] { 1, 2, 3, 3 } });
        }
Пример #19
0
        public void T033_Defect_1467187_Update_In_class_collection_property()
        {
            String code =
            @"
            class Point
            {
            X : double;

            constructor ByCoordinates( x : double )
            {
            X = x;

            }
            def foo ( y )
            {
            [Imperative]
            {
            X = y + 1;
            }
            return = true;
            }

            }

            p1 = Point.ByCoordinates(1);
            test = p1.X;
            dummy = p1.foo(2);
            //expected test to update to '3'
            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test", 3.0);
        }
Пример #20
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();

            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 ProtoScriptTestRunner();

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

            //Run

            fsr.Execute(code, core);

            return core;
        }
Пример #21
0
        public void T031_Defect_1467302_2()
        {
            String code =
            @"
            def foo ( a : int[] )
            {
            b = a;
            b[0] = b[1] + 1;
            return = b;
            }

            i = 1..2;
            a = { 0, 1, 2, 3};
            e1 = foo(a[i]);
            i = 0..2;
            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("e1", new Object[] { 2, 1, 2 });
        }
Пример #22
0
 /// <summary>
 /// Re-initializes the LiveRunner to reset the VM 
 /// Used temporarily when importing libraries on-demand during delta execution
 /// Will be deprecated once this is supported by the core language
 /// </summary>
 public void ReInitializeLiveRunner()
 {
     runner = new ProtoScriptTestRunner();
     deltaSymbols = 0;
     InitCore();
     staticContext = new ProtoCore.CompileTime.Context();
     changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
     CLRModuleType.ClearTypes();
 }
Пример #23
0
        public void T032_Defect_1467335_Update_In_class_Constructor()
        {
            String code =
@"
class A
{
    b : int[] = { 0, 1, 2, 3 };
    
    def foo (i:int ) 
    {
        b[i] = b[i] + 1;
        return = b;
    }
}
i = 1..2;
e1 = A.A().foo(i);
i = 0..2;
";
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            //
            // SSA will transform 
            //      e1 = A.A().foo(i);
            //
            //      to
            //
            //      t0 = A.A()
            //      t1 = i
            //      t2 = t0.foo(t1)
            //
            // This means that the initial value of 'b' will be preserved as class A will not be re-initialed after the update
            //
            thisTest.Verify("e1", new Object[] { new Object[] { 1, 2, 3, 3 }, new Object[] { 1, 3, 3, 3 }, new Object[] { 1, 3, 4, 3 } });
        }
Пример #24
0
 public override void Setup()
 {
     base.Setup();
     coreRunner = new ProtoScript.Runners.ProtoScriptTestRunner();
 }
Пример #25
0
        public LiveRunner(Configuration configuration)
        {
            this.configuration = configuration;

            runner = new ProtoScriptTestRunner();

            InitCore();

            taskQueue = new Queue<Task>();

            workerThread = new Thread(new ThreadStart(TaskExecMethod));
            workerThread.IsBackground = true;
            workerThread.Start();

            staticContext = new ProtoCore.CompileTime.Context();

            terminating = false;
            changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
            changeSetApplier = new ChangeSetApplier();
        }
Пример #26
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif
            
#if __RUN_TEST_FILE
            
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
            ExecutionMirror mirror = runner.LoadAndExecute(@"c:\jun\AutodeskResearch\git\designscript\Scripts\jun.ds", core);
          
#else
            /*
            var runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            var fsr = new ProtoScript.Runners.DebugRunner(core);
            fsr.LoadAndPreStart(@"c:\project\designscript\test.ds", runnerConfig);
            fsr.Run();
            */


            
            //ProtoTest.TD.OtherMiscTests.MiscTest test = new ProtoTest.TD.OtherMiscTests.MiscTest();
            //test.TestDynamicSetValueAfterExecution();
            


            //ProtoTest.DebugTests.RunEqualityTests test = new ProtoTest.DebugTests.RunEqualityTests();
            //test.DebugTest_Jun_ReplicationGuide();

            //ProtoTest.Associative.MicroFeatureTests test = new ProtoTest.Associative.MicroFeatureTests();
            //test.Setup();
            //test.TestContextInject01();


            ProtoFFITests.ContextInjectionTests test = new ProtoFFITests.ContextInjectionTests();
            test.Setup();
            test.TestContextInjectDummy();



            //ProtoTest.Associative.MethodsFocusTeam test = new ProtoTest.Associative.MethodsFocusTeam();
            //test.Setup();
            //test.T014_DotOp_UserDefinedClass_03();
            
#endif

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Пример #27
0
        internal void TestRunnerRunOnly(string includePath, string code, Dictionary<int, List<string>> map /*, string executionLogFilePath*/)
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();

            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.

            core.Options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            core.Options.SuppressBuildOutput = false;
            core.Options.WatchTestMode = true;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            core.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);
                core.Options.IncludeDirectories.Add(includePath);
            }

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            //core.BuildStatus.MessageHandler = fs;
            core.RuntimeStatus.MessageHandler = fs;

            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;

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

            //Run
            ProtoLanguage.CompileStateTracker compileState = null;
            Mirror = fsr.Execute(code, core, out compileState);

            //sw.Close();
            core.Cleanup();
        }
Пример #28
0
        public void T033_Defect_1467187_Update_In_class_collection_property_2()
        {
            String code =
            @"
            class B
            {
            a1 : int;
            a2 : double[];
            constructor B (a:int, b : double[])
            {
            a1 = a;
            a2 = b;
            }
            }
            b1 = B.B ( 1, {1.0, 2.0} );
            test1 = b1.a2[0];
            b1.a2[0] = b1.a2[1];
            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test1", 2.0);
        }
Пример #29
0
        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            bool testScript = string.Equals(args[0], "test") && args.Length == 2;
            var opts = new Options();
            if (args.Length == 0 || testScript)
            {
                opts.WebRunner = false;
            }
            else
            {
                opts.WebRunner = true;
            }
            opts.ExecutionMode = ExecutionMode.Serial;

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


            if (!opts.WebRunner)
            {
                string fileName;
                if (testScript)
                {
                    fileName = args[1];
                }
                else
                {
                    fileName = @"..\..\..\Scripts\defectverify.ds";
                }

                ProtoScriptTestRunner runner = new ProtoScriptTestRunner();
                DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
                ExecutionMirror mirror = runner.LoadAndExecute(fileName, core);
                string str = mirror.GetCoreDump();
                //Console.WriteLine(str);
            }
            else //if (arg)
            {
                // @TODO(Gemeng): Do set "core.ExecutionLog" to some file :)

                ProtoScriptWebRunner runner = new ProtoScriptWebRunner();
                DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
                ExecutionMirror mirror = runner.LoadAndExecute(args[0], core);
                if (null != mirror)
                {
                    string str = mirror.GetCoreDump();
                    // core.coreDumpWriter.WriteLine(str);

                }

                // @TODO(Gemeng): 'coreDumpWriter' has been removed, instead of 
                // doing that we should create an output file stream here with a
                // file name, and then write the "str" content into it.
                // 
                // core.coreDumpWriter.Close();
            }


            //runner.LoadAndExecute(@"..\..\..\Scripts\array.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\arrayargs.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class3.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class4.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class5.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class6.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class7.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class8.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class9.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\class10.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\demo.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\expr.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\fusionarray.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\replication.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\simple.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\simple2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\functionoverload.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\classfunctionoverload.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\inheritance.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\inheritance2.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\update.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\null.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\forloop.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\blockassign_imperative.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\blockassign_associative.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\test.ds", core);
            //runner.LoadAndExecute(@"..\..\..\Scripts\importtest.ds", core);

            //ExecutionMirror mirror = null;   



            //string str = mirror.GetCoreDump();
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();

            if (!opts.WebRunner)
            {
                Console.WriteLine(ms);
                Console.ReadLine();
            }
        }
Пример #30
0
        private void InitRunner(Options options)
        {
            graphCompiler = GraphToDSCompiler.GraphCompiler.CreateInstance();
            graphCompiler.SetCore(GraphUtilities.GetCore());
            runner = new ProtoScriptTestRunner();

            executionOptions = options;
            InitOptions();
            InitCore();


            taskQueue = new Queue<Task>();

            workerThread = new Thread(new ThreadStart(TaskExecMethod));


            workerThread.IsBackground = true;
            workerThread.Start();

            staticContext = new ProtoCore.CompileTime.Context();

            terminating = false;
            changeSetComputer = new ChangeSetComputer(runnerCore);
            changeSetApplier = new ChangeSetApplier();
        }
Пример #31
0
        private void CleanUpRunners()
        {
            Logger.LogInfo("DetachFromDebugger", "Detach");

            // Clear up all watch related data members.
            this.workerParams.CurrentVmState = null;
            this.currentWatchedMirror = null;
            this.currentWatchedStackValue = null;

            if (null != scriptRunner)
                scriptRunner = null;

            if (null != debugRunner)
            {
                debugRunner.Shutdown();
                debugRunner = null;
            }

            if (null != internalWorker)
            {
                // @TODO(Ben): Perhaps cancellation is needed?
                internalWorker = null;
            }

            //Fix DG-1464973 Sprint25: rev 3444 : Multiple import issue - dispose core after execution
            //Core Cleanup should happen only after execution has finished,
            //DebugRunner is ShutDown.
            if (null != this.core)
            {
                this.core.Cleanup();
                this.core = null;
            }

            workerParams.ResetStates();
            SetExecutionState(ExecutionStateChangedEventArgs.States.None);
        }
Пример #32
0
        private bool SetupRegularRunner()
        {
            if ((null != internalWorker) && internalWorker.IsBusy)
                return false;

            Logger.LogInfo("SetupRegularRunner", "Init");
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            SetupCommonRunner(false);
            this.scriptRunner = new ProtoScriptTestRunner();

            Logger.LogPerf("SetupRegularRunner", sw.ElapsedMilliseconds + " ms");
            return true;
        }
Пример #33
0
        public void T033_Defect_1467187_Update_In_class_collection_property_3()
        {
            String code =
            @"
            class Point
            {
            X : double[];

            constructor ByCoordinates( x : double[] )
            {
            X = x;

            }
            def foo ( y :double[])
            {
            X = y + 1;
            [Imperative]
            {
               count = 0;
               for (i in y)
               {
               X[count] = y[count] + X[count];
               count = count + 1;
               }
            }
            return = true;
            }

            }

            p1 = Point.ByCoordinates({0,0,0,0});
            test = p1.X;
            dummy = p1.foo({1,1,1,1});
            p1.X[0..1] = -1;
            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            String errmsg = "DNL-1467401 Rev 4347 : Update issue with collection property in nested imperative scope";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test", new Object[] { -1, -1, 2, 2 } );
        }
Пример #34
0
        /// <summary>
        /// Re-initializes the LiveRunner to reset the VM 
        /// Used temporarily when importing libraries on-demand during delta execution
        /// Will be deprecated once this is supported by the core language
        /// </summary>
        public void ReInitializeLiveRunner()
        {
            runner = new ProtoScriptTestRunner();

            executionOptions = new Options();
            deltaSymbols = 0;

            coreOptions = null;
            InitOptions();
            InitCore();

            staticContext = new ProtoCore.CompileTime.Context();

            changeSetComputer = new ChangeSetComputer(runnerCore);

            CLRModuleType.ClearTypes();
        }