public void EmbeddedTest001()
        {
            String code =
            @"x;[Associative]
            {
            x = 0;
            [Imperative]
            {
            x = x + 5;
            }
            }
            ";

                ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
                ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

                Obj o = mirror.GetValue("x");
                Assert.IsTrue((Int64)o.Payload == 5);
        }

        [Test]
        public void EmbeddedTest002()
        {
            String code =
            @"
        public void TestMultLanguageVariableUsage()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();

            fsr.Execute(
                @"
[Associative]
{
    a = 2;
    [Imperative]
    {
        if(a == 2 )
        {
            b = a + 5;
            a = 20;
        }
        else 
        {
            b = 4;
        }
    }
    c = a;
}
"                                                                                                                                                                                                                                , core);
        }
        public void TestClassUsageInImpeartive()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
                @"
class foo
{
	m : var;
	constructor Create(a1 : int)
	{
		m = a1;
	}
}
x;y;
[Imperative]
{
	p = foo.Create(16);
    x = p.m;
    p.m = 32;
    y = p.m;
}
"
                , core);

            Assert.IsTrue((Int64)mirror.GetValue("x", 0).Payload == 16);
            Assert.IsTrue((Int64)mirror.GetValue("y", 0).Payload == 32);
        }
        public void AccessGlobalVariableInsideFunction()
        {
            string code = @"
                                arr = { 1, 2, 3 };
                                factor = 10;

                                def foo : int[]()
                                {
                                    f = factor;
                                    [Imperative]
                                    {
                                        ix = 0;
                                        for(i in arr)
                                        {
                                            arr[ix] = arr[ix] * factor * f;
                                            ix = ix + 1;
                                        }
                                    }

                                    return = arr;
                                }

                                w = foo();
                                w0 = w[0];
                                w1 = w[1];
                                w2 = w[2];
            ";

                ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
                ExecutionMirror mirror = fsr.Execute(code, core);
                Assert.IsTrue((Int64)mirror.GetValue("w0").Payload == 100);
                Assert.IsTrue((Int64)mirror.GetValue("w1").Payload == 200);
                Assert.IsTrue((Int64)mirror.GetValue("w2").Payload == 300);
        }
