Skip to content

Commit

Permalink
Adding unit test for PythonTokenMaker's auto-indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbylight committed Jul 29, 2023
1 parent 4a08790 commit 1c7374c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 1c7374c

Please sign in to comment.