From 6d6589aa7ddd01043cc8a066249917686bbb981e Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 23 Aug 2009 13:47:00 +0000 Subject: [PATCH] Python code converter now converts type reference expressions. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4762 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/NRefactoryToPythonConverter.cs | 2 +- ...ectReferenceEqualsConversionTestFixture.cs | 40 +++++++++++++++++++ .../Test/PythonBinding.Tests.csproj | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ObjectReferenceEqualsConversionTestFixture.cs diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs index 3831b3a54d..66834ca7f3 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs @@ -1170,7 +1170,7 @@ namespace ICSharpCode.PythonBinding public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) { - Console.WriteLine("VisitTypeReferenceExpression"); + Append(GetTypeName(typeReferenceExpression.TypeReference)); return null; } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ObjectReferenceEqualsConversionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ObjectReferenceEqualsConversionTestFixture.cs new file mode 100644 index 0000000000..c6bc0a02d0 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ObjectReferenceEqualsConversionTestFixture.cs @@ -0,0 +1,40 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.NRefactory; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Converter +{ + [TestFixture] + public class ObjectReferenceEqualsConversionTestFixture + { + string csharp = "class Foo\r\n" + + "{\r\n" + + " public bool IsEqual(object o)\r\n" + + " {\r\n" + + " return object.ReferenceEquals(o, null);\r\n" + + " }\r\n" + + "}"; + + [Test] + public void ConvertedPythonCode() + { + NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp); + converter.IndentString = " "; + string python = converter.Convert(csharp); + string expectedPython = "class Foo(object):\r\n" + + " def IsEqual(self, o):\r\n" + + " return Object.ReferenceEquals(o, None)"; + + Assert.AreEqual(expectedPython, python, python); + } + } +} + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index 9f19d62b91..ea8ad5737d 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -138,6 +138,7 @@ +