Exemple #5
0
        public void TestMethodOverload4()
        {
            string code =
                @"
                class A
                {
	                def execute(a : A)
	                {
		                return = 1;
	                }
                }
                class B extends A
                {
	                def execute(b : B)
	                {
		                return = 2;
	                }
                }
                class C extends B
                {
                }
                c = C.C();
                val = c.execute(c);
                "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);

            Assert.IsTrue((Int64)mirror.GetValue("val").Payload == 2);
            Assert.IsTrue(core.BuildStatus.WarningCount == 0);
        }
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            fsr.Execute(
@"
[Associative]
{
    a = [Imperative]
        {
Exemple #7
0
        public void GetUpcastChainTest()
        {
            String code =
                @"class A {}
class B extends A {}
class C extends B {}
"                                                                       ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ProtoCore.RuntimeCore runtimeCore             = null;
            ExecutionMirror       mirror = fsr.Execute(code, core, out runtimeCore);
            int        idA  = core.ClassTable.IndexOf("A");
            int        idB  = core.ClassTable.IndexOf("B");
            int        idC  = core.ClassTable.IndexOf("C");
            ClassNode  cnA  = core.ClassTable.ClassNodes[idA];
            ClassNode  cnB  = core.ClassTable.ClassNodes[idB];
            ClassNode  cnC  = core.ClassTable.ClassNodes[idC];
            List <int> idsA = ClassUtils.GetClassUpcastChain(cnA, runtimeCore);
            List <int> idsB = ClassUtils.GetClassUpcastChain(cnB, runtimeCore);
            List <int> idsC = ClassUtils.GetClassUpcastChain(cnC, runtimeCore);

            Assert.IsTrue(idsA.Count == 2);
            Assert.IsTrue(idsA.Contains(idA));

            Assert.IsTrue(idsB.Count == 3);
            Assert.IsTrue(idsB.Contains(idA));
            Assert.IsTrue(idsB.Contains(idB));
            Assert.IsTrue(idsC.Count == 4);
            Assert.IsTrue(idsC.Contains(idA));
            Assert.IsTrue(idsC.Contains(idB));
            Assert.IsTrue(idsC.Contains(idC));
        }
Exemple #8
0
        public void LanguageBlockReturn02()
        {
            String code =
                @"
a;
[Associative]
{
    def DoSomthing : int(p : int)
    {
        ret = p;       
        d = [Imperative]
        {
            loc = 20;
            return = loc;
        }
        return = ret * 100 + d;
    }
    a = DoSomthing(10);   
}
    
"                                                                                                                                                                                                                                                                           ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);

            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 1020);
        }
        public void ArrayRetrival2D2b1()
        {
            String code =
                @"
foo;
[Associative]
{
	foo = {{5}, {6}};
}
"                                                             ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Obj o = mirror.GetValue("foo");

            ProtoCore.DSASM.Mirror.DsasmArray a = (ProtoCore.DSASM.Mirror.DsasmArray)o.Payload;
            Assert.IsTrue(a.members.Length == 2);
            ProtoCore.DSASM.Mirror.DsasmArray a2 = (ProtoCore.DSASM.Mirror.DsasmArray)((a.members[0]).Payload);
            Assert.IsTrue(a2.members.Length == 1);
            Assert.IsTrue((Int64)a2.members[0].Payload == 5);
            ProtoCore.DSASM.Mirror.DsasmArray a3 = (ProtoCore.DSASM.Mirror.DsasmArray)((a.members[1]).Payload);
            Assert.IsTrue(a3.members.Length == 1);
            Assert.IsTrue((Int64)a3.members[0].Payload == 6);
        }
        public void TestMethodOverlaodAndArrayInput1()
        {
            string code =
                @"
                class A
                {
                    def execute(a : A)
                    { 
                        return = -1; 
                    }
                }
                class B extends A
                {
                    def execute(arr : B[])
                    {
                        return = 2;
                    }
                }
                b = B.B();
                arr = {B.B(), B.B(), B.B()};
                val = b.execute(arr);
                "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("val").Payload == 2);
            Assert.IsTrue(compileState.BuildStatus.WarningCount == 0);
        }
Exemple #11
0
 protected int ExecuteAndVerify(String code, ValidationData[] data, Dictionary<string, Object> context, out int nErrors)
 {
     ProtoCore.Core core = Setup();
     ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
     ExecutionMirror mirror = fsr.Execute(code, core, context);
     int nWarnings = core.RuntimeStatus.WarningCount;
     nErrors = core.BuildStatus.ErrorCount;
     if (data == null)
     {
         core.Cleanup();
         return nWarnings + nErrors;
     }
     TestFrameWork thisTest = new TestFrameWork();
     foreach (var item in data)
     {
         if (item.ExpectedValue == null)
         {
             object nullOb = null;
             TestFrameWork.Verify(mirror, item.ValueName, nullOb, item.BlockIndex);
         }
         else
         {
             TestFrameWork.Verify(mirror, item.ValueName, item.ExpectedValue, item.BlockIndex);
         }
     }
     core.Cleanup();
     return nWarnings + nErrors;
 }
        public void TestMethodOverlaodAndArrayInput4Min()
        {
            string code =
                @"
                class A
                {
                }
                class B extends A
                {
                    static def execute(b : B)
                    { 
                        return = -1; 
                    }
                    def execute(arr : B[])
                    {
                        return = 2;
                    }
                }
                arr = {B.B(), B.B()};
                val = B.execute(arr);
                val1 = val[0];
                val2 = val[1];
                "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("val1").Payload == -1);
            Assert.IsTrue((Int64)mirror.GetValue("val2").Payload == -1);
            Assert.IsTrue(compileState.BuildStatus.WarningCount == 0);
        }
        public void TestMethodResolutionOverInheritance()
        {
            string code =
                @"
                class A
                {
	                def execute(a : A)
	                {
		                return = 1;
	                }
                }
                class B extends A
                {
                }
                class C extends B
                {
                }
                c = C.C();
                val = c.execute(c);
                "                                                                                                                                                                                                                                                                                                                                                                                                  ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("val").Payload == 1);
            Assert.IsTrue(compileState.BuildStatus.WarningCount == 0);
        }
        public void TestClassUsageInImpeartive()
        {
            ProtoCore.Core 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));
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
            @"
            class foo
            {
            m : var;
            constructor Create(a1 : int)
            {
            m = a1;
            }
            }
            x;y;
            [Imperative]
            {
            p = foo.Create(16);
            x = p.m;

            p.m = 32;
            y = p.m;
            }
            "
            , core, out compileState);
            Assert.IsTrue((Int64)mirror.GetValue("x", 0).Payload == 16);
            Assert.IsTrue((Int64)mirror.GetValue("y", 0).Payload == 32);
        }
        public void TestMethodOverload1()
        {
            string code =
                @"
                class A
                {
	                def execute(a : A)
	                {
		                return = 1;
	                }
                }
                class B extends A
                {
	                def execute(b : B)
	                {
		                return = 2;
	                }
                }
                a = A.A();
                b = B.B();
                val = b.execute(a);
                "                                                                                                                                                                                                                                                                                                                                                                                                                                                               ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("val").Payload == 1);
            Assert.IsTrue(compileState.BuildStatus.WarningCount == 0);
        }
        public void SimpleCtorResolution01()
        {
            String code =
                @"
	class f
	{
		fx : var;
		fy : var;
		constructor f()
		{
			fx = 123;
			fy = 345;
		}
	}
// Construct class 'f'
	cf = f.f();
	x = cf.fx;
	y = cf.fy;
"                                                                                                                                                                          ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 123);
            Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 345);
        }
        public void ClassTest()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
                 fsr.Execute(
                            @"
                            [Associative]
                            {
                                class Point
                              {
                                  mx : var;
                                  my : var;
                                  mz : var;
                                  constructor Point(xx : double, yy : double, zz : double)
                                  {
                                      mz = xx;
                                      my = yy;
                                      mx = zz;
                                  }
                              }
                                point = Point.Point(10,10,10);
                            }
                            ", core, out compileState);

               //Object o = mirror.GetValue("point.mx");
               //Assert.IsTrue((long)o == 10);
        }
        public void ModifierStackWithArray()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
                        @"
            a;
            a@init;
            a@first;
                        [Associative]
                        {
                            a =
                                {
                                    {3, 2, 1} => a@init;
                                    1 => a@first;
                                }
                        }
                        ", core, out compileState);

            Obj o = mirror.GetValue("a@init");
            List<Obj> os = mirror.GetArrayElements(o);
            Assert.IsTrue(os.Count == 3);
            Assert.IsTrue((Int64)os[0].Payload == 3);
            Assert.IsTrue((Int64)os[1].Payload == 2);
            Assert.IsTrue((Int64)os[2].Payload == 1);

            Assert.IsTrue((Int64)mirror.GetValue("a@first", 0).Payload == 1);
        }
        public void EmbeddedTest003()
        {
            String code =
                @"
x;
[Associative]
{
	x = 
    {
        0 => x@first;
        +1 => x@second;
    }

    [Imperative]
    {
        x = x + 5;
    }
}
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Obj o = mirror.GetValue("x");

            Assert.IsTrue((Int64)o.Payload == 6);
        }
