예제 #1
0
        public void VBArrayTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyType())");

            Assert.AreEqual("MyType", toe.TypeReference.Type);
            Assert.AreEqual(new int[] { 0 }, toe.TypeReference.RankSpecifier);
        }
        public void VBNetSimpleTypeOfIsExpression()
        {
            TypeOfIsExpression ce = ParseUtilVBNet.ParseExpression <TypeOfIsExpression>("TypeOf o Is MyObject");

            Assert.AreEqual("MyObject", ce.TypeReference.Type);
            Assert.IsTrue(ce.Expression is IdentifierExpression);
        }
        public void VBNetGlobalReferenceExpressionTest()
        {
            TypeReferenceExpression tre = ParseUtilVBNet.ParseExpression <TypeReferenceExpression>("Global.System");

            Assert.IsTrue(tre.TypeReference.IsGlobal);
            Assert.AreEqual("System", tre.TypeReference.Type);
        }
        public void VBIntReferenceExpression()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("inTeGer.MaxValue");

            Assert.AreEqual("MaxValue", fre.FieldName);
            Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType);
        }
예제 #5
0
        public void VBGenericTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyNamespace.N1.MyType(Of string))");

            Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
            Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].SystemType);
        }
예제 #6
0
        void TestSpecializedCast(string castExpression, Type castType)
        {
            CastExpression ce = ParseUtilVBNet.ParseExpression <CastExpression>(castExpression);

            Assert.AreEqual(castType.FullName, ce.CastTo.Type);
            Assert.IsTrue(ce.Expression is IdentifierExpression);
            Assert.AreEqual(CastType.PrimitiveConversion, ce.CastType);
        }
        public void VBNetGenericTypeOfIsExpression()
        {
            TypeOfIsExpression ce = ParseUtilVBNet.ParseExpression <TypeOfIsExpression>("TypeOf o Is List(of T)");

            Assert.AreEqual("List", ce.TypeReference.Type);
            Assert.AreEqual("T", ce.TypeReference.GenericTypes[0].Type);
            Assert.IsTrue(ce.Expression is IdentifierExpression);
        }
예제 #8
0
        public void VBNetSimpleFieldReferenceExpressionTest()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("myTargetObject.myField");

            Assert.AreEqual("myField", fre.FieldName);
            Assert.IsTrue(fre.TargetObject is IdentifierExpression);
            Assert.AreEqual("myTargetObject", ((IdentifierExpression)fre.TargetObject).Identifier);
        }
예제 #9
0
        public void VBNetSimpleCastExpression()
        {
            CastExpression ce = ParseUtilVBNet.ParseExpression <CastExpression>("CType(o, MyObject)");

            Assert.AreEqual("MyObject", ce.CastTo.Type);
            Assert.IsTrue(ce.Expression is IdentifierExpression);
            Assert.AreEqual(CastType.Conversion, ce.CastType);
        }
예제 #10
0
        public void VBNetArrayCreateExpressionTest1()
        {
            ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression <ArrayCreateExpression>("new Integer() {1, 2, 3, 4}");

            Assert.AreEqual("Integer", ace.CreateType.Type);
            Assert.AreEqual(0, ace.Arguments.Count);
            Assert.AreEqual(new int[] { 0 }, ace.CreateType.RankSpecifier);
        }
예제 #11
0
        public void VBUnboundTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyType(Of ,))");

            Assert.AreEqual("MyType", toe.TypeReference.Type);
            Assert.IsTrue(toe.TypeReference.GenericTypes[0].IsNull);
            Assert.IsTrue(toe.TypeReference.GenericTypes[1].IsNull);
        }
        public void VBNetPrimitiveParenthesizedExpression()
        {
            ParenthesizedExpression p = ParseUtilVBNet.ParseExpression <ParenthesizedExpression>("((1))");

            Assert.IsTrue(p.Expression is ParenthesizedExpression);
            p = p.Expression as ParenthesizedExpression;;
            Assert.IsTrue(p.Expression is PrimitiveExpression);
        }
        void VBNetTestUnaryOperatorExpressionTest(string program, UnaryOperatorType op)
        {
            UnaryOperatorExpression uoe = ParseUtilVBNet.ParseExpression <UnaryOperatorExpression>(program);

            Assert.AreEqual(op, uoe.Op);

            Assert.IsTrue(uoe.Expression is IdentifierExpression);
        }
