From 1c7374cb6afa3817567abbcf19e716a78436f261 Mon Sep 17 00:00:00 2001 From: bobbylight Date: Sat, 29 Jul 2023 10:26:11 -0400 Subject: [PATCH] Adding unit test for PythonTokenMaker's auto-indentation --- .../modes/AbstractTokenMakerTest.java | 2 +- .../modes/PythonTokenMakerTest.java | 22 +++++++++++++++++++ .../ui/rsyntaxtextarea/demo/DemoRootPane.java | 3 +-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/AbstractTokenMakerTest.java b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/AbstractTokenMakerTest.java index 36d07c301..be7064712 100644 --- a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/AbstractTokenMakerTest.java +++ b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/AbstractTokenMakerTest.java @@ -177,7 +177,7 @@ protected void testCommon_getShouldIndentNextLineAfter() { /** * Helper method for {@link #testCommon_getShouldIndentNextLineAfter()} to verify that indentation of - * the next ine is done after curly braces and open parens for a specific language index. + * the next line is done after curly braces and open parens for a specific language index. * * @param languageIndex The language index to check. */ diff --git a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/PythonTokenMakerTest.java b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/PythonTokenMakerTest.java index 2fed18565..c0800e134 100644 --- a/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/PythonTokenMakerTest.java +++ b/RSyntaxTextArea/src/test/java/org/fife/ui/rsyntaxtextarea/modes/PythonTokenMakerTest.java @@ -4,6 +4,8 @@ */ package org.fife.ui.rsyntaxtextarea.modes; +import org.fife.ui.rsyntaxtextarea.Token; +import org.fife.ui.rsyntaxtextarea.TokenImpl; import org.fife.ui.rsyntaxtextarea.TokenMaker; import org.fife.ui.rsyntaxtextarea.TokenTypes; import org.junit.jupiter.api.AfterEach; @@ -83,6 +85,26 @@ public void testCommon_GetLineCommentStartAndEnd() { } + @Test + @Override + protected void testCommon_getShouldIndentNextLineAfter() { + + TokenMaker tm = createTokenMaker(); + + Token[] tokensToIndentAfter = { + new TokenImpl(":".toCharArray(), 0, 0, 0, TokenTypes.SEPARATOR, 0), + new TokenImpl("\\".toCharArray(), 0, 0, 0, TokenTypes.SEPARATOR, 0), + }; + for (Token token: tokensToIndentAfter) { + Assertions.assertTrue(tm.getShouldIndentNextLineAfter(token)); + } + + Token t = new TokenImpl("false".toCharArray(), 0, 0, 0, + TokenTypes.LITERAL_BOOLEAN, 0); + Assertions.assertFalse(tm.getShouldIndentNextLineAfter(t)); + } + + @Test void testIntegers() { assertAllTokensOfType(TokenTypes.LITERAL_NUMBER_DECIMAL_INT, diff --git a/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java b/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java index 0abf1f961..9fd54d5c0 100755 --- a/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java +++ b/RSyntaxTextAreaDemo/src/main/java/org/fife/ui/rsyntaxtextarea/demo/DemoRootPane.java @@ -4,7 +4,7 @@ */ package org.fife.ui.rsyntaxtextarea.demo; -import java.awt.BorderLayout; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; @@ -19,7 +19,6 @@ import javax.swing.*; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; -//import javax.swing.text.StyleConstants; import org.fife.ui.rsyntaxtextarea.*; import org.fife.ui.rtextarea.FoldIndicatorStyle;