Exemple #20
0
        public static void TestMinFac()
        {
            Assert.Ignore("Testing old C++ FFI. Ignored");

            String code =
                @"[Associative] 
             { 
               external (""factorial"") def factorial : int (num4 : int); 
               a = factorial(4); 
             }
            ";


            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ProtoCore.Core 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));

            ProtoLanguage.CompileStateTracker compileState = null;
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Obj o = mirror.GetValue("a");

            Assert.IsTrue((Int64)o.Payload == 24);
        }
        public void NestedBlockInFunction04()
        {
            String code =
                @"
def foo  ()
{    
    t = [Associative]
    {
          t1 = [Imperative]
         {                     
                t2 = 6;    
                return = t2;  
        }      
       return = t1;                 
    }
    return = t;    
}
p = foo();
    
"                                                                                                                                                                                                                                                                                         ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("p").Payload == 6);
        }
        public void AccessGlobalVariableInsideFunction()
        {
            string code = @"
                                arr = { 1, 2, 3 };
                                factor = 10;
                                def foo : int[]()
                                {
	                                f = factor;
	                                [Imperative]
	                                {
		                                ix = 0;
		                                for(i in arr)
		                                {
			                                arr[ix] = arr[ix] * factor * f;
			                                ix = ix + 1;
		                                }
	                                }
	                                return = arr;
                                }
                                w = foo();
                                w0 = w[0];
                                w1 = w[1];
                                w2 = w[2];
"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("w0").Payload == 100);
            Assert.IsTrue((Int64)mirror.GetValue("w1").Payload == 200);
            Assert.IsTrue((Int64)mirror.GetValue("w2").Payload == 300);
        }
        public void NestedBlockInFunction02()
        {
            String code =
                @"

def clampRange : int(i : int, rangeMin : int, rangeMax : int)
{
    result = [Imperative]
    {
	    clampedValue = i;
	    if(i < rangeMin) 
	    {
		    clampedValue = rangeMin;
	    }
	    elseif( i > rangeMax ) 
	    {
		    clampedValue = rangeMax; 
	    } 
        return = clampedValue;
    }
	return = result;
}
a = clampRange(101, 10, 100);
    
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 100);
        }
        public void LanguageBlockReturn02()
        {
            String code =
                @"
a;
[Associative]
{
    def DoSomthing : int(p : int)
    {
        ret = p;       
        d = [Imperative]
        {
            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));
        }
        return = ret * 100 + d;
    }
    a = DoSomthing(10);   
}
    
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 1020);
        }
        public void LanguageBlockReturn01()
        {
            String code =
                @"
a;
[Associative]
{
    a = 4;
    b = a*2;
	
    x = [Imperative]
    {
        i=0;		
        return = i; 
    }
    a = x;
    temp = 5;
}
    
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 0);
        }
        public void TestOverridenMethod()
        {
            string code = @"
                            class A
                            {
	                            def foo(x : double)
                                { return = 1; }
                            }
                            class B extends A
                            {
                                def foo(x : double)
                                { return = 2; }
                            }
                            
                          //  a = A.A();
                          //  val1 = a.foo(0.0);
                            
                          b = B.B();
                            
                          val2 =b.foo(0.0);
                            "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            //Assert.IsTrue((Int64)mirror.GetValue("val1").Payload == 1);
            Assert.IsTrue((Int64)mirror.GetValue("val2").Payload == 2);
        }
