Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void VBNetJuggedNamespaceTest()
        {
            string program = "Namespace N1 'TestNamespace\n" +
                             "    Namespace N2   ' Declares a namespace named N2 within N1.\n" +
                             "    End Namespace\n" +
                             "End Namespace\n";

            NamespaceDeclaration ns = ParseUtilVBNet.ParseGlobal <NamespaceDeclaration>(program);

            Assert.AreEqual("N1", ns.Name);

            Assert.IsTrue(ns.Children[0] is NamespaceDeclaration);

            ns = (NamespaceDeclaration)ns.Children[0];

            Assert.AreEqual("N2", ns.Name);
        }
Beispiel #4
0
        public void VBNetGenericMethodInInterface()
        {
            const string      program = @"Interface MyInterface
	Function MyMethod(Of T As {ISomeInterface})(a As T) As T
	End Interface"    ;
            TypeDeclaration   td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);
            MethodDeclaration md      = (MethodDeclaration)td.Children[0];

            Assert.AreEqual("T", md.TypeReference.Type);
            Assert.AreEqual(1, md.Parameters.Count);
            Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
            Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);

            Assert.AreEqual(1, md.Templates.Count);
            Assert.AreEqual("T", md.Templates[0].Name);
            Assert.AreEqual(1, md.Templates[0].Bases.Count);
            Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type);
        }
Beispiel #5
0
 public void VBNetOnErrorStatementTest()
 {
     OnErrorStatement onErrorStatement = ParseUtilVBNet.ParseStatement <OnErrorStatement>("On Error Goto err");
 }
        public void SimpleVBNetDelegateDeclarationTest()
        {
            string program = "Public Delegate Sub MyDelegate(ByVal a As Integer, ByVal secondParam As Integer, ByVal lastParam As MyObj)\n";

            TestDelegateDeclaration(ParseUtilVBNet.ParseGlobal <DelegateDeclaration>(program));
        }
Beispiel #7
0
 public void VBNetReDimStatementTest()
 {
     ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim Preserve MyArray(15)");
 }
Beispiel #8
0
 public void VBNetGenericInvocationExpressionTest()
 {
     CheckGenericInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod(Of Char)(\"a\"c)"));
 }
Beispiel #9
0
 public void VBNetRaiseEventStatementTest()
 {
     RaiseEventStatement raiseEventStatement = ParseUtilVBNet.ParseStatement <RaiseEventStatement>("RaiseEvent MyEvent(a, 5, (6))");
 }
 public void PrimitiveExpression1Test()
 {
     InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()");
 }
Beispiel #11
0
        public void VBNetEmptyReturnStatementTest()
        {
            ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return");

            Assert.IsTrue(returnStatement.Expression.IsNull);
        }
Beispiel #12
0
 public void VBNetForeachStatementTest()
 {
     ForeachStatement foreachStmt = ParseUtilVBNet.ParseStatement <ForeachStatement>("For Each i As Integer In myColl : Next");
     // TODO : Extend test.
 }
 public void VBNetErrorStatementTest()
 {
     ErrorStatement errorStatement = ParseUtilVBNet.ParseStatement <ErrorStatement>("Error a");
 }
Beispiel #14
0
 public void VBNetStopStatementTest()
 {
     StopStatement stopStatement = ParseUtilVBNet.ParseStatement <StopStatement>("Stop");
 }
Beispiel #15
0
        public void VBNetLabelStatementTest()
        {
            LabelStatement labelStmt = ParseUtilVBNet.ParseStatement <LabelStatement>("myLabel: Console.WriteLine()");

            Assert.AreEqual("myLabel", labelStmt.Label);
        }
Beispiel #16
0
        public void VBVoidTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(void)");

            Assert.AreEqual("System.Void", toe.TypeReference.SystemType);
        }
 public void VBNetThisReferenceExpressionTest1()
 {
     ThisReferenceExpression ie = ParseUtilVBNet.ParseExpression <ThisReferenceExpression>("Me");
 }
Beispiel #18
0
 public void VBNetWithStatementTest()
 {
     WithStatement withStatement = ParseUtilVBNet.ParseStatement <WithStatement>("With MyObj : End With");
 }
        public void VBNetBaseReferenceExpressionTest1()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("MyBase.myField");

            Assert.IsTrue(fre.TargetObject is BaseReferenceExpression);
        }
        public void VBNetGotoStatementTest()
        {
            GotoStatement gotoStmt = ParseUtilVBNet.ParseStatement <GotoStatement>("GoTo myLabel");

            Assert.AreEqual("myLabel", gotoStmt.Label);
        }
 public void VBNetAddHandlerTest()
 {
     AddHandlerStatement addHandlerStatement = ParseUtilVBNet.ParseStatement <AddHandlerStatement>("AddHandler Obj.Ev_Event, AddressOf EventHandler");
 }
 public void VBNetEraseStatementTest()
 {
     EraseStatement eraseStatement = ParseUtilVBNet.ParseStatement <EraseStatement>("Erase a, b, c");
 }
Beispiel #23
0
 public void VBNetSimpleInvocationExpressionTest()
 {
     CheckSimpleInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod()"));
 }
 public void VBNetForNextStatementTest()
 {
     ForNextStatement forNextStatement = ParseUtilVBNet.ParseStatement <ForNextStatement>("For i=0 To 10 Step 2 : Next i");
 }
Beispiel #25
0
        public void PrimitiveExpression1Test()
        {
            InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()");

            Assert.AreEqual(0, ie.Arguments.Count);
        }
Beispiel #26
0
        public void VBSimpleTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyNamespace.N1.MyType)");

            Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
        }
Beispiel #27
0
 public void VBNetReDimStatementTest2()
 {
     ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim calCheckData(channelNum, lambdaNum).ShiftFromLastFullCalPixels(CalCheckPeak.HighWavelength)");
 }
Beispiel #28
0
        public void VBGlobalTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(Global.System.Console)");

            Assert.AreEqual("System.Console", toe.TypeReference.Type);
        }
Beispiel #29
0
 public void VBNetRemoveHandlerTest()
 {
     RemoveHandlerStatement removeHandlerStatement = ParseUtilVBNet.ParseStatement <RemoveHandlerStatement>("RemoveHandler MyHandler, AddressOf MyMethod");
 }
Beispiel #30
0
        public void VBPrimitiveTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(integer)");

            Assert.AreEqual("System.Int32", toe.TypeReference.SystemType);
        }