public void Setup() { string fileContent = "// I told the doctor I broke my leg in two places.\n" + "// He told me to stop going to those places.\n" + "// - Henny Youngman\n" + "\n" + "[Imperative]\n" + "{\n" + "\t aVar = 2;\n" + "\t nVar = -4.5678; // Assign value of -4.5678\n" + "\t bVar = aVar;\n" + "\t sVar = (32.7654 + 5) + bVar;\n" + "\n" + "\t // An associative block.\n" + "\t [Associative]\n" + "\t {\n" + "\t \tsVar = 3;\n" + "\t }\n" + "}\n"; testSolution = Solution.CreateTemporary(); testSolution.AddNewScript(fileContent); testSolution.ActivateScript(0); textCore = TextEditorCore.CreateTemporary(); textCore.ChangeScript(0); textCore.ParseScriptImmediate(); }
public void Setup() { string fileContent = "hello\n" + "\n" + "\t\tcruel\n" + "\tworld"; testSolution = Solution.CreateTemporary(); testSolution.AddNewScript(fileContent); testSolution.ActivateScript(0); textCore = TextEditorCore.CreateTemporary(); textCore.ChangeScript(0); }
public void TestCommentedLines() { string fileContent = "// This case tests the ability to format embedded comments\n" + "// properly. These include both multi-line and single-line\n" + "// comments syntax. \n" + " \n" + "// This line by itself should not be modified. \n" + " \n" + "a=2;// This line should be formatted (not indented). \n" + " \n" + "/* This is the beginning of a multi-line comment block \n" + " \n" + " This is a line within a multi-line comment block. \n" + " It is indented now but should not be indented further.\n" + " \n" + "This marks the end of a multi-line comment block */ \n" + " \n" + " [Imperative] // This should be un-indented. \n" + "{ \n" + " /* This is another multi-line \n" + " comment block, only that it \n" + " is indented for the scope */ \n" + " \n" + " // This should be indented. \n" + " \n" + "b=3;// Formatting should resume on this line. \n" + " c = 4 ; // And this line, too. \n" + "} \n" + " \n" + " // Spaces in comments shouldn't be normalized! \n"; Solution testSolution = Solution.CreateTemporary(); testSolution.AddNewScript(fileContent); testSolution.ActivateScript(0); TextEditorCore textCore = TextEditorCore.Instance; textCore.ChangeScript(0); textCore.ParseScriptImmediate(); SmartFormatter.Instance.AlternateEditorCore = textCore; bool formatted = textCore.FormatDocument(); Assert.AreEqual(true, formatted); SmartFormatter.Instance.AlternateEditorCore = null; Assert.AreEqual("// This case tests the ability to format embedded comments\n", textCore.GetLine(0)); Assert.AreEqual("// properly. These include both multi-line and single-line\n", textCore.GetLine(1)); Assert.AreEqual("// comments syntax. \n", textCore.GetLine(2)); Assert.AreEqual("\n", textCore.GetLine(3)); Assert.AreEqual("// This line by itself should not be modified. \n", textCore.GetLine(4)); Assert.AreEqual("\n", textCore.GetLine(5)); Assert.AreEqual("a = 2; // This line should be formatted (not indented). \n", textCore.GetLine(6)); Assert.AreEqual("\n", textCore.GetLine(7)); Assert.AreEqual("/* This is the beginning of a multi-line comment block \n", textCore.GetLine(8)); Assert.AreEqual("\n", textCore.GetLine(9)); Assert.AreEqual(" This is a line within a multi-line comment block. \n", textCore.GetLine(10)); Assert.AreEqual(" It is indented now but should not be indented further.\n", textCore.GetLine(11)); Assert.AreEqual("\n", textCore.GetLine(12)); Assert.AreEqual("This marks the end of a multi-line comment block */ \n", textCore.GetLine(13)); Assert.AreEqual("\n", textCore.GetLine(14)); Assert.AreEqual("[Imperative] // This should be un-indented. \n", textCore.GetLine(15)); Assert.AreEqual("{\n", textCore.GetLine(16)); Assert.AreEqual(" /* This is another multi-line \n", textCore.GetLine(17)); Assert.AreEqual(" comment block, only that it \n", textCore.GetLine(18)); Assert.AreEqual(" is indented for the scope */ \n", textCore.GetLine(19)); Assert.AreEqual(" \n", textCore.GetLine(20)); Assert.AreEqual(" // This should be indented. \n", textCore.GetLine(21)); Assert.AreEqual(" \n", textCore.GetLine(22)); Assert.AreEqual(" b = 3; // Formatting should resume on this line. \n", textCore.GetLine(23)); Assert.AreEqual(" c = 4; // And this line, too. \n", textCore.GetLine(24)); Assert.AreEqual("}\n", textCore.GetLine(25)); Assert.AreEqual("\n", textCore.GetLine(26)); Assert.AreEqual("// Spaces in comments shouldn't be normalized! \n", textCore.GetLine(27)); }