Browse Source

Add test cases

pull/2077/head
Siegfried Pammer 6 years ago
parent
commit
a231ab54d4
  1. 3
      ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
  2. 2
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  3. 18
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/LocalFunctions.cs

3
ICSharpCode.Decompiler.Tests/Helpers/Tester.cs

@ -257,6 +257,9 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
preprocessorSymbols.Add("LEGACY_CSC"); preprocessorSymbols.Add("LEGACY_CSC");
preprocessorSymbols.Add("LEGACY_VBC"); preprocessorSymbols.Add("LEGACY_VBC");
} }
if (flags.HasFlag(CompilerOptions.Preview)) {
preprocessorSymbols.Add("CS90");
}
return preprocessorSymbols; return preprocessorSymbols;
} }

2
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -199,7 +199,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test] [Test]
public void LocalFunctions([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions) public void LocalFunctions([ValueSource(nameof(roslynOnlyOptions))] CompilerOptions cscOptions)
{ {
RunForLibrary(cscOptions: cscOptions); RunForLibrary(cscOptions: cscOptions | CompilerOptions.Preview);
} }
[Test] [Test]

18
ICSharpCode.Decompiler.Tests/TestCases/Pretty/LocalFunctions.cs

@ -23,6 +23,12 @@ namespace LocalFunctions
{ {
internal class LocalFunctions internal class LocalFunctions
{ {
[AttributeUsage(AttributeTargets.All)]
internal class MyAttribute : Attribute
{
}
public class Generic<T1> where T1 : struct, ICloneable, IConvertible public class Generic<T1> where T1 : struct, ICloneable, IConvertible
{ {
public int MixedLocalFunction<T2>() where T2 : ICloneable, IConvertible public int MixedLocalFunction<T2>() where T2 : ICloneable, IConvertible
@ -31,15 +37,21 @@ namespace LocalFunctions
object z = this; object z = this;
for (int j = 0; j < 10; j++) { for (int j = 0; j < 10; j++) {
int i = 0; int i = 0;
i += NonStaticMethod6<object>(); i += NonStaticMethod6<object>(0);
int NonStaticMethod6<T3>() #if CS90
[My]
[return: My]
int NonStaticMethod6<T3>([My] int unused)
#else
int NonStaticMethod6<T3>(int unused)
#endif
{ {
t2 = default(T2); t2 = default(T2);
int l = 0; int l = 0;
return NonStaticMethod6_1<T1>() + NonStaticMethod6_1<T2>() + z.GetHashCode(); return NonStaticMethod6_1<T1>() + NonStaticMethod6_1<T2>() + z.GetHashCode();
int NonStaticMethod6_1<T4>() int NonStaticMethod6_1<T4>()
{ {
return i + l + NonStaticMethod6<T4>() + StaticMethod1<decimal>(); return i + l + NonStaticMethod6<T4>(0) + StaticMethod1<decimal>();
} }
} }
} }

Loading…
Cancel
Save