Exemplo n.º 1
0
        public void VBNetReturnStatementTest()
        {
            ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return 5");

            Assert.IsFalse(returnStatement.Expression.IsNull);
            Assert.IsTrue(returnStatement.Expression is PrimitiveExpression);
        }
        public void VBNetGlobalTypeDeclaration()
        {
            LocalVariableDeclaration lvd     = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a As Global.System.String");
            TypeReference            typeRef = lvd.GetTypeForVariable(0);

            Assert.IsTrue(typeRef.IsGlobal);
            Assert.AreEqual("System.String", typeRef.Type);
        }
Exemplo n.º 3
0
        public void VBNetUsingStatementTest2()
        {
            string         usingText = @"
Using nf As Font = New Font()
	Bla(nf)
End Using";
            UsingStatement usingStmt = ParseUtilVBNet.ParseStatement <UsingStatement>(usingText);
            // TODO : Extend test.
        }
Exemplo n.º 4
0
        public void VBNetSimpleIfStatementTest2()
        {
            IfElseStatement ifElseStatement = ParseUtilVBNet.ParseStatement <IfElseStatement>("If True THEN\n END\n END IF");

            Assert.IsFalse(ifElseStatement.Condition.IsNull);
            Assert.IsTrue(ifElseStatement.TrueStatement.Count == 1, "true count != 1:" + ifElseStatement.TrueStatement.Count);
            Assert.IsTrue(ifElseStatement.FalseStatement.Count == 0, "false count != 0:" + ifElseStatement.FalseStatement.Count);

            Assert.IsTrue(ifElseStatement.TrueStatement[0] is BlockStatement, "Statement was: " + ifElseStatement.TrueStatement[0]);
        }
Exemplo n.º 5
0
        public void VBNetUsingStatementTest()
        {
            string         usingText = @"
Using nf As New System.Drawing.Font(""Arial"", 12.0F, FontStyle.Bold)
        c.Font = nf
        c.Text = ""This is 12-point Arial bold""
End Using";
            UsingStatement usingStmt = ParseUtilVBNet.ParseStatement <UsingStatement>(usingText);
            // TODO : Extend test.
        }
        void VBNetTestAssignmentExpression(string program, AssignmentOperatorType op)
        {
            StatementExpression  se = ParseUtilVBNet.ParseStatement <StatementExpression>(program);
            AssignmentExpression ae = se.Expression as AssignmentExpression;

            Assert.AreEqual(op, ae.Op);

            Assert.IsTrue(ae.Left is IdentifierExpression);
            Assert.IsTrue(ae.Right is IdentifierExpression);
        }
Exemplo n.º 7
0
        public void VBNetLocalVariableNamedOverrideDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim override As Integer = 5");

            Assert.AreEqual(1, lvd.Variables.Count);
            Assert.AreEqual("override", lvd.Variables[0].Name);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("Integer", type.Type);
            Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value);
        }
Exemplo n.º 8
0
        public void VBNetLocalArrayDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a() As Integer");

            Assert.AreEqual(1, lvd.Variables.Count);
            Assert.AreEqual("a", lvd.Variables[0].Name);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("Integer", type.Type);
            Assert.AreEqual(new int[] { 0 }, type.RankSpecifier);
        }
Exemplo n.º 9
0
        public void VBNetGenericLocalVariableDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a As G(Of Integer)");

            Assert.AreEqual(1, lvd.Variables.Count);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("G", type.Type);
            Assert.AreEqual(1, type.GenericTypes.Count);
            Assert.AreEqual("Integer", type.GenericTypes[0].Type);
        }
Exemplo n.º 10
0
        public void VBNetGenericWithArrayLocalVariableDeclarationTest1()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a As G(Of Integer)()");

            Assert.AreEqual(1, lvd.Variables.Count);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("G", type.Type);
            Assert.AreEqual(1, type.GenericTypes.Count);
            Assert.AreEqual("Integer", type.GenericTypes[0].Type);
            Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
            Assert.IsFalse(type.GenericTypes[0].IsArrayType);
            Assert.AreEqual(new int[] { 0 }, type.RankSpecifier);
        }
Exemplo n.º 11
0
        public void VBNetComplexGenericLocalVariableDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim where As Generic(Of Printable, G(Of Printable()))");

            Assert.AreEqual(1, lvd.Variables.Count);
            Assert.AreEqual("where", lvd.Variables[0].Name);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("Generic", type.Type);
            Assert.AreEqual(2, type.GenericTypes.Count);
            Assert.AreEqual("Printable", type.GenericTypes[0].Type);
            Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
            Assert.AreEqual("G", type.GenericTypes[1].Type);
            Assert.AreEqual(1, type.GenericTypes[1].GenericTypes.Count);
            Assert.AreEqual("Printable", type.GenericTypes[1].GenericTypes[0].Type);
        }
Exemplo n.º 12
0
        public void VBNetLocalJaggedArrayDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a(10)() As Integer");

            Assert.AreEqual(1, lvd.Variables.Count);
            Assert.AreEqual("a", lvd.Variables[0].Name);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("Integer", type.Type);
            Assert.AreEqual(new int[] { 0, 0 }, type.RankSpecifier);
            ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer;

            Assert.AreEqual(new int[] { 0, 0 }, ace.CreateType.RankSpecifier);
            Assert.AreEqual(1, ace.Arguments.Count);
            Assert.AreEqual(11, ((PrimitiveExpression)ace.Arguments[0]).Value);
        }
