Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some unit tests.

  • Loading branch information...
commit 7bf1b4a850aff4be5cc7fa45b95405dbae716f75 1 parent d9113f3
@mkrueger mkrueger authored
View
91 ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/ObjectInitializerTests.cs
@@ -475,8 +475,97 @@ public void Test ()
}
", provider => {
Assert.IsNotNull(provider.Find("List<string>"), "class 'List<string>' not found.");
- });
+ }
+ );
+ }
+
+ [Ignore ()]
+ [Test()]
+ public void TestArrayInitializerObjectCreationNarrowing()
+ {
+ CodeCompletionBugTests.CombinedProviderTest(
+@"using System;
+using System.Collections.Generic;
+class MyList : List<IEnumerable<string>> {}
+class MyTest
+{
+ public void Test ()
+ {
+ $new MyList { new L$
+ }
+}
+", provider => {
+ Assert.IsNotNull(provider.Find("List<string>"), "class 'List<string>' not found.");
+ }
+ );
}
+
+ [Ignore ()]
+ [Test()]
+ public void TestObjectCreationEnumerable()
+ {
+ CodeCompletionBugTests.CombinedProviderTest(
+@"using System;
+using System.Collections.Generic;
+class MyList : List<IEnumerable<string>> { public bool MyProp {get;set; } }
+class MyTest
+{
+ public void Test ()
+ {
+ $new MyList { n$
}
}
+", provider => {
+ Assert.IsNotNull(provider.Find("new"), "'new' not found.");
+ Assert.IsNotNull(provider.Find("MyProp"), "'MyProp' not found.");
+ }
+ );
+ }
+
+ [Ignore ()]
+ [Test()]
+ public void TestObjectCreationForbiddenInArrayInitializers()
+ {
+ CodeCompletionBugTests.CombinedProviderTest(
+@"using System;
+using System.Collections.Generic;
+class MyList : List<IEnumerable<string>> { public bool MyProp {get;set; } }
+class MyTest
+{
+ public void Test ()
+ {
+ $new MyList { new List<string> (), n$
+ }
+}
+", provider => {
+ Assert.IsNotNull(provider.Find("new"), "'new' not found.");
+ Assert.IsNull(provider.Find("MyProp"), "'MyProp' found.");
+ }
+ );
+ }
+
+ [Ignore ()]
+ [Test()]
+ public void TestArrayInitializersForbiddenInObjectCreation()
+ {
+ CodeCompletionBugTests.CombinedProviderTest(
+@"using System;
+using System.Collections.Generic;
+class MyList : List<IEnumerable<string>> { public bool MyProp {get;set; } public bool MyProp2 {get;set; } }
+class MyTest
+{
+ public void Test ()
+ {
+ $new MyList { MyProp = true, n$
+ }
+}
+", provider => {
+ Assert.IsNull(provider.Find("new"), "'new' found.");
+ Assert.IsNotNull(provider.Find("MyProp2"), "'MyProp2' not found.");
+ }
+ );
+ }
+ }
+
+}
View
30 ICSharpCode.NRefactory.Tests/CSharp/Parser/Bugs/ParserBugTests.cs
@@ -317,6 +317,36 @@ void Foo ()
}
Assert.IsTrue(passed);
}
+
+ /// <summary>
+ /// Bug 4556 - AST broken for unclosed invocation
+ /// </summary>
+ [Ignore ()]
+ [Test]
+ public void TestBug4556()
+ {
+ string code =
+@"using System;
+
+class Foo
+{
+ public static void Main (string[] args)
+ {
+ Console.WriteLine (""foo"",
+ }
+}
+";
+ var unit = CompilationUnit.Parse(code);
+
+ var type = unit.Members.First() as TypeDeclaration;
+ var method = type.Members.First() as MethodDeclaration;
+ bool passed = !method.Body.IsNull;
+ if (!passed) {
+ Console.WriteLine("Expected:" + code);
+ Console.WriteLine("Was:" + unit.GetText());
+ }
+ Assert.IsTrue(passed);
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.