From ec18084e7a65fc2e9f11a7346fd62c42f4d3a086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Mon, 9 Mar 2009 08:15:49 +0000 Subject: [PATCH] * Output/SnippetConversion.cs: * Output/VBNet/CSharpToVBNetConverterTest.cs: * Output/CSharp/VBNetToCSharpConverterTest.cs: Fixed some unit tests so that they run on non windows platforms. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3841 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../CSharp/VBNetToCSharpConverterTest.cs | 10 +- .../Test/Output/SnippetConversion.cs | 114 +++++++++--------- .../VBNet/CSharpToVBNetConverterTest.cs | 70 ++++++----- 3 files changed, 95 insertions(+), 99 deletions(-) diff --git a/src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs b/src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs index 0cb5f4e9af..55d359ae6a 100644 --- a/src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/CSharp/VBNetToCSharpConverterTest.cs @@ -625,7 +625,7 @@ static int static_Test2_j = 0;"); [Test] public void ImportAliasPrimitiveType() { - TestProgram("Imports T = System.Boolean", "using T = System.Boolean;\r\n"); + TestProgram("Imports T = System.Boolean", "using T = System.Boolean;" + Environment.NewLine); } [Test] @@ -696,10 +696,10 @@ static int static_Test2_j = 0;"); public void ConstModuleMember() { TestProgram("Module Test : Public Const C As Integer = 0 : End Module", - "static class Test\r\n" + - "{\r\n" + - " public const int C = 0;\r\n" + - "}\r\n"); + "static class Test" + Environment.NewLine + + "{" + Environment.NewLine + + " public const int C = 0;" + Environment.NewLine + + "}" + Environment.NewLine); } } } diff --git a/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs b/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs index 35720f966e..3671b112ad 100644 --- a/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs +++ b/src/Libraries/NRefactory/Test/Output/SnippetConversion.cs @@ -30,6 +30,7 @@ namespace ICSharpCode.NRefactory.Tests.Output node.AcceptVisitor(new ToVBNetConvertVisitor(), null); VBNetOutputVisitor output = new VBNetOutputVisitor(); + using (SpecialNodesInserter.Install(parser.Specials, output)) { node.AcceptVisitor(output, null); } @@ -66,38 +67,38 @@ namespace ICSharpCode.NRefactory.Tests.Output public void CompilationUnitCS2VB() { CS2VB( - @"using System; + @"using System;" + Environment.NewLine + +"" + Environment.NewLine + +"public class MyClass" + Environment.NewLine + +"{" + Environment.NewLine + +" string abc;" + Environment.NewLine + +"" + Environment.NewLine + +" public string Abc { get { return abc; } }" + Environment.NewLine + +"" + Environment.NewLine + +" // This is a test method" + Environment.NewLine + +" static void M(params T[] args) where T : IDisposable" + Environment.NewLine + +" {" + Environment.NewLine + +" Console.WriteLine(\"Hello!\");" + Environment.NewLine + +" }" + Environment.NewLine + +"}", -public class MyClass -{ - string abc; - - public string Abc { get { return abc; } } - - // This is a test method - static void M(params T[] args) where T : IDisposable - { - Console.WriteLine(""Hello!""); - } -}", - - @"Imports System - -Public Class [MyClass] - Private m_abc As String - - Public ReadOnly Property Abc() As String - Get - Return m_abc - End Get - End Property - - ' This is a test method - Private Shared Sub M(Of T As IDisposable)(ParamArray args As T()) - Console.WriteLine(""Hello!"") - End Sub -End Class -" + @"Imports System" + Environment.NewLine + +"" + Environment.NewLine + +"Public Class [MyClass]" + Environment.NewLine + +" Private m_abc As String" + Environment.NewLine + +"" + Environment.NewLine + +" Public ReadOnly Property Abc() As String" + Environment.NewLine + +" Get" + Environment.NewLine + +" Return m_abc" + Environment.NewLine + +" End Get" + Environment.NewLine + +" End Property" + Environment.NewLine + +"" + Environment.NewLine + +" ' This is a test method" + Environment.NewLine + +" Private Shared Sub M(Of T As IDisposable)(ParamArray args As T())" + Environment.NewLine + +" Console.WriteLine(\"Hello!\")" + Environment.NewLine + +" End Sub" + Environment.NewLine + +"End Class" + Environment.NewLine + +"" ); } @@ -108,14 +109,14 @@ End Class public void TypeMembersCS2VB() { CS2VB( - "void Test() {}\n" + + "void Test() {}" + Environment.NewLine + "void Test2() {}", - @"Private Sub Test() -End Sub -Private Sub Test2() -End Sub -" + @"Private Sub Test()" + Environment.NewLine + +"End Sub" + Environment.NewLine + +"Private Sub Test2()" + Environment.NewLine + +"End Sub" + Environment.NewLine + ); } @@ -123,12 +124,11 @@ End Sub public void StatementsCS2VB() { CS2VB( - "int a = 3;\n" + + "int a = 3;" + Environment.NewLine + "a++;", - @"Dim a As Integer = 3 -a += 1 -" + @"Dim a As Integer = 3" + Environment.NewLine + +"a += 1" + Environment.NewLine ); } @@ -137,18 +137,17 @@ a += 1 public void TypeMembersVB2CS() { VB2CS( - @"Sub Test() -End Sub -Sub Test2() -End Sub -", - @"public void Test() -{ -} -public void Test2() -{ -} -" + @"Sub Test()" + Environment.NewLine + +"End Sub" + Environment.NewLine + +"Sub Test2()" + Environment.NewLine + +"End Sub" + Environment.NewLine, + @"public void Test()" + Environment.NewLine + +"{" + Environment.NewLine + +"}" + Environment.NewLine + +"public void Test2()" + Environment.NewLine + +"{" + Environment.NewLine + +"}" + Environment.NewLine + ); } @@ -156,11 +155,10 @@ public void Test2() public void StatementsVB2CS() { VB2CS( - @"Dim a As Integer = 3 -a += 1 -", - "int a = 3;\r\n" + - "a += 1;\r\n" + @"Dim a As Integer = 3" + Environment.NewLine + +"a += 1" + Environment.NewLine, + "int a = 3;" + Environment.NewLine + + "a += 1;" + Environment.NewLine ); } } diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs index 9aadc9ab56..bc96394b9f 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs @@ -71,45 +71,45 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter public void MoveImportsStatement() { TestProgram("namespace test { using SomeNamespace; }", - "Imports SomeNamespace\r\n" + - "Namespace test\r\n" + - "End Namespace\r\n"); + "Imports SomeNamespace" + Environment.NewLine + + "Namespace test" + Environment.NewLine + + "End Namespace" + Environment.NewLine); } [Test] public void ClassImplementsInterface() { TestProgram("class test : IComparable { }", - "Class test\r\n" + - " Implements IComparable\r\n" + - "End Class\r\n"); + "Class test" + Environment.NewLine + + " Implements IComparable" + Environment.NewLine + + "End Class" + Environment.NewLine); } [Test] public void ClassImplementsInterface2() { TestProgram("class test : System.IComparable { }", - "Class test\r\n" + - " Implements System.IComparable\r\n" + - "End Class\r\n"); + "Class test" + Environment.NewLine + + " Implements System.IComparable" + Environment.NewLine + + "End Class" + Environment.NewLine); } [Test] public void ClassInheritsClass() { TestProgram("class test : InvalidDataException { }", - "Class test\r\n" + - " Inherits InvalidDataException\r\n" + - "End Class\r\n"); + "Class test" + Environment.NewLine + + " Inherits InvalidDataException" + Environment.NewLine + + "End Class"+ Environment.NewLine); } [Test] public void ClassInheritsClass2() { TestProgram("class test : System.IO.InvalidDataException { }", - "Class test\r\n" + - " Inherits System.IO.InvalidDataException\r\n" + - "End Class\r\n"); + "Class test" + Environment.NewLine + + " Inherits System.IO.InvalidDataException" + Environment.NewLine + + "End Class" + Environment.NewLine); } [Test] @@ -227,9 +227,9 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter [Test] public void PInvoke() { - TestMember("[DllImport(\"user32.dll\", CharSet = CharSet.Auto)]\n" + + TestMember("[DllImport(\"user32.dll\", CharSet = CharSet.Auto)]" + Environment.NewLine + "public static extern int MessageBox(IntPtr hwnd, string t, string caption, UInt32 t2);", - " _\n" + + " _" + Environment.NewLine + "Public Shared Function MessageBox(ByVal hwnd As IntPtr, ByVal t As String, ByVal caption As String, ByVal t2 As UInt32) As Integer\n" + "End Function"); @@ -406,7 +406,7 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter [Test] public void ImportAliasPrimitiveType() { - TestProgram("using T = System.Boolean;", "Imports T = System.Boolean\r\n"); + TestProgram("using T = System.Boolean;", "Imports T = System.Boolean"+ Environment.NewLine); } [Test] @@ -418,11 +418,10 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter [Test] public void StaticClass() { - TestProgram("public static class Test {}", @"Public NotInheritable Class Test - Private Sub New() - End Sub -End Class -"); + TestProgram("public static class Test {}", @"Public NotInheritable Class Test" + Environment.NewLine + +" Private Sub New()" + Environment.NewLine + +" End Sub" + Environment.NewLine + +"End Class" + Environment.NewLine); } [Test] @@ -500,19 +499,18 @@ End Class public void InlineAssignment() { TestProgram(@"public class Convert { void Run(string s) { char c; if ((c = s[0]) == '\n') { c = ' '; } } }", - @"Public Class Convert - Private Sub Run(ByVal s As String) - Dim c As Char - If (InlineAssignHelper(c, s(0))) = ControlChars.Lf Then - c = "" ""C - End If - End Sub - Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T - target = value - Return value - End Function -End Class -"); + @"Public Class Convert" + Environment.NewLine + +" Private Sub Run(ByVal s As String)" + Environment.NewLine + +" Dim c As Char" + Environment.NewLine + +" If (InlineAssignHelper(c, s(0))) = ControlChars.Lf Then" + Environment.NewLine + +" c = \" \"C" + Environment.NewLine + +" End If" + Environment.NewLine + +" End Sub" + Environment.NewLine + +" Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T" + Environment.NewLine + +" target = value" + Environment.NewLine + +" Return value" + Environment.NewLine + +" End Function" + Environment.NewLine + +"End Class" + Environment.NewLine); } [Test]