Exemple #27
0
            ExecutionMirror mirror = fsr.Execute(
                        @"
a;
                        [Associative]
                        {
                            a = 
                                {
Exemple #28
0
            public void ExternCallTest()
            {

               //String code =
/*@"external (""ffi_library"") def sum_all : double (arr : double[], numElems : int);

def sum_all_2 : double (arr : double[], numElems : int)
{ return = 42;

}

arr = {1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10};

sum_1_to_10 = sum_all_2(arr, 10);";
*/

                String code =
@"external (""ffi_library"") def sum_all : double (arr : double[], numElems : int);


arr = {1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10};

sum_1_to_10 = sum_all(arr, 10);";
                


                ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
                ExecutionMirror mirror = fsr.Execute(code, core);

                Obj o = mirror.GetValue("sum_1_to_10");
                Assert.IsTrue((Int64)o.Payload == 55);
            }
        public void SimpleCtorResolution01()
        {
            String code =
            @"
            class f
            {
            fx : var;
            fy : var;
            constructor f()
            {
            fx = 123;
            fy = 345;
            }
            }

            // Construct class 'f'
            cf = f.f();
            x = cf.fx;
            y = cf.fy;

            ";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 123);
            Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 345);
        }
Exemple #30
0
        public void ModifierStackWithArray()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
                @"
a;
a@init;
a@first;
                        [Associative]
                        {
                            a = 
                                {
                                    {3, 2, 1} => a@init;
                                    1 => a@first;
                                }
                        }
                        ", core, out runtimeCore);

            Obj        o  = mirror.GetValue("a@init");
            List <Obj> os = mirror.GetArrayElements(o);

            Assert.IsTrue(os.Count == 3);
            Assert.IsTrue((Int64)os[0].Payload == 3);
            Assert.IsTrue((Int64)os[1].Payload == 2);
            Assert.IsTrue((Int64)os[2].Payload == 1);
            Assert.IsTrue((Int64)mirror.GetValue("a@first", 0).Payload == 1);
        }
Exemple #31
0
        public void ModifierStackWithArrayAndFunction()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
                @"a@init;a@first;b;
                        [Associative]
                         {
	                         def foo : int(x : int)
	                         {
		                        a = x+2;
		                        return = a;
	                         }
                             b = 
                                 {
                                     {3, 2, 1} => a@init;
                                     foo(7) => a@first;
                                 }
                         }
                        ", core, out runtimeCore);
            Obj        o  = mirror.GetValue("a@init");
            List <Obj> os = mirror.GetArrayElements(o);

            Assert.IsTrue(os.Count == 3);
            Assert.IsTrue((Int64)os[0].Payload == 3);
            Assert.IsTrue((Int64)os[1].Payload == 2);
            Assert.IsTrue((Int64)os[2].Payload == 1);
            Assert.IsTrue((Int64)mirror.GetValue("a@first", 0).Payload == 9);
            Assert.IsTrue((Int64)mirror.GetValue("b", 0).Payload == 9);
        }
