public void NormalizeIndentationTest() { string expected = "\r\nclass Foo {\r\n void Bar() {}\r\n}"; string actual = "\r\n\t\tclass Foo {\r\n\t\t void Bar() {}\r\n\t\t}"; StringsModule.AssertAreEqualIgnoringNewLineDifferences(expected.Trim(), StringsModule.NormalizeIndentation(actual)); }
public void RunTestCase(string testFile) { try { string testFilePath = this.ResolvePath(testFile); CompileUnit[] array = CSharpAssertModule.Convert(new FileInput(testFilePath)); CompileUnit resultingCSharpNode = array[0]; CompileUnit resultingBooNode = array[1]; string[] expectedOutput = this.GetExpectedOutput(testFilePath); string expectedCSharpOutput = expectedOutput[0]; string expectedBooOutput = expectedOutput[1]; string inputJSCode = expectedOutput[2]; Debug.WriteLine("JavaScript:\n" + inputJSCode); var output = new StringWriter(); resultingCSharpNode.Accept(new CSharpPrinter(output)); Debug.WriteLine("Generated C#:\n" + output.ToString().TrimEnd()); Debug.WriteLine("Generated Boo:\n" + resultingBooNode.ToCodeString()); CSharpAssertModule.AssertCSharpCode(expectedCSharpOutput, resultingCSharpNode); StringsModule.AssertAreEqualIgnoringNewLineDifferences(expectedBooOutput, resultingBooNode.ToCodeString()); } catch (CompilationErrorsException x) { Assert.Fail(x.Errors.ToString(true)); } }
public static void AssertCSharpCode(string expected, Node node) { var output = new StringWriter(); node.Accept(new CSharpPrinter(output)); StringsModule.AssertAreEqualIgnoringNewLineDifferences( StringsModule.NormalizeIndentation(expected), output.ToString().TrimEnd()); }