예제 #14
0
        public void VBNetGenericTryCastExpression()
        {
            CastExpression ce = ParseUtilVBNet.ParseExpression <CastExpression>("TryCast(o, List(of T))");

            Assert.AreEqual("List", ce.CastTo.Type);
            Assert.AreEqual("T", ce.CastTo.GenericTypes[0].Type);
            Assert.IsTrue(ce.Expression is IdentifierExpression);
            Assert.AreEqual(CastType.TryCast, ce.CastType);
        }
예제 #15
0
        void VBNetTestBinaryOperatorExpressionTest(string program, BinaryOperatorType op)
        {
            BinaryOperatorExpression boe = ParseUtilVBNet.ParseExpression <BinaryOperatorExpression>(program);

            Assert.AreEqual(op, boe.Op);

            Assert.IsTrue(boe.Left is IdentifierExpression);
            Assert.IsTrue(boe.Right is IdentifierExpression);
        }
        public void VBStandaloneIntReferenceExpression()
        {
            // this is propably not what really should be returned for a standalone int
            // reference, but it has to stay consistent because NRefactoryResolver depends
            // on this trick.
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("inTeGer", true);

            Assert.AreEqual("", fre.FieldName);
            Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType);
        }
예제 #17
0
        public void VBNetFullNamespaceGenericFieldReferenceExpressionTest()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("System.Subnamespace.SomeClass(of string).myField");

            Assert.AreEqual("myField", fre.FieldName);
            Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
            TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;

            Assert.AreEqual("System.Subnamespace.SomeClass", tr.Type);
            Assert.AreEqual(1, tr.GenericTypes.Count);
            Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType);
        }
예제 #18
0
        public void VBNetNestedGenericFieldReferenceExpressionTest()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("MyType(of string).InnerClass(of integer).myField");

            Assert.AreEqual("myField", fre.FieldName);
            Assert.IsTrue(fre.TargetObject is TypeReferenceExpression);
            InnerClassTypeReference ic = (InnerClassTypeReference)((TypeReferenceExpression)fre.TargetObject).TypeReference;

            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);
        }
예제 #19
0
        public void VBNestedGenericTypeOfExpressionTest()
        {
            TypeOfExpression        toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyType(Of string).InnerClass(of integer).InnerInnerClass)");
            InnerClassTypeReference ic  = (InnerClassTypeReference)toe.TypeReference;

            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);
        }
예제 #20
0
        public void PrimitiveExpression1Test()
        {
            InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()");

            Assert.AreEqual(0, ie.Arguments.Count);
        }
예제 #21
0
 public void VBNetGenericInvocationExpressionTest()
 {
     CheckGenericInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod(Of Char)(\"a\"c)"));
 }
예제 #22
0
 public void VBNetSimpleInvocationExpressionTest()
 {
     CheckSimpleInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod()"));
 }
 public void PrimitiveExpression1Test()
 {
     InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()");
 }
예제 #24
0
        public void VBGlobalTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(Global.System.Console)");

            Assert.AreEqual("System.Console", toe.TypeReference.Type);
        }
예제 #25
0
        public void VBPrimitiveTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(integer)");

            Assert.AreEqual("System.Int32", toe.TypeReference.SystemType);
        }
 public void VBNetThisReferenceExpressionTest1()
 {
     ThisReferenceExpression ie = ParseUtilVBNet.ParseExpression <ThisReferenceExpression>("Me");
 }
예제 #27
0
        public void VBVoidTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(void)");

            Assert.AreEqual("System.Void", toe.TypeReference.SystemType);
        }
        public void VBNetAssemblyIdentifierExpressionTest()
        {
            IdentifierExpression ie = ParseUtilVBNet.ParseExpression <IdentifierExpression>("Assembly");

            Assert.AreEqual("Assembly", ie.Identifier);
        }
        public void VBNetBaseReferenceExpressionTest1()
        {
            FieldReferenceExpression fre = ParseUtilVBNet.ParseExpression <FieldReferenceExpression>("MyBase.myField");

            Assert.IsTrue(fre.TargetObject is BaseReferenceExpression);
        }
예제 #30
0
        public void VBSimpleTypeOfExpressionTest()
        {
            TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyNamespace.N1.MyType)");

            Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
        }