Exemple #32
0
        public void TestDepthCountOnJaggedArray()
        {
            String code =
                @"
a = {1,{{1},{3.1415}},null,1.0,12.3};
b = {1,2,{3}};
x = {{1},{3.1415}};
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            StackValue      a      = mirror.GetRawFirstValue("a");
            StackValue      b      = mirror.GetRawFirstValue("b");
            StackValue      x      = mirror.GetRawFirstValue("x");
            int             rankA  = ArrayUtils.GetMaxRankForArray(a, core);

            Assert.IsTrue(rankA == 3);
            int rankB = ArrayUtils.GetMaxRankForArray(b, core);

            Assert.IsTrue(rankB == 2);
            int rankX = ArrayUtils.GetMaxRankForArray(x, core);

            Assert.IsTrue(rankX == 2);            /*
                                                   *
                                                   */
        }
Exemple #33
0
        public void StackValueDiffTestProperty01()
        {
            String code =
                @"
class A
{
    x : var;
    constructor A()
    {
        x = 20;
    }
}
[Imperative]
{
	a = A.A();
    b = 1.0;
}
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            StackValue      svA    = mirror.GetRawFirstValue("a");
            StackValue      svB    = mirror.GetRawFirstValue("b");

            Assert.IsTrue(svA.metaData.type != svB.metaData.type);
        }
