Browse Source

Move using test from ControlFlow to Using

pull/877/head
Siegfried Pammer 8 years ago
parent
commit
f53005cf5a
  1. 59
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/ControlFlow.cs
  2. 34
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs

59
ICSharpCode.Decompiler.Tests/TestCases/Correctness/ControlFlow.cs

@ -41,9 +41,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -41,9 +41,6 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
BreakUnlessContinue(true);
BreakUnlessContinue(false);
TestConditionals();
ThisIsNotAUsingBlock();
NoUsing();
UsingObject();
return 0;
}
@ -152,61 +149,5 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -152,61 +149,5 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
byte answer = (byte)(value == 128 ? 255 : 0);
return answer;
}
static void ThisIsNotAUsingBlock()
{
var obj = new System.IO.StringWriter();
IDisposable disposable;
try {
obj.WriteLine("ThisIsNotAUsingBlock");
} finally {
disposable = (object)obj as IDisposable;
if (disposable != null) {
disposable.Dispose();
}
}
Console.WriteLine(disposable);
}
private class PrintOnDispose : IDisposable
{
private string v;
public PrintOnDispose(string v)
{
this.v = v;
}
public void Dispose()
{
Console.WriteLine(this.v);
}
}
static void NoUsing()
{
PrintOnDispose printOnDispose = new PrintOnDispose("NoUsing(): Wrong");
try {
printOnDispose = new PrintOnDispose("NoUsing(): Correct");
} finally {
IDisposable disposable = (object)printOnDispose as IDisposable;
if (disposable != null) {
disposable.Dispose();
}
}
}
static void UsingObject()
{
object obj = new object();
try {
Console.WriteLine("UsingObject: {0}", obj);
} finally {
IDisposable disposable = obj as IDisposable;
if (disposable != null) {
disposable.Dispose();
}
}
}
}
}

34
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Using.cs

@ -42,6 +42,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -42,6 +42,8 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
SimpleUsingNullStatement();
NoUsing();
NoUsing2();
ThisIsNotAUsingBlock();
UsingObject();
}
/// <summary>
@ -68,11 +70,39 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -68,11 +70,39 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
public static void NoUsing2()
{
object printOnDispose = new PrintOnDispose("NoUsing(): Wrong");
PrintOnDispose printOnDispose = new PrintOnDispose("NoUsing(): Wrong");
try {
printOnDispose = new PrintOnDispose("NoUsing(): Correct");
} finally {
IDisposable disposable = printOnDispose as IDisposable;
IDisposable disposable = (object)printOnDispose as IDisposable;
if (disposable != null) {
disposable.Dispose();
}
}
}
public static void ThisIsNotAUsingBlock()
{
var obj = new System.IO.StringWriter();
IDisposable disposable;
try {
obj.WriteLine("ThisIsNotAUsingBlock");
} finally {
disposable = (object)obj as IDisposable;
if (disposable != null) {
disposable.Dispose();
}
}
Console.WriteLine(disposable);
}
public static void UsingObject()
{
object obj = new object();
try {
Console.WriteLine("UsingObject: {0}", obj);
} finally {
IDisposable disposable = obj as IDisposable;
if (disposable != null) {
disposable.Dispose();
}

Loading…
Cancel
Save