Browse Source

Support converting VB.NET exit statements to Python.

4.0
Matt Ward 14 years ago
parent
commit
8926ba5a93
  1. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  2. 38
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/VBExitConversionTests.cs
  3. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

2
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

@ -549,7 +549,7 @@ namespace ICSharpCode.PythonBinding @@ -549,7 +549,7 @@ namespace ICSharpCode.PythonBinding
public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
{
Console.WriteLine("VisitExitStatement");
AppendIndentedLine("break");
return null;
}

38
src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/VBExitConversionTests.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class VBExitConversionTests
{
string vb =
"Public Class Class1\r\n" +
" Public Sub Test\r\n" +
" While True\r\n" +
" Exit While\r\n" +
" End While\r\n" +
" End Sub\r\n" +
"End Class\r\n";
[Test]
public void ConvertedPythonCode()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string python = converter.Convert(vb);
string expectedPython =
"class Class1(object):\r\n" +
" def Test(self):\r\n" +
" while True:\r\n" +
" break";
Assert.AreEqual(expectedPython, python);
}
}
}

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -178,6 +178,7 @@ @@ -178,6 +178,7 @@
<Compile Include="Converter\UnaryOperatorConversionTests.cs" />
<Compile Include="Converter\UsingStatementConversionTestFixture.cs" />
<Compile Include="Converter\VBClassConversionTestFixture.cs" />
<Compile Include="Converter\VBExitConversionTests.cs" />
<Compile Include="Converter\VBStringConcatTestFixture.cs" />
<Compile Include="Converter\WhileLoopConversionTestFixture.cs" />
<Compile Include="Converter\XmlDocCommentConversionTestFixture.cs" />

Loading…
Cancel
Save