public void VBNetCompareTextOptionDeclarationTest()
        {
            string            program = "Option Compare Text\n";
            OptionDeclaration oParameterDeclarationExpression = ParseUtilVBNet.ParseGlobal <OptionDeclaration>(program);

            Assert.AreEqual(OptionType.CompareText, oParameterDeclarationExpression.OptionType);
            Assert.IsTrue(oParameterDeclarationExpression.OptionValue);
        }
예제 #2
0
        public void AssemblyAttributeVBNet()
        {
            string           program = @"<assembly: System.Attribute()>";
            AttributeSection decl    = ParseUtilVBNet.ParseGlobal <AttributeSection>(program);

            Assert.AreEqual(new Location(1, 1), decl.StartLocation);
            Assert.AreEqual("assembly", decl.AttributeTarget);
        }
        public void VBNetInferOffOptionDeclarationTest()
        {
            string            program = "Option Infer\n";
            OptionDeclaration oParameterDeclarationExpression = ParseUtilVBNet.ParseGlobal <OptionDeclaration>(program);

            Assert.AreEqual(OptionType.Infer, oParameterDeclarationExpression.OptionType);
            Assert.IsTrue(oParameterDeclarationExpression.OptionValue);
        }
        public void VBNetExplicitOptionDeclarationTest()
        {
            string            program = "Option Explicit Off\n";
            OptionDeclaration oParameterDeclarationExpression = ParseUtilVBNet.ParseGlobal <OptionDeclaration>(program);

            Assert.AreEqual(OptionType.Explicit, oParameterDeclarationExpression.OptionType);
            Assert.IsFalse(oParameterDeclarationExpression.OptionValue, "Off option value excepted!");
        }
        public void VBNetInferOptionDeclarationTest()
        {
            string            program = "Option Infer\n";
            OptionDeclaration opDec   = ParseUtilVBNet.ParseGlobal <OptionDeclaration>(program);

            Assert.AreEqual(OptionType.Infer, opDec.OptionType);
            Assert.IsTrue(opDec.OptionValue);
        }
        public void VBNetCompareBinaryOptionDeclarationTest()
        {
            string            program = "Option Compare Binary\n";
            OptionDeclaration opDec   = ParseUtilVBNet.ParseGlobal <OptionDeclaration>(program);

            Assert.AreEqual(OptionType.CompareBinary, opDec.OptionType);
            Assert.IsTrue(opDec.OptionValue);
        }
        public void VBNetSimpleNamespaceTest()
        {
            string program = "Namespace TestNamespace" + Environment.NewLine +
                             "End Namespace" + Environment.NewLine;
            NamespaceDeclaration ns = ParseUtilVBNet.ParseGlobal <NamespaceDeclaration>(program);

            Assert.AreEqual("TestNamespace", ns.Name);
        }
예제 #8
0
        public void VBNetEnumOnSingleLine2()
        {
            string          program = "Enum TestEnum : A : : B = 1 :: C : End Enum";
            TypeDeclaration td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestEnum", td.Name);
            Assert.AreEqual(ClassType.Enum, td.Type);
            Assert.AreEqual(3, td.Children.Count);
        }
        public void VBNetMultiFieldsOnSingleLineTest()
        {
            string          program = "Class TestClass : Dim a : Dim b : End Class";
            TypeDeclaration td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual(2, td.Children.Count);
            Assert.IsTrue(td.Children[0] is FieldDeclaration);
            Assert.IsTrue(td.Children[1] is FieldDeclaration);
        }
예제 #10
0
        public void VBNetPartialPublicClass()
        {
            string          program = "Partial Public Class TestClass\nEnd Class\n";
            TypeDeclaration td      = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual(Modifiers.Partial | Modifiers.Public, td.Modifier);
        }
예제 #11
0
        public void GlobalAttributeVB()
        {
            string          program = @"<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Form1
	
End Class";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.DesignerGenerated", decl.Attributes[0].Attributes[0].Name);
        }
예제 #12
0
        public void VBNetSimpleClassTypeDeclarationWithColon()
        {
            string program = "Class TestClass\n" +
                             " : \n" +
                             "End Class";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
        }
예제 #13
0
        public void VBNetEnumWithSystemBaseClassDeclarationTest()
        {
            string program = "Enum TestEnum As System.UInt16\n" +
                             "End Enum\n";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestEnum", td.Name);
            Assert.AreEqual(ClassType.Enum, td.Type);
            Assert.AreEqual("System.UInt16", td.BaseTypes[0].Type);
            Assert.AreEqual(0, td.Children.Count);
        }
예제 #14
0
        public void VBNetSimpleClassTypeDeclarationWithoutLastNewLineTest()
        {
            string program = "Class TestClass\n" +
                             "End Class";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual(1, td.StartLocation.Y, "start line");
            Assert.AreEqual(2, td.EndLocation.Y, "end line");
        }