Exemplo n.º 13
0
        public void VBNetNestedGenericLocalVariableDeclarationTest()
        {
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a as MyType(of string).InnerClass(of integer).InnerInnerClass");

            Assert.AreEqual(1, lvd.Variables.Count);
            InnerClassTypeReference ic = (InnerClassTypeReference)lvd.GetTypeForVariable(0);

            Assert.AreEqual("InnerInnerClass", ic.Type);
            Assert.AreEqual(0, ic.GenericTypes.Count);
            ic = (InnerClassTypeReference)ic.BaseType;
            Assert.AreEqual("InnerClass", ic.Type);
            Assert.AreEqual(1, ic.GenericTypes.Count);
            Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType);
            Assert.AreEqual("MyType", ic.BaseType.Type);
            Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
            Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType);
        }
Exemplo n.º 14
0
        public void VBNetLocalArrayDeclarationWithInitializationAndLowerBoundTest()
        {
            // VB.NET allows only "0" as lower bound
            LocalVariableDeclaration lvd = ParseUtilVBNet.ParseStatement <LocalVariableDeclaration>("Dim a(0 To 10) As Integer");

            Assert.AreEqual(1, lvd.Variables.Count);
            Assert.AreEqual("a", lvd.Variables[0].Name);
            TypeReference type = lvd.GetTypeForVariable(0);

            Assert.AreEqual("Integer", type.Type);
            Assert.AreEqual(new int[] { 0 }, type.RankSpecifier);
            ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer;

            Assert.AreEqual(new int[] { 0 }, ace.CreateType.RankSpecifier);
            Assert.AreEqual(1, ace.Arguments.Count);
            Assert.AreEqual(11, ((PrimitiveExpression)ace.Arguments[0]).Value);
        }
Exemplo n.º 15
0
 public void VBNetStopStatementTest()
 {
     StopStatement stopStatement = ParseUtilVBNet.ParseStatement <StopStatement>("Stop");
 }
Exemplo n.º 16
0
        public void VBNetEmptyReturnStatementTest()
        {
            ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return");

            Assert.IsTrue(returnStatement.Expression.IsNull);
        }
Exemplo n.º 17
0
        public void VBNetLabelStatementTest()
        {
            LabelStatement labelStmt = ParseUtilVBNet.ParseStatement <LabelStatement>("myLabel: Console.WriteLine()");

            Assert.AreEqual("myLabel", labelStmt.Label);
        }
Exemplo n.º 18
0
 public void VBNetRaiseEventStatementTest()
 {
     RaiseEventStatement raiseEventStatement = ParseUtilVBNet.ParseStatement <RaiseEventStatement>("RaiseEvent MyEvent(a, 5, (6))");
 }
Exemplo n.º 19
0
 public void VBNetForNextStatementTest()
 {
     ForNextStatement forNextStatement = ParseUtilVBNet.ParseStatement <ForNextStatement>("For i=0 To 10 Step 2 : Next i");
 }
Exemplo n.º 20
0
 public void VBNetEraseStatementTest()
 {
     EraseStatement eraseStatement = ParseUtilVBNet.ParseStatement <EraseStatement>("Erase a, b, c");
 }
Exemplo n.º 21
0
 public void VBNetOnErrorStatementTest()
 {
     OnErrorStatement onErrorStatement = ParseUtilVBNet.ParseStatement <OnErrorStatement>("On Error Goto err");
 }
Exemplo n.º 22
0
 public void VBNetReDimStatementTest2()
 {
     ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim calCheckData(channelNum, lambdaNum).ShiftFromLastFullCalPixels(CalCheckPeak.HighWavelength)");
 }
 public void VBNetAddHandlerTest()
 {
     AddHandlerStatement addHandlerStatement = ParseUtilVBNet.ParseStatement <AddHandlerStatement>("AddHandler Obj.Ev_Event, AddressOf EventHandler");
 }
Exemplo n.º 24
0
 public void VBNetErrorStatementTest()
 {
     ErrorStatement errorStatement = ParseUtilVBNet.ParseStatement <ErrorStatement>("Error a");
 }
Exemplo n.º 25
0
 public void VBNetForeachStatementTest()
 {
     ForeachStatement foreachStmt = ParseUtilVBNet.ParseStatement <ForeachStatement>("For Each i As Integer In myColl : Next");
     // TODO : Extend test.
 }
Exemplo n.º 26
0
 public void VBNetWithStatementTest()
 {
     WithStatement withStatement = ParseUtilVBNet.ParseStatement <WithStatement>("With MyObj : End With");
 }
Exemplo n.º 27
0
 public void VBNetReDimStatementTest()
 {
     ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim Preserve MyArray(15)");
 }
Exemplo n.º 28
0
        public void VBNetGotoStatementTest()
        {
            GotoStatement gotoStmt = ParseUtilVBNet.ParseStatement <GotoStatement>("GoTo myLabel");

            Assert.AreEqual("myLabel", gotoStmt.Label);
        }
Exemplo n.º 29
0
 public void VBNetRemoveHandlerTest()
 {
     RemoveHandlerStatement removeHandlerStatement = ParseUtilVBNet.ParseStatement <RemoveHandlerStatement>("RemoveHandler MyHandler, AddressOf MyMethod");
 }
Exemplo n.º 30
0
 public void VBNetResumeStatementTest()
 {
     ResumeStatement resumeStatement = ParseUtilVBNet.ParseStatement <ResumeStatement>("Resume");
 }