Ejemplo n.º 1
0
        public void T005_Inline_Using_2_Collections_In_Condition()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");
            string          src    = @"
	a1  =  1..3..1; 
	b1  =  4..6..1; 
	a2  =  1..3..1; 
	b2  =  4..7..1; 
	a3  =  1..4..1; 
	b3  =  4..6..1; 
	c1 = a1 > b1 ? true : false; // { false, false, false }
	c2 = a2 > b2 ? true : false; // { false, false, false }
	c3 = a3 > b3 ? true : false; // { false, false, false, null }
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> c1 = new List <object>()
            {
                false, false, false
            };
            List <Object> c2 = new List <object>()
            {
                false, false, false
            };
            List <Object> c3 = new List <object>()
            {
                false, false, false
            };

            Assert.IsTrue(mirror.CompareArrays("c1", c1, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c2", c2, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c3", c3, typeof(System.Boolean)));
        }
Ejemplo n.º 2
0
        public void T006_Inline_Using_Different_Sized_1_Dim_Collections()
        {
            string          src    = @"[Imperative]
{
	a = 10 ;
	b = ((a - a / 2 * 2) > 0)? a : a+1 ; //11
	c = 5; 
	d = ((c - c / 2 * 2) > 0)? c : c+1 ; //5 
	e1 = ((b>(d-b+d))) ? d : (d+1); //5
	//inline conditional, returning different sized collections
	c1 = {1,2,3};
	c2 = {1,2};
	a1 = {1, 2, 3, 4};
	b1 = a1>3?true:a1; // expected : {1, 2, 3, true}
	b2 = a1>3?true:c1; // expected : {1, 2, 3}
	b3 = a1>3?c1:c2;   // expected : {1, 2}
}";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> b1 = new List <object> {
                1, 2, 3, true
            };
            List <Object> b2 = new List <object> {
                1, 2, 3
            };
            List <Object> b3 = new List <object> {
                1, 2
            };

            Assert.IsTrue(mirror.CompareArrays("b1", b1, typeof(System.Object)));
            Assert.IsTrue(mirror.CompareArrays("b2", b2, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("b3", b3, typeof(System.Int64)));
        }
Ejemplo n.º 3
0
        public void T007_Inline_Using_Collections_And_Replication()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Associative\\InlineCondition\\T007_Inline_Using_Collections_And_Replication.CollectionFunctionCall.ds");

            // following verification might need to be updated for current implementation, once the defect above is fixed

            // b = ((a[i] % 2) > 0)? even(a[i]) : a;
            // replication only is supported on condition, not the overall expression.
            // List<Object> b = new List<object>() { 1, 6, 3, 10, 5 };
            // Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));

            List <Object> c = new List <object>()
            {
                4, 6, 8, 10, 12
            };
            List <Object> d = new List <object>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <Object> e1 = new List <object>()
            {
                2, 3
            };

            Assert.IsTrue(mirror.CompareArrays("c", c, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("d", d, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("e1", e1, typeof(System.Int64)));
        }
Ejemplo n.º 4
0
        public void T005_Inline_Using_2_Collections_In_Condition()
        {
            string          src    = @"[Imperative]
{
	a1  =  1..3..1; 
	b1  =  4..6..1; 
	a2  =  1..3..1; 
	b2  =  4..7..1; 
	a3  =  1..4..1; 
	b3  =  4..6..1; 
	c1 = a1 > b1 ? true : false; // { false, false, false }
	c2 = a2 > b2 ? true : false; // { false, false, false }
	c3 = a3 > b3 ? true : false; // { false, false, false, null }
}
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> c1 = new List <object> {
                false, false, false
            };
            List <Object> c2 = new List <object> {
                false, false, false
            };
            List <Object> c3 = new List <object> {
                false, false, false, null
            };

            Assert.IsTrue(mirror.CompareArrays("c1", c1, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c2", c2, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c3", c3, typeof(System.Object)));
        }
Ejemplo n.º 5
0
        public void T009_Inline_Using_Function_Call_And_Collection_And_Replication()
        {
            string          src    = @"[Imperative]
{
	def even(a : int)
	{
		return = a * 2;
	}
	def odd(a : int ) 
	{
	return = a* 2 + 1;
	}
	x = 1..3;
	a = ((even(5) > odd(3)))? even(5) : even(3); //10
	b = ((even(x) > odd(x+1)))?odd(x+1):even(x) ; // {2,4,6}
	c = odd(even(3)); // 13
	d = ((a > c))?even(odd(c)) : odd(even(c)); //53
}
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> b = new List <object> {
                2, 4, 6
            };

            Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));
            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 10);
            Assert.IsTrue((Int64)mirror.GetValue("c").Payload == 13);
            Assert.IsTrue((Int64)mirror.GetValue("d").Payload == 53);
        }