예제 #15
0
        public void VBNetSimpleClassTypeDeclarationTest()
        {
            string program = "Class TestClass\n" +
                             "End Class\n";
            TypeDeclaration td = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("TestClass", td.Name);
            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual(1, td.StartLocation.Line, "start line");
            Assert.AreEqual(1, td.BodyStartLocation.Line, "bodystart line");
            Assert.AreEqual(16, td.BodyStartLocation.Column, "bodystart col");
            Assert.AreEqual(2, td.EndLocation.Line, "end line");
        }
예제 #16
0
        public void AttributeOnStructure()
        {
            string          program = @"
<StructLayout( LayoutKind.Explicit )> _
Public Structure MyUnion

	<FieldOffset( 0 )> Public i As Integer
	< FieldOffset( 0 )> Public d As Double
	
End Structure 'MyUnion
";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("StructLayout", decl.Attributes[0].Attributes[0].Name);
        }
예제 #17
0
        public void AttributeOnModule()
        {
            string          program = @"
<HideModule> _
Public Module MyExtra

	Public i As Integer
	Public d As Double
	
End Module
";
            TypeDeclaration decl    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);

            Assert.AreEqual("HideModule", decl.Attributes[0].Attributes[0].Name);
        }
예제 #18
0
        public void VBNetGenericClassWithConstraint()
        {
            string          declr = @"
Public Class Test(Of T As IMyInterface)

End Class
";
            TypeDeclaration td    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(declr);

            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual("Test", td.Name);

            Assert.AreEqual(1, td.Templates.Count);
            Assert.AreEqual("T", td.Templates[0].Name);
            Assert.AreEqual("IMyInterface", td.Templates[0].Bases[0].Type);
        }
예제 #19
0
        public void VBNetGenericClassTypeDeclarationTest()
        {
            string          declr = @"
Public Class Test(Of T)

End Class
";
            TypeDeclaration td    = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(declr);

            Assert.AreEqual(ClassType.Class, td.Type);
            Assert.AreEqual("Test", td.Name);
            Assert.AreEqual(Modifiers.Public, td.Modifier);
            Assert.AreEqual(0, td.BaseTypes.Count);
            Assert.AreEqual(1, td.Templates.Count);
            Assert.AreEqual("T", td.Templates[0].Name);
        }
예제 #20
0
        public void VBNetBigReDimStatementTest()
        {
            string          program         = @"
Class X
	Sub x
		ReDim sU(m - 1, n - 1)
		ReDim sW(n - 1)
		ReDim sV(n - 1, n - 1)
		ReDim rv1(n - 1)
		ReDim sMt(iNrCols - 1, 0)
		ReDim Preserve sMt(iNrCols - 1, iRowNr)
		ReDim sM(iRowNr - 1, iNrCols - 1)
		If (IsNothing(ColLengths)) Then ReDim ColLengths(0)
		If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1)
		ReDim sTransform(2, iTransformType - 1)
		ReDim Preserve _Items(_Count)
		ReDim Preserve _Items(nCapacity)
		ReDim Preserve _Items(0 To _Count)
		ReDim Preserve _Items(0 To nCapacity)
		ReDim sU(m - 1, n - 1)
		ReDim sW(n - 1)
		ReDim sV(n - 1, n - 1)
		ReDim rv1(n - 1)
		ReDim sMt(iNrCols - 1, 0)
		ReDim Preserve sMt(iNrCols - 1, iRowNr)
		ReDim sM(iRowNr - 1, iNrCols - 1)
		If (IsNothing(ColLengths)) Then ReDim ColLengths(0)
		If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1)
		ReDim sTransform(2, iTransformType - 1)
		ReDim Preserve Samples(Samples.GetUpperBound(0) + 1)
		ReDim Samples(0)
		ReDim BaseCssContent(BaseCssContentRows - 1)
		ReDim mabtRxBuf(Bytes2Read - 1)
		ReDim Preserve primarykey(primarykey.Length)
		ReDim Preserve IntArray(10, 10, 15)
		ReDim X(10, 10)
		ReDim Preserve IntArray(0 To 10, 10, 0 To 20)
		ReDim Preserve IntArray(10, 10, 15)
		ReDim X(0 To 10, 0 To 10)
		ReDim GetMe().IntArray(0 To 10, 10, 0 To 20)
		ReDim GetMe(ExplicitParameter := 3).IntArray(0 To 10, 10, 0 To 20)
		ReDim SomeType(Of Integer).IntArray(0 To 10, 10, 0 To 20)
	End Sub
End Class";
            TypeDeclaration typeDeclaration = ParseUtilVBNet.ParseGlobal <TypeDeclaration>(program);
        }
예제 #21
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);
        }
        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);
        }
 public void ModuleAttributeTargetEscapedVB()
 {
     // check that this doesn't crash the parser:
     ParseUtilVBNet.ParseGlobal <AttributeSection>("<[Module]: SuppressMessageAttribute>", true);
 }
예제 #24
0
        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));
        }