3rdparty/NRefactory/ICSharpCode.NRefactory.Tests/CSharp/Parser/Bugs/ParserBugTests.cs
/// <summary>
/// Bug 5064 - Autocomplete doesn't include object initializer properties in yield return 
/// </summary>
Bug 5064 - Autocomplete doesn't include object initializer properties in yield return
Bug 5064 - Autocomplete doesn ' t include object initializer properties in yield return
[Test]
		public void TestBug5064()
		{
			string code = 
@"public class Bar
{
    public IEnumerable<Foo> GetFoos()
    {
        yield return new Foo { }
    }
}";
			var unit = SyntaxTree.Parse(code);
			string text = unit.ToString().Trim();
			string expected = @"public class Bar
{
	public IEnumerable<Foo> GetFoos()
	{
		yield return new Foo { };
	}
}";
			int i = 0, j = 0;
			while (i < text.Length && j < expected.Length) {
				if (char.IsWhiteSpace (text[i])) {
					i++;
					continue;
				}
				if (char.IsWhiteSpace (expected[j])) {
					j++;
					continue;
				}
				if (text [i] != expected [j]) {
					break;
				}
				i++;j++;
			}
			bool passed = i == text.Length && j == expected.Length;
			if (!passed) {
				Console.WriteLine("Expected:" + expected);
				Console.WriteLine("Was:" + unit);
			}
			Assert.IsTrue(passed);
		}
[ Test ] public void TestBug5064 ( ) { string code = @"public class Bar
{
    public IEnumerable<Foo> GetFoos()
    {
        yield return new Foo { }
    }
}" ; var unit = SyntaxTree . Parse ( code ) ; string text = unit . ToString ( ) . Trim ( ) ; string expected = @"public class Bar
{
	public IEnumerable<Foo> GetFoos()
	{
		yield return new Foo { };
	}
}" ; int i = 0 , j = 0 ; while ( i < text . Length && j < expected . Length ) { if ( char . IsWhiteSpace ( text [ i ] ) ) { i ++ ; continue ; } if ( char . IsWhiteSpace ( expected [ j ] ) ) { j ++ ; continue ; } if ( text [ i ] != expected [ j ] ) { break ; } i ++ ; j ++ ; } bool passed = i == text . Length && j == expected . Length ; if ( ! passed ) { Console . WriteLine ( " " + expected ) ; Console . WriteLine ( " " + unit ) ; } Assert . IsTrue ( passed ) ; }
Bug 5064 - Autocomplete doesn't include object initializer properties in yield return
Bug 5064 - Autocomplete doesn ' t include object initializer properties in yield return