コード例 #1
0
        public void VBNetReturnStatementTest()
        {
            ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return 5");

            Assert.IsFalse(returnStatement.Expression.IsNull);
            Assert.IsTrue(returnStatement.Expression is PrimitiveExpression);
        }
コード例 #2
0
        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);
        }
コード例 #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.
        }
コード例 #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]);
        }
コード例 #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.
        }
コード例 #6
0
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #15
0
 public void VBNetStopStatementTest()
 {
     StopStatement stopStatement = ParseUtilVBNet.ParseStatement <StopStatement>("Stop");
 }
コード例 #16
0
        public void VBNetEmptyReturnStatementTest()
        {
            ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return");

            Assert.IsTrue(returnStatement.Expression.IsNull);
        }
コード例 #17
0
        public void VBNetLabelStatementTest()
        {
            LabelStatement labelStmt = ParseUtilVBNet.ParseStatement <LabelStatement>("myLabel: Console.WriteLine()");

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

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