PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs

http://github.com/icsharpcode/ILSpy
C# | 203 lines | 10 code | 2 blank | 191 comment | 0 complexity | bf95bdd62effa02d7fce3bff5843c6c0 MD5 | raw file
  1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
  3
  4using System;
  5using ICSharpCode.NRefactory.VB.Ast;
  6using NUnit.Framework;
  7
  8namespace ICSharpCode.NRefactory.VB.Tests.Ast
  9{
 10	[TestFixture]
 11	public class TypeDeclarationTests
 12	{
 13//		#region VB.NET
 14//		[Test]
 15//		public void VBNetSimpleClassTypeDeclarationTest()
 16//		{
 17//			string program = "Class TestClass\n" +
 18//				"End Class\n";
 19//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 20//			
 21//			Assert.AreEqual("TestClass", td.Name);
 22//			Assert.AreEqual(ClassType.Class, td.Type);
 23//			Assert.AreEqual(1, td.StartLocation.Line, "start line");
 24//			Assert.AreEqual(1, td.BodyStartLocation.Line, "bodystart line");
 25//			Assert.AreEqual(16, td.BodyStartLocation.Column, "bodystart col");
 26//			Assert.AreEqual(2, td.EndLocation.Line, "end line");
 27//			Assert.AreEqual(10, td.EndLocation.Column, "end col");
 28//		}
 29//		
 30//		[Test]
 31//		public void VBNetMissingBaseClassTest()
 32//		{
 33//			// SD2-1499: test that this invalid code doesn't crash
 34//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>("public class test inherits", true);
 35//			Assert.AreEqual(0, td.BaseTypes.Count);
 36//		}
 37//		
 38//		[Test]
 39//		public void VBNetEnumWithBaseClassDeclarationTest()
 40//		{
 41//			string program = "Enum TestEnum As Byte\n" +
 42//				"End Enum\n";
 43//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 44//			
 45//			Assert.AreEqual("TestEnum", td.Name);
 46//			Assert.AreEqual(ClassType.Enum, td.Type);
 47//			Assert.AreEqual("System.Byte", td.BaseTypes[0].Type);
 48//			Assert.AreEqual(0, td.Children.Count);
 49//		}
 50//		
 51//		[Test]
 52//		public void VBNetEnumOnSingleLine()
 53//		{
 54//			string program = "Enum TestEnum : A : B = 1 : C : End Enum";
 55//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 56//			
 57//			Assert.AreEqual("TestEnum", td.Name);
 58//			Assert.AreEqual(ClassType.Enum, td.Type);
 59//			Assert.AreEqual(3, td.Children.Count);
 60//		}
 61//		
 62//		[Test]
 63//		public void VBNetEnumOnSingleLine2()
 64//		{
 65//			string program = "Enum TestEnum : A : : B = 1 :: C : End Enum";
 66//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 67//			
 68//			Assert.AreEqual("TestEnum", td.Name);
 69//			Assert.AreEqual(ClassType.Enum, td.Type);
 70//			Assert.AreEqual(3, td.Children.Count);
 71//		}
 72//		
 73//		
 74//		[Test]
 75//		public void VBNetEnumWithSystemBaseClassDeclarationTest()
 76//		{
 77//			string program = "Enum TestEnum As System.UInt16\n" +
 78//				"End Enum\n";
 79//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 80//			
 81//			Assert.AreEqual("TestEnum", td.Name);
 82//			Assert.AreEqual(ClassType.Enum, td.Type);
 83//			Assert.AreEqual("System.UInt16", td.BaseTypes[0].Type);
 84//			Assert.AreEqual(0, td.Children.Count);
 85//		}
 86//		
 87//		[Test]
 88//		public void VBNetSimpleClassTypeDeclarationWithoutLastNewLineTest()
 89//		{
 90//			string program = "Class TestClass\n" +
 91//				"End Class";
 92//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
 93//			
 94//			Assert.AreEqual("TestClass", td.Name);
 95//			Assert.AreEqual(ClassType.Class, td.Type);
 96//			Assert.AreEqual(1, td.StartLocation.Line, "start line");
 97//			Assert.AreEqual(2, td.EndLocation.Line, "end line");
 98//		}
 99//		
100//		[Test]
101//		public void VBNetSimpleClassTypeDeclarationWithColon()
102//		{
103//			string program = "Class TestClass\n" +
104//				" : \n" +
105//				"End Class";
106//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
107//			
108//			Assert.AreEqual("TestClass", td.Name);
109//			Assert.AreEqual(ClassType.Class, td.Type);
110//		}
111//		
112//		[Test]
113//		public void VBNetSimplePartialClassTypeDeclarationTest()
114//		{
115//			string program = "Partial Class TestClass\n" +
116//				"End Class\n";
117//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
118//			
119//			Assert.AreEqual("TestClass", td.Name);
120//			Assert.AreEqual(ClassType.Class, td.Type);
121//			Assert.AreEqual(Modifiers.Partial, td.Modifier);
122//		}
123//		
124//		[Test]
125//		public void VBNetPartialPublicClass()
126//		{
127//			string program = "Partial Public Class TestClass\nEnd Class\n";
128//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(program);
129//			
130//			Assert.AreEqual("TestClass", td.Name);
131//			Assert.AreEqual(ClassType.Class, td.Type);
132//			Assert.AreEqual(Modifiers.Partial | Modifiers.Public, td.Modifier);
133//		}
134//		
135//		[Test]
136//		public void VBNetGenericClassTypeDeclarationTest()
137//		{
138//			string declr = @"
139//Public Class Test(Of T)
140//
141//End Class
142//";
143//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(declr);
144//			
145//			Assert.AreEqual(ClassType.Class, td.Type);
146//			Assert.AreEqual("Test", td.Name);
147//			Assert.AreEqual(Modifiers.Public, td.Modifier);
148//			Assert.AreEqual(0, td.BaseTypes.Count);
149//			Assert.AreEqual(1, td.Templates.Count);
150//			Assert.AreEqual("T", td.Templates[0].Name);
151//		}
152//		
153//		[Test]
154//		public void VBNetGenericClassWithConstraint()
155//		{
156//			string declr = @"
157//Public Class Test(Of T As IMyInterface)
158//
159//End Class
160//";
161//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(declr);
162//			
163//			Assert.AreEqual(ClassType.Class, td.Type);
164//			Assert.AreEqual("Test", td.Name);
165//			
166//			Assert.AreEqual(1, td.Templates.Count);
167//			Assert.AreEqual("T", td.Templates[0].Name);
168//			Assert.AreEqual("IMyInterface", td.Templates[0].Bases[0].Type);
169//		}
170//		
171//		[Test]
172//		public void VBNetComplexGenericClassTypeDeclarationTest()
173//		{
174//			string declr = @"
175//Public Class Generic(Of T As MyNamespace.IMyInterface, S As {G(Of T()), IAnotherInterface})
176//	Implements System.IComparable
177//
178//End Class
179//";
180//			TypeDeclaration td = ParseUtil.ParseGlobal<TypeDeclaration>(declr);
181//			
182//			Assert.AreEqual(ClassType.Class, td.Type);
183//			Assert.AreEqual("Generic", td.Name);
184//			Assert.AreEqual(Modifiers.Public, td.Modifier);
185//			Assert.AreEqual(1, td.BaseTypes.Count);
186//			Assert.AreEqual("System.IComparable", td.BaseTypes[0].Type);
187//			
188//			Assert.AreEqual(2, td.Templates.Count);
189//			Assert.AreEqual("T", td.Templates[0].Name);
190//			Assert.AreEqual("MyNamespace.IMyInterface", td.Templates[0].Bases[0].Type);
191//			
192//			Assert.AreEqual("S", td.Templates[1].Name);
193//			Assert.AreEqual(2, td.Templates[1].Bases.Count);
194//			Assert.AreEqual("G", td.Templates[1].Bases[0].Type);
195//			Assert.AreEqual(1, td.Templates[1].Bases[0].GenericTypes.Count);
196//			Assert.IsTrue(td.Templates[1].Bases[0].GenericTypes[0].IsArrayType);
197//			Assert.AreEqual("T", td.Templates[1].Bases[0].GenericTypes[0].Type);
198//			Assert.AreEqual(new int[] {0}, td.Templates[1].Bases[0].GenericTypes[0].RankSpecifier);
199//			Assert.AreEqual("IAnotherInterface", td.Templates[1].Bases[1].Type);
200//		}
201//		#endregion
202	}
203}