Files
coverlet/test/coverlet.core.tests/Samples/Instrumentation.Yield.cs
T
bert2 3264ad3ac3 Skip branches in generated MoveNext() for singleton iterators (#813)
Skip branches in generated `MoveNext()` for singleton iterators
2020-05-10 18:07:24 +02:00

60 lines
1.4 KiB
C#

// Remember to use full name because adding new using directives change line numbers
namespace Coverlet.Core.Samples.Tests
{
public class Yield
{
public System.Collections.Generic.IEnumerable<int> One()
{
yield return 1;
}
public System.Collections.Generic.IEnumerable<int> Two()
{
yield return 1;
yield return 2;
}
public System.Collections.Generic.IEnumerable<int> OneWithSwitch(int n)
{
int result;
switch (n)
{
case 0:
result = 10;
break;
case 1:
result = 11;
break;
case 2:
result = 12;
break;
default:
result = -1;
break;
}
yield return result;
}
public System.Collections.Generic.IEnumerable<int> Three()
{
yield return 1;
yield return 2;
yield return 3;
}
public System.Collections.Generic.IEnumerable<string> Enumerable(System.Collections.Generic.IList<string> ls)
{
foreach (
var item
in
ls
)
{
yield return item;
}
}
}
}