Ejemplo n.º 6
0
        public void T004_Inline_Inside_Class_Constructor_and_replication()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");
            string          src    = @"class MyClass
{
    positive : var;
    constructor ByValue(value : int)
    {
        positive = value >= 0 ? true : false;
    }
}
number = 2;
sample = MyClass.ByValue(number);
values = sample.positive; // { true, false } 
number = { 3, -3 };
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> values = new List <object>()
            {
                true, false
            };

            Assert.IsTrue(mirror.CompareArrays("values", values, typeof(System.Boolean)));
        }
Ejemplo n.º 7
0
        public void T021_Vector_ByCoordinates_1458422_Regress()
        {
            //Assert.Fail("1463747 - Sprint 20 : rev 2147 : FFI issue : exception is thrown when same geometry is assigned to same variable more than once ");

            ExecutionMirror mirror = thisTest.RunScriptFile(FFIPath, "T021_Vector_ByCoordinates.ds");

            Assert.Fail("1467174 - sprint24 : rev 3150 : warning:Function 'get_X' not Found");

            thisTest.Verify("vec_X", 0.6, 0);
            thisTest.Verify("vec_Y", 0.8, 0);
            thisTest.Verify("vec_Z", 0.0, 0);
            thisTest.Verify("vec_Normalised", true, 0);

            thisTest.Verify("vec2_X", 1.0, 0); //vec2 is initialized as {3.0, 4.0, 0.0} but reset as {1.0, 2.0, 0.0}
            thisTest.Verify("vec2_Y", 2.0, 0);
            thisTest.Verify("vec2_Z", 0.0, 0);
            thisTest.Verify("vec_len", 2.23606797749979, 0);

            List <Object> vec4 = new List <Object> {
                3.0, 0.0, 0.0
            };
            List <Object> vec5 = new List <Object> {
                3.0, 4.0, 5.0
            };

            Assert.IsTrue(mirror.CompareArrays("vec4_coord", vec4, typeof(System.Double))); //updated to vec4=  Vector.ByCoordinates(3.0,0.0,0.0);

            Assert.IsTrue(mirror.CompareArrays("vec5_coord", vec5, typeof(System.Double))); //updated to vec5 =  Vector.ByCoordinates(3.0,4.0,5.0);

            thisTest.Verify("is_same", true, 0);
            thisTest.Verify("is_same2", false, 0);
            thisTest.Verify("is_parallel1", true, 0);
            thisTest.Verify("is_parallel2", true, 0);
            thisTest.Verify("is_parallel3", false, 0);
            thisTest.Verify("is_perp1", true, 0);
            thisTest.Verify("is_perp2", false, 0);
            thisTest.Verify("is_perp2", false, 0);
            thisTest.Verify("dotProduct", 5.0, 0);
            thisTest.Verify("cross_X", 0.0, 0);
            thisTest.Verify("cross_Y", 0.0, 0);
            thisTest.Verify("cross_Z", 1.0, 0);
            thisTest.Verify("newVec_X", 6.0, 0);
            thisTest.Verify("newVec_Y", 8.0, 0);
            thisTest.Verify("newVec_Z", 10.0, 0);
            thisTest.Verify("vec1", null, 0);
            thisTest.Verify("coord_Vec", null, 0); //ComputeGlobalCoords is not defined on Vector class.
        }
Ejemplo n.º 8
0
        public void T006_Inline_Using_Different_Sized_1_Dim_Collections()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T006_Inline_Using_Different_Sized_1_Dim_Collections.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> b1 = new List <object> {
                1, 2, 3, true
            };
            List <Object> b2 = new List <object> {
                1, 2, 3
            };
            List <Object> b3 = new List <object> {
                1, 2
            };

            Assert.IsTrue(mirror.CompareArrays("b1", b1, typeof(System.Object)));
            Assert.IsTrue(mirror.CompareArrays("b2", b2, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("b3", b3, typeof(System.Int64)));
        }
Ejemplo n.º 9
0
        public void T005_Inline_Using_2_Collections_In_Condition()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T005_Inline_Using_2_Collections_In_Condition.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> c1 = new List <object> {
                false, false, false
            };
            List <Object> c2 = new List <object> {
                false, false, false
            };
            List <Object> c3 = new List <object> {
                false, false, false, null
            };

            Assert.IsTrue(mirror.CompareArrays("c1", c1, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c2", c2, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c3", c3, typeof(System.Object)));
        }
