PageRenderTime 11ms CodeModel.GetById 4ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/ICSharpCode.Decompiler/Tests/TestRunner.cs

http://github.com/icsharpcode/ILSpy
C# | 205 lines | 158 code | 28 blank | 19 comment | 0 complexity | bd174c17305c186d3223e3cfe2c4e34d MD5 | raw file
  1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
  2// 
  3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4// software and associated documentation files (the "Software"), to deal in the Software
  5// without restriction, including without limitation the rights to use, copy, modify, merge,
  6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7// to whom the Software is furnished to do so, subject to the following conditions:
  8// 
  9// The above copyright notice and this permission notice shall be included in all copies or
 10// substantial portions of the Software.
 11// 
 12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 17// DEALINGS IN THE SOFTWARE.
 18
 19using System;
 20using System.CodeDom.Compiler;
 21using System.Collections.Generic;
 22using System.IO;
 23using System.Linq;
 24using System.Text;
 25using DiffLib;
 26using ICSharpCode.Decompiler.Ast;
 27using ICSharpCode.Decompiler.Tests.Helpers;
 28using Microsoft.CSharp;
 29using Mono.Cecil;
 30using NUnit.Framework;
 31
 32namespace ICSharpCode.Decompiler.Tests
 33{
 34	[TestFixture]
 35	public class TestRunner : DecompilerTestBase
 36	{
 37		[Test]
 38		public void Async()
 39		{
 40			TestFile(@"..\..\Tests\Async.cs");
 41		}
 42		
 43		[Test, Ignore("disambiguating overloads is not yet implemented")]
 44		public void CallOverloadedMethod()
 45		{
 46			TestFile(@"..\..\Tests\CallOverloadedMethod.cs");
 47		}
 48		
 49		[Test, Ignore("unncessary primitive casts")]
 50		public void CheckedUnchecked()
 51		{
 52			TestFile(@"..\..\Tests\CheckedUnchecked.cs");
 53		}
 54		
 55		[Test, Ignore("Missing cast on null")]
 56		public void DelegateConstruction()
 57		{
 58			TestFile(@"..\..\Tests\DelegateConstruction.cs");
 59		}
 60		
 61		[Test, Ignore("Not yet implemented")]
 62		public void ExpressionTrees()
 63		{
 64			TestFile(@"..\..\Tests\ExpressionTrees.cs");
 65		}
 66		
 67		[Test]
 68		public void ExceptionHandling()
 69		{
 70			AssertRoundtripCode(@"..\..\Tests\ExceptionHandling.cs", optimize: false);
 71			AssertRoundtripCode(@"..\..\Tests\ExceptionHandling.cs", optimize: false);
 72		}
 73		
 74		[Test]
 75		public void Generics()
 76		{
 77			TestFile(@"..\..\Tests\Generics.cs");
 78		}
 79		
 80		[Test]
 81		public void CustomShortCircuitOperators()
 82		{
 83			TestFile(@"..\..\Tests\CustomShortCircuitOperators.cs");
 84		}
 85		
 86		[Test]
 87		public void ControlFlowWithDebug()
 88		{
 89			AssertRoundtripCode(@"..\..\Tests\ControlFlow.cs", optimize: false, useDebug: true);
 90			AssertRoundtripCode(@"..\..\Tests\ControlFlow.cs", optimize: false, useDebug: true);
 91		}
 92		
 93		[Test]
 94		public void DoubleConstants()
 95		{
 96			TestFile(@"..\..\Tests\DoubleConstants.cs");
 97		}
 98		
 99		[Test]
100		public void IncrementDecrement()
101		{
102			TestFile(@"..\..\Tests\IncrementDecrement.cs");
103		}
104		
105		[Test]
106		public void InitializerTests()
107		{
108			TestFile(@"..\..\Tests\InitializerTests.cs");
109		}
110
111		[Test]
112		public void LiftedOperators()
113		{
114			TestFile(@"..\..\Tests\LiftedOperators.cs");
115		}
116		
117		[Test]
118		public void Lock()
119		{
120			//TestFile(@"..\..\Tests\Lock.cs", compilerVersion: 2);
121			TestFile(@"..\..\Tests\Lock.cs", compilerVersion: 4);
122		}
123		
124		[Test]
125		public void Loops()
126		{
127			TestFile(@"..\..\Tests\Loops.cs");
128		}
129		
130		[Test]
131		public void MultidimensionalArray()
132		{
133			TestFile(@"..\..\Tests\MultidimensionalArray.cs");
134		}
135		
136		[Test]
137		public void PInvoke()
138		{
139			TestFile(@"..\..\Tests\PInvoke.cs");
140		}
141		
142		[Test]
143		public void PropertiesAndEvents()
144		{
145			TestFile(@"..\..\Tests\PropertiesAndEvents.cs");
146		}
147		
148		[Test]
149		public void QueryExpressions()
150		{
151			TestFile(@"..\..\Tests\QueryExpressions.cs");
152		}
153		
154		[Test, Ignore("switch transform doesn't recreate the exact original switch")]
155		public void Switch()
156		{
157			TestFile(@"..\..\Tests\Switch.cs");
158		}
159		
160		[Test]
161		public void UndocumentedExpressions()
162		{
163			TestFile(@"..\..\Tests\UndocumentedExpressions.cs");
164		}
165		
166		[Test, Ignore("has incorrect casts to IntPtr")]
167		public void UnsafeCode()
168		{
169			TestFile(@"..\..\Tests\UnsafeCode.cs");
170		}
171		
172		[Test]
173		public void ValueTypes()
174		{
175			TestFile(@"..\..\Tests\ValueTypes.cs");
176		}
177		
178		[Test, Ignore("Redundant yield break; not removed")]
179		public void YieldReturn()
180		{
181			TestFile(@"..\..\Tests\YieldReturn.cs");
182		}
183
184		[Test]
185		public void TypeAnalysis()
186		{
187			TestFile(@"..\..\Tests\TypeAnalysisTests.cs");
188		}
189
190		// see https://github.com/icsharpcode/ILSpy/pull/671
191		[Test]
192		public void NotUsingBlock()
193		{
194			TestFile(@"..\..\Tests\NotUsingBlock.cs");
195		}
196
197		static void TestFile(string fileName, bool useDebug = false, int compilerVersion = 4)
198		{
199			AssertRoundtripCode(fileName, optimize: false, useDebug: useDebug, compilerVersion: compilerVersion);
200			AssertRoundtripCode(fileName, optimize: true, useDebug: useDebug, compilerVersion: compilerVersion);
201			AssertRoundtripCode(fileName, optimize: false, useDebug: useDebug, compilerVersion: compilerVersion);
202			AssertRoundtripCode(fileName, optimize: true, useDebug: useDebug, compilerVersion: compilerVersion);
203		}
204	}
205}