public void TestMethodOverlaodAndArrayInput2() { string code = @" class A { def execute(a : A) { return = -1; } } class B extends A { def execute(arr : B[]) { return = 2; } } class C extends B { } b = B.B(); arr = {C.C(), B.B(), C.C()}; val = b.execute(arr); " ; ExecutionMirror mirror = thisTest.RunScriptSource(code); thisTest.Verify("val", 2); thisTest.VerifyBuildWarningCount(0); }
public void T01_WhileBreakContinue() { string src = @"x; y; [Imperative] { x = 0; y = 0; while (true) { x = x + 1; if (x > 10) break; if ((x == 1) || (x == 3) || (x == 5) || (x == 7) || (x == 9)) continue; y = y + 1; } } "; ExecutionMirror mirror = thisTest.RunScriptSource(src); Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 11); Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 5); }
public void RecursionImperative01() { String code = @" def f(x) { return = [Imperative] { if(x <= 1) { return = 1; } else { return = f(x - 1) + x; } } } a = f(3); " ; thisTest.RunScriptSource(code); thisTest.Verify("a", 6); }
public void SanityCheckVMExecution() { var mirror = thisTest.RunScriptSource("a = 4 + 5;"); var a = mirror.GetFirstValue("a").Payload; Assert.IsTrue((Int64)a == 9); }
public void Collection_Assignment_1() { string code = @" c; d; e; [Imperative] { a = { {1,2}, {3,4} }; a[1] = {-1,-2,3}; c = a[1][1]; d = a[0]; b = { 1, 2 }; b[0] = {2,2}; e = b[0]; }"; ExecutionMirror mirror = thisTest.RunScriptSource(code); object[] expectedResult2 = { 1, 2 }; object[] expectedResult3 = { 2, 2 }; thisTest.Verify("c", -2, 0); thisTest.Verify("d", expectedResult2, 0); thisTest.Verify("e", expectedResult3, 0); }
public void BasicRunAndVerify() { 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; "; thisTest.RunScriptSource(code); thisTest.Verify("x", 123); thisTest.Verify("y", 345); }
public void InheritanceTest01() { String code = @" class RigidBody { id : var; velocity : var; constructor RigidBody(objID : int, vel : double) { id = objID; velocity = vel; } def GetVelocity : double(drag : int) { return = velocity * drag; } } class Particle extends RigidBody { lifetime : var; constructor Particle(objID : int, vel : double, life : double) { id = objID; velocity = vel; lifetime = life; } } // TODO Jun: Fix defect, allow statements (or maybe just preprocs?) before a class decl // Define some constants kRigidBodyID = 0; kParticleID = 1; kGravityCoeff = 9.8; //================================ // Simulate physical object 1 //================================ // Construct a base rigid body rb = RigidBody.RigidBody(kRigidBodyID, kGravityCoeff); rbVelocity = rb.GetVelocity(2); //================================ // Simulate physical object 2 //================================ // Construct a particle that inherits from a rigid body kLifetime = 0.25; p = Particle.Particle(kParticleID, kGravityCoeff, kLifetime); lt = p.lifetime; particleVelocity = rb.GetVelocity(4); " ; ExecutionMirror mirror = thisTest.RunScriptSource(code); Assert.IsTrue((double)mirror.GetValue("rbVelocity").Payload == 19.6); Assert.IsTrue((double)mirror.GetValue("lt").Payload == 0.25); Assert.IsTrue((double)mirror.GetValue("particleVelocity").Payload == 39.2); }
public void TestArray01() { string code = @"a = {10, 20, 30};"; thisTest.RunScriptSource(code); Assert.IsFalse(ProtoCore.Utils.HeapUtils.IsHeapCyclic(core)); }
public void TestArrayPromoteAndCastIList() { string code = @" import(""FFITarget.dll""); a = 5; o1 = RegressionTargets.AverageIList(a); "; ExecutionMirror mirror = thisTest.RunScriptSource(code); thisTest.Verify("o1", 5.0); }
public void DupImportTest() { var mirror = thisTest.RunScriptSource( @"import(""FFITarget.dll""); a = A.DupTargetTest.DupTargetTest(); aO = a.Foo(); b = B.DupTargetTest.DupTargetTest(); bO = b.Foo(); " ); Assert.IsTrue((Int64)mirror.GetFirstValue("aO").Payload == 1); Assert.IsTrue((Int64)mirror.GetFirstValue("bO").Payload == 2); }
public void T002_ClassConstructorNestedScope_InlineCondition() { String code = @" class A { a : int; constructor A ( x ) { [Imperative] { [Associative] { [Imperative] { a = x > 1 ? 1 : 0; } } } } } t1 = A.A(2).a; " ; ExecutionMirror mirror = thisTest.RunScriptSource(code); thisTest.Verify("t1", 1); }
public void RedefineWithExpressionLists04() { String code = @" class C { x : var[]; constructor C() { x = {1, 2, 3, 4, 5, 6}; } def f(a : int) { x = x[a] * x[a + 1]; return = x; } } x = 2; p = C.C(); x = p.f(x); "; thisTest.RunScriptSource(code); thisTest.Verify("x", new object[] { 12 }); }
public void MinimalSetValue() { String code = @" a = 1; " ; ExecutionMirror mirror = thisTest.RunScriptSource(code); StackValue svA = mirror.GetValue("a").DsasmValue; Assert.IsTrue(svA.optype == AddressType.Int); Assert.IsTrue(svA.opdata == 1); mirror.SetValueAndExecute("a", 2); StackValue svA2 = mirror.GetValue("a").DsasmValue; Assert.IsTrue(svA2.optype == AddressType.Int); Assert.IsTrue(svA2.opdata == 2); }
public void DupImportTest() { var mirror = thisTest.RunScriptSource( @"import(""FFITarget.dll""); a = A.DupTargetTest.DupTargetTest(); aO = a.Foo(); b = B.DupTargetTest.DupTargetTest(); bO = b.Foo(); " ); // Tracked by http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-1947 string defectID = "MAGN-1947 IntegrationTests.NamespaceConflictTest.DupImportTest"; Assert.IsTrue((Int64)mirror.GetFirstValue("aO").Payload == 1, defectID); Assert.IsTrue((Int64)mirror.GetFirstValue("bO").Payload == 2, defectID); }
public void TestConds01() { String code = @" f0;f1;f2;f3;t0;t1;t2;t3;t4;t5;t6;t7; [Imperative] { f0 = 5 > 6; f1 = (5 > 6); f2 = 5 >= 6; f3 = (5 >= 6); t0 = 5 == 5; t1 = (5 == 5); t2 = 5 < 6; t3 = (5 < 6); t4 = 5 <= 6; t5 = (5 <= 6); t6 = 5 <= 5; t7 = (5 <= 5); } "; 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); thisTest.Verify("t3", true); thisTest.Verify("t4", true); thisTest.Verify("t5", true); thisTest.Verify("t6", true); thisTest.Verify("t7", true); }
public void T01_SampleTestUsingCodeWithinTestFunction() { String code = @"variable;[Imperative] { variable = 5; } "; ExecutionMirror mirror = thisTest.RunScriptSource(code); Obj o = mirror.GetValue("variable"); Assert.IsTrue((Int64)o.Payload == 5); }
public void Test() { String code = @" c = 3.0..5.0;//3.0,4.0,5.0 " ; //Assert.Fail("StackOverflow"); thisTest.RunScriptSource(code); }
public void BasicAssign() { string code = @"a = 16; b = 42; c = a + b;"; ExecutionMirror mirror = thisTest.RunScriptSource(code); thisTest.Verify("a", 16); thisTest.Verify("b", 42); thisTest.Verify("c", 58); }
public void TestAddition01() { GraphToDSCompiler.GraphCompiler gc = GraphToDSCompiler.GraphCompiler.CreateInstance(); gc.CreateOperatorNode(1, "+"); object o1 = 10; gc.CreateLiteralNode(2, o1); object o2 = 11; gc.CreateLiteralNode(3, o2); gc.ConnectNodes(2, 0, 1, 0); gc.ConnectNodes(3, 0, 1, 1); string mmx = gc.GetGraph2String(); mmx = mmx.Trim(); ExecutionMirror mirror = thisTest.RunScriptSource(mmx); Obj o = mirror.GetValue("temp20001"); Assert.IsTrue((Int64)o.Payload == 21); }
public void TestRoundTrip_Assign01() { //================================= // 1. Build AST // 2. Execute AST and verify // 3. Convert AST to source // 4. Execute source and verify //================================= int result1 = 10; ExecutionMirror mirror = null; // 1. Build AST ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode( new ProtoCore.AST.AssociativeAST.IdentifierNode("a"), new ProtoCore.AST.AssociativeAST.IntNode(10), ProtoCore.DSASM.Operator.assign); List <ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List <ProtoCore.AST.AssociativeAST.AssociativeNode>(); astList.Add(assign); // 2. Execute AST and verify mirror = thisTest.RunASTSource(astList); Assert.IsTrue((Int64)mirror.GetValue("a").Payload == result1); // 3. Convert AST to source ProtoCore.CodeGenDS codegenDS = new ProtoCore.CodeGenDS(astList); string code = codegenDS.GenerateCode(); // 4. Execute source and verify mirror = thisTest.RunScriptSource(code); Assert.IsTrue((Int64)mirror.GetValue("a").Payload == result1); }
public void T001_Inline_Using_Function_Call() { string src = @" def fo1 : int(a1 : int) { return = a1 * a1; } a = 10; b = 20; smallest1 = a < b ? a : b; largest1 = a > b ? a : b; d = fo1(a); smallest2 = (fo1(a)) < (fo1(b)) ? (fo1(a)) : (fo1(a)); //100 largest2 = (fo1(a)) > (fo1(b)) ? (fo1(a)) : (fo1(b)); //400 "; ExecutionMirror mirror = thisTest.RunScriptSource(src); // expected "StatementUsedInAssignment" warning Assert.IsTrue((Int64)mirror.GetValue("smallest2").Payload == 100); Assert.IsTrue((Int64)mirror.GetValue("largest2").Payload == 400); }
public void Regress_1454075() { string dscode = @" class Vector{ constructor Vector() {} } v = Vector.Vector();"; ExecutionMirror mirror = thisTest.RunScriptSource(dscode); //Compilation test. }
public void StackOverflow_DNL_1467365() { string code = @"class test { a; constructor test(a1 : int, b1 : int, c1 : int) { a = a1; } } class Row { constructor ByPoints(yy:int, xx: int) { [Imperative] { for(j in 0..36) { tread = test.test(yy, xx, 3); rise = test.test(tread.a,xx,3); } } } } a = 0..18..1; b = 0..18..1; Rows = Row.ByPoints(a, b);"; thisTest.RunScriptSource(code); }
public void RunPropertyChangedForRunMode() { string code = @"import (Foo from ""ProtoTest.dll""); foo = Foo.GetInstance(); foo.ID = 17; id = foo.ID; Foo.SetID(foo, 41); "; var testRunner = new TestFrameWork(); testRunner.RunScriptSource(code); testRunner.Verify("id", 41); }
public void ExecTraceVMClassVerifyTLSCleared() { var mirror = thisTest.RunScriptSource( @"import(""FFITarget.dll""); x = 1; wrapper = WrapperObject.WrapperObject(x); x = 2; x = 3; wrapper = null; "); Assert.IsTrue(WrappersTest.CleanedObjects.Count == 1); }
public void RunPropertyChangedNegative() { string code = @"import (Foo from ""ProtoTest.dll""); foo = Foo.GetInstance(); foo.ID = 17; id = foo.ID; id = bar.ID; // Redefinition Foo.SetID(foo, 41); " ; var testRunner = new TestFrameWork(); testRunner.RunScriptSource(code); testRunner.Verify("id", null); }
public void T014_Robert_2012_09_14_MultipleNestedLanguage() { string errmsg = ""; string code = @" def foo () { t = [Imperative] { t1 = [Associative] { t2 = 6; return = t2; } return = t1; } return = t; } def foo2 () { t = [Associative] { t1 = [Imperative] { t2 = 6; return = t2; } return = t1; } return = t; } p1 = foo(); // expected 6, got null p2 = foo2();// expected 6, got 6 "; thisTest.RunScriptSource(code, ""); thisTest.Verify("p1", 6); thisTest.Verify("p2", 6); //thisTest.Verify("totalLength", 2.0 ); // this needs to be verified after the defect is fixed }
public void TDD_SimpleIfCondition_1() { String code = @" r = [Imperative] { //b = 1; if (null==false) { return = ""null==true""; } else if(!null) { return = ""!null==true""; } return = ""expected""; } "; thisTest.RunScriptSource(code); thisTest.Verify("r", "expected"); }
public void UpdateMember01() { String code = @" class C { x; constructor C() { x = 1; } } p = C.C(); a = p.x; p.x = 10; "; ExecutionMirror mirror = thisTest.RunScriptSource(code); Obj o = mirror.GetValue("a"); Assert.IsTrue((Int64)o.Payload == 10); }
public void TestTrigonometricFunction() { String code = @"import(""math.dll""); a = -0.5; b = 0.5; c = 45; d = -45; e = 2.90; f = 1.90; x1 = Math.Acos(a); y1 = Math.Asin(a); z1 = Math.Atan(a); r1 = Math.Atan2(e, f); x2 = Math.Acos(b); y2 = Math.Asin(b); z2 = Math.Atan(b); x3 = Math.Sin(c); y3 = Math.Cos(c); z3 = Math.Tan(c); r3 = Math.Tanh(c); x4 = Math.Sin(d); y4 = Math.Cos(d); z4 = Math.Tan(d); r4 = Math.Tanh(d); " ; ExecutionMirror mirror = thisTest.RunScriptSource(code); thisTest.Verify("x1", 120.0); thisTest.Verify("y1", -30.0); thisTest.Verify("z1", -26.565051177078); thisTest.Verify("r1", 56.7682889320206); thisTest.Verify("x2", 60.0); thisTest.Verify("y2", 30.0); thisTest.Verify("z2", 26.565051177078); thisTest.Verify("x3", 0.707106781186547); thisTest.Verify("y3", 0.707106781186547); thisTest.Verify("z3", 1.0); thisTest.Verify("r3", 1.0); thisTest.Verify("x4", -0.707106781186547); thisTest.Verify("y4", 0.707106781186547); thisTest.Verify("z4", -1.0); thisTest.Verify("r4", -1.0); }
public void TestNamespaceImport() { string code = @"import(MicroFeatureTests from ""ProtoTest.dll"");"; TestFrameWork theTest = new TestFrameWork(); var mirror = theTest.RunScriptSource(code); TestFrameWork.VerifyBuildWarning(ProtoCore.BuildData.WarningID.kMultipleSymbolFound); string[] classes = theTest.GetAllMatchingClasses("MicroFeatureTests"); Assert.True(classes.Length > 1, "More than one implementation of MicroFeatureTests class expected"); }
public void TestDefaultConstructorNotAvailableOnAbstractClass() { string code = @" import(""ProtoGeometry.dll""); "; TestFrameWork theTest = new TestFrameWork(); ExecutionMirror mirror = theTest.RunScriptSource(code); //Verify that Geometry.Geometry constructor deson't exists theTest.VerifyMethodExists("Geometry", "Geometry", false); }
public void TestNonBrowsableInterfaces() { string code = @" import(""ProtoGeometry.dll""); "; TestFrameWork theTest = new TestFrameWork(); ExecutionMirror mirror = theTest.RunScriptSource(code); Assert.IsTrue(theTest.GetClassIndex("Geometry") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IColor") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IDesignScriptEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IDisplayable") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPersistentObject") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPersistencyManager") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICoordinateSystemEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IGeometryEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPointEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICurveEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ILineEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICircleEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IArcEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IBSplineCurveEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IBRepEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ISurfaceEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IBSplineSurfaceEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPlaneEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ISolidEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPrimitiveSolidEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IConeEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICuboidEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ISphereEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IPolygonEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ISubDMeshEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IBlockEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IBlockHelper") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ITopologyEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IShellEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICellEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IFaceEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ICellFaceEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IVertexEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IEdgeEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("ITextEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("IGeometryFactory") == ProtoCore.DSASM.Constants.kInvalidIndex); }
public void TestImportBrowsableClass() { string code = @" import(NurbsCurve from ""ProtoGeometry.dll""); "; TestFrameWork theTest = new TestFrameWork(); ExecutionMirror mirror = theTest.RunScriptSource(code); //This import must import BSplineCurve and related classes. Assert.IsTrue(theTest.GetClassIndex("Geometry") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Point") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Vector") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Solid") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Surface") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Plane") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("CoordinateSystem") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("CoordinateSystem") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Curve") != ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("NurbsCurve") != ProtoCore.DSASM.Constants.kInvalidIndex); //Non-browsable as well as unrelated class should not be imported. Assert.IsTrue(theTest.GetClassIndex("DesignScriptEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Circle") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("SubDivisionMesh") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("GeometryFactory") == ProtoCore.DSASM.Constants.kInvalidIndex); }
public void TestImportNonBrowsableClass() { string code = @" import(DesignScriptEntity from ""ProtoGeometry.dll""); "; TestFrameWork theTest = new TestFrameWork(); ExecutionMirror mirror = theTest.RunScriptSource(code); Assert.IsTrue(theTest.GetClassIndex("Geometry") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("Point") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("DesignScriptEntity") == ProtoCore.DSASM.Constants.kInvalidIndex); Assert.IsTrue(theTest.GetClassIndex("GeometryFactory") == ProtoCore.DSASM.Constants.kInvalidIndex); }
Assert.IsTrue((Int64)val.Payload == 202); // expect to re-execute id2 = bar.ID Assert.AreEqual(5, vms.ExecutionCursor.StartInclusive.LineNo); vms = runner_.StepOver(); val = GetWatchValue(core_, @"id2"); Assert.IsTrue((Int64)val.Payload == 202); }
Assert.IsTrue((Int64)val.Payload == 101); val = GetWatchValue(core_, @"id2"); Assert.IsTrue((Int64)val.Payload == 101); fooSingleton.ID = 202; // expect to re-execute id1 = foo.ID vms = runner_.StepOver(); Assert.AreEqual(3, vms.ExecutionCursor.StartInclusive.LineNo); vms = runner_.StepOver();