Exemple #34
0
        public void GetUpcastChainTest()
        {
            String code =
@"class A {}
class B extends A {}
class C extends B {}
";
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            int idA = core.ClassTable.IndexOf("A");
            int idB = core.ClassTable.IndexOf("B");
            int idC = core.ClassTable.IndexOf("C");
            ClassNode cnA = core.ClassTable.ClassNodes[idA];
            ClassNode cnB = core.ClassTable.ClassNodes[idB];
            ClassNode cnC = core.ClassTable.ClassNodes[idC];
            List<int> idsA = ClassUtils.GetClassUpcastChain(cnA, core);
            List<int> idsB = ClassUtils.GetClassUpcastChain(cnB, core);
            List<int> idsC = ClassUtils.GetClassUpcastChain(cnC, core);
            Assert.IsTrue(idsA.Count == 2);
            Assert.IsTrue(idsA.Contains(idA));

            Assert.IsTrue(idsB.Count == 3);
            Assert.IsTrue(idsB.Contains(idA));
            Assert.IsTrue(idsB.Contains(idB));
            Assert.IsTrue(idsC.Count == 4);
            Assert.IsTrue(idsC.Contains(idA));
Exemple #35
0
        public void TestArrayLayerStatsSimple()
        {
            String code =
                @"
a;b;c;
[Imperative]
{
	a = {1,2,3};
    b = {1.0, 2.0, 3.0, 3.0};
    c = {1.0, 2.0, 9};
}
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            StackValue      svA    = mirror.GetRawFirstValue("a");
            var             dict   = ProtoCore.Utils.ArrayUtils.GetTypeStatisticsForLayer(svA, core);

            Assert.IsTrue(dict[dict.Keys.First()] == 3);
            StackValue svB   = mirror.GetRawFirstValue("b");
            var        dict2 = ProtoCore.Utils.ArrayUtils.GetTypeStatisticsForLayer(svB, core);

            Assert.IsTrue(dict2[dict2.Keys.First()] == 4);
            StackValue svC   = mirror.GetRawFirstValue("c");
            var        dict3 = ProtoCore.Utils.ArrayUtils.GetTypeStatisticsForLayer(svC, core);

            Assert.IsTrue(dict3[dict3.Keys.First()] == 2);
            Assert.IsTrue(dict3[dict3.Keys.Last()] == 1);

            // Assert.IsTrue((Int64)o.Payload == 5);
        }
Exemple #36
0
        public void TestGetRunId03()
        {
            String code =
                @"
def f(i : int)
{
	return = i + 1;
}

x = 0;
y = f(x);
x = {1,2,3}; // Replicated call to 'f' should still yield runId of 1

";

            ProtoCore.Core core = SetupTestCore("TestGetRunId03");
            ProtoScript.Runners.ProtoScriptTestRunner runner = new ProtoScript.Runners.ProtoScriptTestRunner();

            ExecutionMirror mirror = runner.Execute(code, core);


            // Verify entries in the callsite map
            ProtoCore.CallsiteExecutionState csState = core.csExecutionState;
            int entries = csState.GetCSStateCount();

            Assert.IsTrue(entries == 1);

            // Verify run id of each callsite
            Assert.IsTrue(core.csExecutionState.CallsiteDataMap[0].RunID == 1);

            RemoveTestCallsiteStateFile(ProtoCore.CallsiteExecutionState.GetThisSessionFileName());
        }
Exemple #37
0
        public void StackValueDiffTestProperty01()
        {
            String code =
@"
class A
{
    x : var;
    constructor A()
    {
        x = 20;
    }
}
[Imperative]
{
	a = A.A();
    b = 1.0;
}
";
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ProtoCore.RuntimeCore runtimeCore = null;
            ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);
            StackValue svA = mirror.GetRawFirstValue("a");
            StackValue svB = mirror.GetRawFirstValue("b");
            Assert.IsTrue(svA.metaData.type != svB.metaData.type);
        }
Exemple #38
0
        public void TestClassUsageInImpeartive()
        {
            ProtoCore.Core 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));
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(
                @"
class foo
{
	m : var;
	constructor Create(a1 : int)
	{
		m = a1;
	}
}
x;y;
[Imperative]
{
	p = foo.Create(16);
    x = p.m;

    p.m = 32;
    y = p.m;
}
"
                , core, out compileState);

            Assert.IsTrue((Int64)mirror.GetValue("x", 0).Payload == 16);
            Assert.IsTrue((Int64)mirror.GetValue("y", 0).Payload == 32);
        }
Exemple #39
0
        public void TestMultLanguageVariableUsage()
        {
            ProtoCore.Core 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));
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();

            fsr.Execute(
                @"
[Associative]
{
    a = 2;
    [Imperative]
    {
        if(a == 2 )
        {
            b = a + 5;
            a = 20;
        }
        else 
        {
            b = 4;
        }
    }
    c = a;
}
", core, out compileState);
        }
Exemple #40
0
        public void RedefineWithFunctions03()
        {
            String code =
                @"
class C
{
    mx : var;
    constructor C()
    {
        mx = 10;
    }
    def f(a : int)
    {
        mx = a + 1;
        return = mx;
    }
}
x = 10;
p = C.C();
x = p.f(x);
"                                                                                                                                                                                                     ;

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);

            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 11);
        }
        public void EmbeddedTest005()
        {
            Assert.Fail("This code should fail as x@second should be read only, however it doesn't");

            String code =
                @"x;
[Associative]
{
	x = {
        0 => x@first;
        +1 => x@second;
}
    [Imperative]
    {
        x@second = x + 5;
    }
}
";

            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out compileState);

            Obj o = mirror.GetValue("x");

            Assert.IsTrue((Int64)o.Payload == 6);
        }
