public void VBNetReturnStatementTest() { ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return 5"); Assert.IsFalse(returnStatement.Expression.IsNull); Assert.IsTrue(returnStatement.Expression is PrimitiveExpression); }
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); }
public void VBNetUsingStatementTest2() { string usingText = @" Using nf As Font = New Font() Bla(nf) End Using"; UsingStatement usingStmt = ParseUtilVBNet.ParseStatement <UsingStatement>(usingText); // TODO : Extend test. }
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]); }
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. }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void VBNetStopStatementTest() { StopStatement stopStatement = ParseUtilVBNet.ParseStatement <StopStatement>("Stop"); }
public void VBNetEmptyReturnStatementTest() { ReturnStatement returnStatement = ParseUtilVBNet.ParseStatement <ReturnStatement>("Return"); Assert.IsTrue(returnStatement.Expression.IsNull); }
public void VBNetLabelStatementTest() { LabelStatement labelStmt = ParseUtilVBNet.ParseStatement <LabelStatement>("myLabel: Console.WriteLine()"); Assert.AreEqual("myLabel", labelStmt.Label); }
public void VBNetRaiseEventStatementTest() { RaiseEventStatement raiseEventStatement = ParseUtilVBNet.ParseStatement <RaiseEventStatement>("RaiseEvent MyEvent(a, 5, (6))"); }
public void VBNetForNextStatementTest() { ForNextStatement forNextStatement = ParseUtilVBNet.ParseStatement <ForNextStatement>("For i=0 To 10 Step 2 : Next i"); }
public void VBNetEraseStatementTest() { EraseStatement eraseStatement = ParseUtilVBNet.ParseStatement <EraseStatement>("Erase a, b, c"); }
public void VBNetOnErrorStatementTest() { OnErrorStatement onErrorStatement = ParseUtilVBNet.ParseStatement <OnErrorStatement>("On Error Goto err"); }
public void VBNetReDimStatementTest2() { ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim calCheckData(channelNum, lambdaNum).ShiftFromLastFullCalPixels(CalCheckPeak.HighWavelength)"); }
public void VBNetAddHandlerTest() { AddHandlerStatement addHandlerStatement = ParseUtilVBNet.ParseStatement <AddHandlerStatement>("AddHandler Obj.Ev_Event, AddressOf EventHandler"); }
public void VBNetErrorStatementTest() { ErrorStatement errorStatement = ParseUtilVBNet.ParseStatement <ErrorStatement>("Error a"); }
public void VBNetForeachStatementTest() { ForeachStatement foreachStmt = ParseUtilVBNet.ParseStatement <ForeachStatement>("For Each i As Integer In myColl : Next"); // TODO : Extend test. }
public void VBNetWithStatementTest() { WithStatement withStatement = ParseUtilVBNet.ParseStatement <WithStatement>("With MyObj : End With"); }
public void VBNetReDimStatementTest() { ReDimStatement reDimStatement = ParseUtilVBNet.ParseStatement <ReDimStatement>("ReDim Preserve MyArray(15)"); }
public void VBNetGotoStatementTest() { GotoStatement gotoStmt = ParseUtilVBNet.ParseStatement <GotoStatement>("GoTo myLabel"); Assert.AreEqual("myLabel", gotoStmt.Label); }
public void VBNetRemoveHandlerTest() { RemoveHandlerStatement removeHandlerStatement = ParseUtilVBNet.ParseStatement <RemoveHandlerStatement>("RemoveHandler MyHandler, AddressOf MyMethod"); }
public void VBNetResumeStatementTest() { ResumeStatement resumeStatement = ParseUtilVBNet.ParseStatement <ResumeStatement>("Resume"); }