Ejemplo n.º 10
0
        public void T003_Inline_Using_Collection()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T003_Inline_Using_Collection.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> result = new List <object> {
                1, 0, 1, 1, 0,
            };

            Assert.IsTrue(mirror.CompareArrays("Results", result, typeof(System.Int64)));
        }
Ejemplo n.º 11
0
        public void T008_Inline_Returing_Different_Ranks()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T008_Inline_Returing_Different_Ranks.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> x = new List <object> {
                1, 1
            };

            Assert.IsTrue(mirror.CompareArrays("x", x, typeof(System.Int64)));
        }
Ejemplo n.º 12
0
        public void T003_Inline_Using_Collection()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");

            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Associative\\InlineCondition\\T003_Inline_Using_Collection.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> result = new List <object>()
            {
                1, 0, 1, 1, 0,
            };

            Assert.IsTrue(mirror.CompareArrays("Results", result, typeof(System.Int64)));
        }
Ejemplo n.º 13
0
        public void T007_Inline_Using_Collections_And_Replication()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T007_Inline_Using_Collections_And_Replication.CollectionFunctionCall.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> b = new List <object> {
                1, 6, 3, 10, 5
            };
            List <Object> c = new List <object> {
                4, 6, 8, 0, 2
            };
            List <Object> d = new List <object> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <Object> e1 = new List <object> {
                2, 3
            };

            Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("c", c, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("d", d, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("e1", e1, typeof(System.Int64)));
        }
Ejemplo n.º 14
0
        public void T004_Inline_Inside_Class_Constructor_and_replication()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");

            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Associative\\InlineCondition\\T004_Inline_Inside_Class_Constructor_and_replication.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> values = new List <object>()
            {
                true, false
            };

            Assert.IsTrue(mirror.CompareArrays("values", values, typeof(System.Boolean)));
        }
Ejemplo n.º 15
0
        public void T009_Inline_Using_Function_Call_And_Collection_And_Replication()
        {
            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Imperative\\InlineCondition\\T009_Inline_Using_Function_Call_And_Collection_And_Replication.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> b = new List <object> {
                2, 4, 6
            };

            Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));
            Assert.IsTrue((Int64)mirror.GetValue("a").Payload == 10);
            Assert.IsTrue((Int64)mirror.GetValue("c").Payload == 13);
            Assert.IsTrue((Int64)mirror.GetValue("d").Payload == 53);
        }
