diff options
author | Mike Krüger <mkrueger@novell.com> | 2011-01-10 13:47:49 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2011-01-10 13:48:32 +0300 |
commit | 4d191680cddc3df0a228668fbf6c6f62af82a0df (patch) | |
tree | edb30f58a7ad3455b64be052a5e762e80f6e97da /main/tests/UnitTests/MonoDevelop.Refactoring | |
parent | b738d5d49997d84ce1a6ea5044de6c9d3b8e139e (diff) |
Added test for 'Bug 616199 - Extract method forgets to return a local
var which is used in main method' - adjusted some old extract unit
tests.
Diffstat (limited to 'main/tests/UnitTests/MonoDevelop.Refactoring')
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs index 85bd9085b9..2a77b2ce8e 100644 --- a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs +++ b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs @@ -206,15 +206,13 @@ namespace MonoDevelop.Refactoring.Tests void TestMethod () { int i = 5; - i = NewMethod (); + NewMethod (ref i); Console.WriteLine (i); } - int NewMethod () + void NewMethod (ref int i) { - int i; i = member + 1; - return i; } } "); @@ -266,14 +264,13 @@ namespace MonoDevelop.Refactoring.Tests void TestMethod () { int i = 5; - i = NewMethod (i); + NewMethod (ref i); Console.WriteLine (i); } - static int NewMethod (int i) + static void NewMethod (ref int i) { i = i + 1; - return i; } } "); @@ -398,10 +395,10 @@ namespace MonoDevelop.Refactoring.Tests string ret; string x; IEnumerable<string> y; - NewMethod (ref ret, x, y); + NewMethod (out ret, x, y); } - static void NewMethod (ref string ret, string x, IEnumerable<string> y) + static void NewMethod (out string ret, string x, IEnumerable<string> y) { string z = ret + y; ret = x + z; @@ -410,6 +407,37 @@ namespace MonoDevelop.Refactoring.Tests "); } + /// <summary> + /// Bug 616199 - Extract method forgets to return a local var which is used in main method + /// </summary> + [Test()] + public void TestBug616199 () + { + TestExtractMethod (@"class TestClass +{ + void TestMethod () + { + <-string z = ""test"" + ""x"";-> + string ret = ""test1"" + z; + } +} +", @"class TestClass +{ + void TestMethod () + { + string z = NewMethod (); + string ret = ""test1"" + z; + } + + static string NewMethod () + { + string z = ""test"" + ""x""; + return z; + } +} +"); + } + /* Currently not possible to implement, would cause serve bugs: [Test()] public void ExtractMethodMultiVariableWithLocalReturnVariableTest () |