Exemple #42
0
        public void ClassTest()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            fsr.Execute(
                @"
                            [Associative]
                            {
                                class Point
                              {		
                                  mx : var;
                                  my : var;
                                  mz : var;
                                  constructor Point(xx : double, yy : double, zz : double)
                                  {
                                      mz = xx;
                                      my = yy;
                                      mx = zz;
                                  }
                              }
                                point = Point.Point(10,10,10);
                            }
                            ", core, out compileState);

            //Object o = mirror.GetValue("point.mx");
            //Assert.IsTrue((long)o == 10);
        }
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 1001);
        }

        [Test]
        [Category("ToFixYuKe")]
        public void RedefineWithFunctions02()
";
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core);
            Obj o = mirror.GetValue("x");
            Assert.IsTrue((Int64)o.Payload == 6);
        }

        [Test]
import(""FFITarget.dll"");
p = 10;
p = DummyPoint.ByCoordinates(11.0, 20.0, 30.0);
x = p.X;
";
            thisTest.RunScriptSource(code);
            thisTest.Verify("x", 11);
        }
        public void RedefineWithFunctions03()
        {
            String code =
@"
class C
{
    mx : var;
    constructor C()
    }
    def f(a : int)
    {
        mx = a + 1;
        return = mx;
    }
}
x = 10;
Exemple #48
0
                        ", core);
            Assert.IsTrue((Int64)mirror.GetValue("a", 0).Payload == 10);

        }
        [Test]
        public void TwoSimpleExprInModifierStack()
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
Exemple #49
0
 public void TestScript(string scriptCode)
 {
     ProtoCore.Core 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));
     ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
     fsr.Execute(scriptCode, core);
 }
Exemple #50
0
 ExecutionMirror mirror = thisTest.RunScriptSource(code);
 thisTest.Verify("f0", false);
 thisTest.Verify("f1", false);
 thisTest.Verify("f2", false);
 thisTest.Verify("f3", false);
 thisTest.Verify("t0", true);
 thisTest.Verify("t1", true);
 thisTest.Verify("t2", true);
        public void RedefineWithFunctions01()
        {
            String code =
@"
def f(i : int)
{
    return = i + 1;
}
Exemple #52
0
            ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);
            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 123);
            Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 345);
        }

        [Test]
        [Category("DSDefinedClass_Ported")]
        public void SimpleMethodOverload2()
Exemple #53
0
        return = 0;
	}
	x = 10;
    y = 40;
	n = scale();
	n = scale(10);
";
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);
Exemple #54
0
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
            ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);
            Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 123);
            Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 345);
        }

        [Test]
        [Category("DSDefinedClass_Ported")]
        public void SimpleMethodOverload1()
Exemple #55
0
	def f()
	{
		return = 123;
	}
    def f(a : int)
    {
        return = a;
	}
    x = f();
Exemple #56
0
        public void SimpleAssignment()
        {
            String code =
@"
	fx : var;
	fy : var;
	fx = 123;
	fy = 345;
	
        public void PreClarifyPreParseBracket001()
        {
            String code =
@"x;
[Associative]
{
 a = {1001,1002};    
 // This is failing the pre-parse. 
 // Probably has somthing to do with convertingthe language blocks into binary exprs
Exemple #58
0
    a = 3;
    b = 4;
}
", core);
        }
        [Test]
        public void TestSingleLanguageAssociative()
        {
            ProtoCore.Core core = new ProtoCore.Core(new ProtoCore.Options());
Exemple #59
0
        public void TestDS()
        {
            String code =
@"
size;
[Imperative]
{
	size = 5;
}
Exemple #60
0
 }
 [Test]
 public void TestMultLanguageAssociativeImperative()
 {
     ProtoCore.Core 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));
     ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
     fsr.Execute(