Ejemplo n.º 16
0
        public void T007_Inline_Using_Collections_And_Replication()
        {
            string          src    = @"
	def even : int(a : int)
	{
		return = a * 2;
	}
	a =1..10..1 ; //{1,2,3,4,5,6,7,8,9,10}
	i = 1..5; 
	b = ((a[i] % 2) > 0)? even(a[i]) : a ;  // { 1, 6, 3, 10, 5 }	
	c = ((a[0] % 2) > 0)? even(a[i]) : a ; // { 4, 6, 8, 10, 12 }
	d = ((a[-2] % 2) == 0)? even(a[i]) : a ; // { 1, 2,..10}
	e1 = (a[-2] == d[9])? 9 : a[1..2]; // { 2, 3 }
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // following verification might need to be updated for current implementation, once the defect above is fixed
            // b = ((a[i] % 2) > 0)? even(a[i]) : a;
            // replication only is supported on condition, not the overall expression.
            // List<Object> b = new List<object>() { 1, 6, 3, 10, 5 };
            // Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));
            List <Object> c = new List <object>()
            {
                4, 6, 8, 10, 12
            };
            List <Object> d = new List <object>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <Object> e1 = new List <object>()
            {
                2, 3
            };

            Assert.IsTrue(mirror.CompareArrays("c", c, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("d", d, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("e1", e1, typeof(System.Int64)));
        }
Ejemplo n.º 17
0
        public void T005_Inline_Using_2_Collections_In_Condition()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");

            ExecutionMirror mirror = thisTest.RunScript(@"..\\..\\..\\Scripts\\TD\\Associative\\InlineCondition\\T005_Inline_Using_2_Collections_In_Condition.ds");

            // expected "StatementUsedInAssignment" warning
            List <Object> c1 = new List <object>()
            {
                false, false, false
            };
            List <Object> c2 = new List <object>()
            {
                false, false, false
            };
            List <Object> c3 = new List <object>()
            {
                false, false, false
            };

            Assert.IsTrue(mirror.CompareArrays("c1", c1, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c2", c2, typeof(System.Boolean)));
            Assert.IsTrue(mirror.CompareArrays("c3", c3, typeof(System.Boolean)));
        }
Ejemplo n.º 18
0
        public void T007_Inline_Using_Collections_And_Replication()
        {
            string          src    = @"[Imperative]
{
	def even : int(a : int)
	{
		return = a * 2;
	}
	a =1..10..1 ; //{1,2,3,4,5,6,7,8,9,10}
	i = 1..5; 
	b = ((a[i] % 2) > 0)? even(a[i]) : a ;  // { 1, 6, 3, 10, 5 }	
	c = ((a[0] % 2) > 0)? even(a[i]) : a ; // { 4, 6, 8, `0, `2 }
	d = ((a[-2] % 2) == 0)? even(a[i]) : a ; // { 1, 2,..10}
	e1 = (a[-2] == d[9])? 9 : a[1..2]; // { 2, 3 }
}
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> b = new List <object> {
                1, 6, 3, 10, 5
            };
            List <Object> c = new List <object> {
                4, 6, 8, 0, 2
            };
            List <Object> d = new List <object> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            List <Object> e1 = new List <object> {
                2, 3
            };

            Assert.IsTrue(mirror.CompareArrays("b", b, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("c", c, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("d", d, typeof(System.Int64)));
            Assert.IsTrue(mirror.CompareArrays("e1", e1, typeof(System.Int64)));
        }
Ejemplo n.º 19
0
        public void RangeExpr001()
        {
            String code =
                @"a;
                        [Imperative]
                        {
	                        a = 1..1.5..0.2;                           
                        }
                        ";
            ExecutionMirror mirror = thisTest.RunScriptSource(code);
            List <Object>   result = new List <Object> {
                1.0, 1.2, 1.4
            };

            Assert.IsTrue(mirror.CompareArrays("a", result, typeof(System.Double)));
        }
Ejemplo n.º 20
0
        public void T008_Inline_Returing_Different_Ranks()
        {
            string          src    = @"x;
[Imperative]
{
	a = { 0, 1, 2, 4};
	x = a > 1 ? 0 : {1,1}; // { 1, 1} ? 
	x_0 = x[0];
	x_1 = x[1];
}
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> x = new List <object> {
                1, 1
            };

            Assert.IsTrue(mirror.CompareArrays("x", x, typeof(System.Int64)));
        }
Ejemplo n.º 21
0
        public void T051_Test_Identifier_Scope_07()
        {
            String code =
                @"
@a;
[Imperative]
{	
   @a1 = 1;
   @a2 = 5;
   @a3 = 1;
   @a = @a1..@a2..@a3;
			
}
                        
";
            ExecutionMirror mirror = thisTest.RunScriptSource(code);
            List <Object>   result = new List <Object> {
                1, 2, 3, 4, 5
            };

            Assert.IsTrue(mirror.CompareArrays("@a", result, typeof(System.Double)));
        }
Ejemplo n.º 22
0
        public void T003_Inline_Using_Collection()
        {
            //Assert.Fail("1456751 - Sprint16 : Rev 990 : Inline conditions not working with replication over collections");
            string          src    = @"
	Passed = 1;
	Failed = 0;
	Einstein = 56;
	BenBarnes = 90;
	BenGoh = 5;
	Rameshwar = 80;
	Jun = 68;
	Roham = 50;
	Smartness = { BenBarnes, BenGoh, Jun, Rameshwar, Roham }; // { 1, 0, 1, 1, 0 }
	Results = Smartness > Einstein ? Passed : Failed;
";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> result = new List <object>()
            {
                1, 0, 1, 1, 0,
            };

            Assert.IsTrue(mirror.CompareArrays("Results", result, typeof(System.Int64)));
        }
Ejemplo n.º 23
0
        public void T003_Inline_Using_Collection()
        {
            string          src    = @"[Imperative]
{
	Passed = 1;
	Failed = 0;
	Einstein = 56;
	BenBarnes = 90;
	BenGoh = 5;
	Rameshwar = 80;
	Jun = 68;
	Roham = 50;
	Smartness = { BenBarnes, BenGoh, Jun, Rameshwar, Roham }; // { 1, 0, 1, 1, 0 }
	Results = Smartness > Einstein ? Passed : Failed;
	
}";
            ExecutionMirror mirror = thisTest.RunScriptSource(src);
            // expected "StatementUsedInAssignment" warning
            List <Object> result = new List <object> {
                1, 0, 1, 1, 0,
            };

            Assert.IsTrue(mirror.CompareArrays("Results", result, typeof(System.Int64)));
        }