Esempio n. 1
0
  public void testPastePostStringAdaptiveIndent() throws BadLocationException {
    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    String content =
        "class foobar;\n"
            + "\n"
            + "function void foo2();\n"
            + "	$psprintf(\"Hello World\\n    Testing %d\\n\",\n"
            + "		a, b, c);\n\n";
    String expected =
        "class foobar;\n"
            + "\n"
            + "function void foo2();\n"
            + "	$psprintf(\"Hello World\\n    Testing %d\\n\",\n"
            + "		a, b, c);\n"
            + ""
            + "	if (foobar) begin\n"
            + "		a = 6;\n"
            + "	end\n";
    tester.setContent(content);
    // SVCorePlugin.getDefault().enableDebug(false);
    tester.paste("if (foobar) begin\n" + "a = 6;\n" + "end\n");

    String result = tester.getContent();

    fLog.debug("Result:\n" + result);
    IndentComparator.compare("testPastePostStringAdaptiveIndent", expected, result);
  }
Esempio n. 2
0
  public void testPasteInsertOpeningComment() throws BadLocationException {
    String input =
        "class foo;\n"
            + "\n"
            + "	function void foobar;\n"
            + "		int var;\n"
            + "		var = 5;\n"
            + "		bar = 6;\n"
            + "		*/\n"
            + "	endfunction\n"
            + "\n"
            + "endclass\n";
    String expected =
        "class foo;\n"
            + "\n"
            + "	function void foobar;\n"
            + "		int var;\n"
            + "/*\n"
            + "		var = 5;\n"
            + "		bar = 6;\n"
            + "		*/\n"
            + "	endfunction\n"
            + "\n"
            + "endclass\n";

    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    tester.setContent(input);

    tester.setCaretOffset(0);
    while (true) {
      String line = tester.readLine();
      fLog.debug("line=\"" + line + "\"");

      if (line.trim().startsWith("int var")) {
        break;
      }
    }
    tester.paste("/*\n");

    String result = tester.getContent();
    fLog.debug("Result:\n" + result);
    IndentComparator.compare("testPasteInsertOpeningComment", expected, result);
  }
Esempio n. 3
0
  public void testPasteAdaptiveIndent() throws BadLocationException {
    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    String content = "class foobar;\n" + "\n" + "function void foo2();\n\n";
    String expected =
        "class foobar;\n"
            + "\n"
            + "function void foo2();\n"
            + "	if (foobar) begin\n"
            + "		a = 6;\n"
            + "	end\n";

    tester.setContent(content);
    tester.paste("if (foobar) begin\n" + "a = 6;\n" + "end\n");

    String result = tester.getContent();

    fLog.debug("Result:\n" + result);
    IndentComparator.compare("testPasteAdaptiveIndent", expected, result);
  }
Esempio n. 4
0
  public void testPasteInModule() throws BadLocationException {

    SVCorePlugin.getDefault().enableDebug(false);

    String first = "module t();\n" + "	logic a;\n" + "endmodule\n";

    String text = "logic b;\n";

    String expected = "module t();\n" + "	logic a;\n" + "	logic b;\n" + "endmodule\n";

    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    tester.setContent(first);
    //		tester.type(first);
    tester.setCaretOffset(("module t();\n" + "	logic a;\n").length());

    tester.paste(text);

    String content = tester.getContent();

    fLog.debug("Result:\n" + content);
    IndentComparator.compare("", expected, content);
  }