~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/BreakAndContinueConversionTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.NRefactory;
 
6
using ICSharpCode.RubyBinding;
 
7
using NUnit.Framework;
 
8
 
 
9
namespace RubyBinding.Tests.Converter
 
10
{
 
11
        /// <summary>
 
12
        /// Tests that a break statement is converted correctly.
 
13
        /// </summary>
 
14
        [TestFixture]   
 
15
        public class BreakAndContinueConversionTestFixture
 
16
        {               
 
17
                string csharp =
 
18
                        "class Foo\r\n" +
 
19
                        "{\r\n" +
 
20
                        "    public void Run()\r\n" +
 
21
                        "    {\r\n" +
 
22
                        "        int i = 0;\r\n" +
 
23
                        "        while (i < 10) {\r\n" +
 
24
                        "            if (i == 5) {\r\n" +
 
25
                        "                break;\r\n" +
 
26
                        "            } else {\r\n" +
 
27
                        "                continue;\r\n" +
 
28
                        "            }\r\n" +
 
29
                        "            i++;\r\n" +
 
30
                        "        }\r\n" +
 
31
                        "    }\r\n" +
 
32
                        "}";
 
33
                                
 
34
                [Test]
 
35
                public void ConvertedRubyCode()
 
36
                {
 
37
                        NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
 
38
                        converter.IndentString = "    ";
 
39
                        string Ruby = converter.Convert(csharp);
 
40
                        string expectedRuby =
 
41
                                "class Foo\r\n" +
 
42
                                "    def Run()\r\n" +
 
43
                                "        i = 0\r\n" +
 
44
                                "        while i < 10\r\n" +
 
45
                                "            if i == 5 then\r\n" +
 
46
                                "                break\r\n" +
 
47
                                "            else\r\n" +
 
48
                                "                next\r\n" +
 
49
                                "            end\r\n" +
 
50
                                "            i += 1\r\n" +
 
51
                                "        end\r\n" +
 
52
                                "    end\r\n" +
 
53
                                "end";
 
54
                        
 
55
                        Assert.AreEqual(expectedRuby, Ruby, Ruby);
 
56
                }
 
57
        }
 
58
}