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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void PrimitiveExpression1Test() { InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()"); Assert.AreEqual(0, ie.Arguments.Count); }
public void VBNetGenericInvocationExpressionTest() { CheckGenericInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod(Of Char)(\"a\"c)")); }
public void VBNetSimpleInvocationExpressionTest() { CheckSimpleInvoke(ParseUtilVBNet.ParseExpression <InvocationExpression>("myMethod()")); }
public void PrimitiveExpression1Test() { InvocationExpression ie = ParseUtilVBNet.ParseExpression <InvocationExpression>("546.ToString()"); }
public void VBGlobalTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(Global.System.Console)"); Assert.AreEqual("System.Console", toe.TypeReference.Type); }
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"); }
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); }
public void VBSimpleTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilVBNet.ParseExpression <TypeOfExpression>("GetType(MyNamespace.N1.MyType)"); Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); }