From 4d78138a2a0b7d29cfa1def23aa2f9a35441c90a Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Mon, 3 Sep 2012 17:44:57 +0200 Subject: [PATCH] Add test for broken ref/out in if-then-else conditionals --- CSharpTranslator/tests/Tester/Misc/RefOut.cs | 77 ++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/CSharpTranslator/tests/Tester/Misc/RefOut.cs b/CSharpTranslator/tests/Tester/Misc/RefOut.cs index 69584e0..563baa1 100644 --- a/CSharpTranslator/tests/Tester/Misc/RefOut.cs +++ b/CSharpTranslator/tests/Tester/Misc/RefOut.cs @@ -55,5 +55,82 @@ namespace Tester.RefOut new RefOutTest ().Init (args); } } + + class TC { + + public TC() {} + + public bool TCtest1(out string modifiedUrlString, string urlString){ + modifiedUrlString = urlString.ToUpper(); + return false; + } + + public bool TCtest2(out string user, out string passwd, string urlString){ + user = urlString.ToUpper(); + passwd = urlString.ToLower(); + return true; + } + + + public void TCtest(string urlString) + { + + string modifiedUrlString=null; + string engineAuthUser=null; + string engineAuthPassword=null; + + if (TCtest1(out modifiedUrlString, urlString)) + { + System.Console.WriteLine(modifiedUrlString); + } + else if (TCtest2(out engineAuthUser, out engineAuthPassword, urlString)) + { + if (!String.IsNullOrEmpty(engineAuthUser) && !String.IsNullOrEmpty(engineAuthPassword)) + { + System.Console.WriteLine(engineAuthUser + engineAuthPassword); + } + else + { + System.Console.WriteLine("Null or Null"); + } + } + else + { + System.Console.WriteLine("They really didn't like us"); + } + } + + public void TCtest_workaround(string urlString) + { + + string modifiedUrlString=null; + string engineAuthUser=null; + string engineAuthPassword=null; + + bool optTCTest1 = TCtest1(out modifiedUrlString, urlString); + if (optTCTest1) + { + System.Console.WriteLine(modifiedUrlString); + } + else { + bool optTCTest2 = TCtest2(out engineAuthUser, out engineAuthPassword, urlString); + if (optTCTest2) + { + if (!String.IsNullOrEmpty(engineAuthUser) && !String.IsNullOrEmpty(engineAuthPassword)) + { + System.Console.WriteLine(engineAuthUser + engineAuthPassword); + } + else + { + System.Console.WriteLine("Null or Null"); + } + } + else + { + System.Console.WriteLine("They really didn't like us"); + } + } + } + } }