Migrate from JUnit 4 to 5

This commit is contained in:
Riccardo Azzolini 2019-08-12 17:45:20 +02:00
parent fc119efedc
commit b3f2ad82d0
10 changed files with 121 additions and 173 deletions

View File

@ -46,8 +46,8 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -29,18 +29,4 @@ public class DslAggregateException extends Exception {
public List<DslError> getErrors() { public List<DslError> getErrors() {
return errors; return errors;
} }
@Override
public boolean equals(final Object o) {
if (!(o instanceof DslAggregateException)) {
return false;
}
final DslAggregateException other = (DslAggregateException) o;
return this.errors.equals(other.errors);
}
@Override
public int hashCode() {
return Objects.hash(errors);
}
} }

View File

@ -1,35 +0,0 @@
package it.cavallium.warppi;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest extends TestCase {
/**
* Create the test case
*
* @param testName
* name of the test case
*/
public AppTest(final String testName) {
super(testName);
}
/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite(AppTest.class);
}
/**
* Rigourous Test :-)
*/
public void testApp() {
Assert.assertTrue(true);
}
}

View File

@ -10,13 +10,13 @@ import it.cavallium.warppi.math.rules.RuleType;
import it.cavallium.warppi.math.rules.dsl.patterns.*; import it.cavallium.warppi.math.rules.dsl.patterns.*;
import it.cavallium.warppi.util.Error; import it.cavallium.warppi.util.Error;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.math.BigDecimal; import java.math.BigDecimal;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class PatternRuleTest { class PatternRuleTest {
private final MathContext mathContext = new MathContext(); private final MathContext mathContext = new MathContext();
private final Pattern x = new SubFunctionPattern("x"); private final Pattern x = new SubFunctionPattern("x");
@ -26,7 +26,7 @@ public class PatternRuleTest {
); );
@Test @Test
public void testNonMatching() throws InterruptedException, Error { void testNonMatching() throws InterruptedException, Error {
final Function func = new Sum( final Function func = new Sum(
mathContext, mathContext,
new Number(mathContext, 1), new Number(mathContext, 1),
@ -38,7 +38,7 @@ public class PatternRuleTest {
} }
@Test @Test
public void testMatching() throws InterruptedException, Error { void testMatching() throws InterruptedException, Error {
final Function func = new Sum( final Function func = new Sum(
mathContext, mathContext,
new Number(mathContext, 1), new Number(mathContext, 1),
@ -57,7 +57,7 @@ public class PatternRuleTest {
} }
@Test @Test
public void testMatchingRecursive() throws InterruptedException, Error { void testMatchingRecursive() throws InterruptedException, Error {
final Function func = new Sum( final Function func = new Sum(
mathContext, mathContext,
new Number(mathContext, 3), new Number(mathContext, 3),
@ -85,13 +85,14 @@ public class PatternRuleTest {
} }
@Test @Test
public void testMultipleReplacements() throws InterruptedException, Error { void testMultipleReplacements() throws InterruptedException, Error {
final Number one = new Number(mathContext, 1); final Number one = new Number(mathContext, 1);
final Number two = new Number(mathContext, 2); final Number two = new Number(mathContext, 2);
final Function func = new SumSubtraction(mathContext, one, two); final Function func = new SumSubtraction(mathContext, one, two);
final Pattern x = new SubFunctionPattern("x"); final Pattern x = new SubFunctionPattern("x");
final Pattern y = new SubFunctionPattern("y"); final Pattern y = new SubFunctionPattern("y");
@SuppressWarnings("SuspiciousNameCombination")
final PatternRule rule = new PatternRule( final PatternRule rule = new PatternRule(
"TestRule", "TestRule",
RuleType.EXPANSION, RuleType.EXPANSION,
@ -108,7 +109,7 @@ public class PatternRuleTest {
} }
@Test @Test
public void testNoReplacements() throws InterruptedException, Error { void testNoReplacements() throws InterruptedException, Error {
final Function func = new Sum( final Function func = new Sum(
mathContext, mathContext,
new Number(mathContext, 1), new Number(mathContext, 1),

View File

@ -10,18 +10,18 @@ import it.cavallium.warppi.math.functions.equations.EquationsSystem;
import it.cavallium.warppi.math.functions.trigonometry.*; import it.cavallium.warppi.math.functions.trigonometry.*;
import it.cavallium.warppi.math.rules.dsl.patterns.*; import it.cavallium.warppi.math.rules.dsl.patterns.*;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class PatternTest { class PatternTest {
private final MathContext mathContext = new MathContext(); private final MathContext mathContext = new MathContext();
@Test @Test
public void subFunctionPattern() { void subFunctionPattern() {
final Pattern pattern = new SubFunctionPattern("x"); final Pattern pattern = new SubFunctionPattern("x");
final Function func = new Sum( final Function func = new Sum(
@ -36,16 +36,19 @@ public class PatternTest {
assertEquals(func, pattern.replace(mathContext, subFunctions.get())); assertEquals(func, pattern.replace(mathContext, subFunctions.get()));
} }
@Test(expected = UndefinedSubFunctionException.class) // TODO assert exception.getSubFunctionName().equals("x") @Test
public void undefinedSubFunction() { void undefinedSubFunction() {
final Pattern pattern = new SubFunctionPattern("x"); final Pattern pattern = new SubFunctionPattern("x");
final Map<String, Function> subFunctions = Collections.singletonMap("y", new Number(mathContext, 1)); final Map<String, Function> subFunctions = Collections.singletonMap("y", new Number(mathContext, 1));
pattern.replace(mathContext, subFunctions); final var exception = assertThrows(UndefinedSubFunctionException.class, () ->
pattern.replace(mathContext, subFunctions)
);
assertEquals("x", exception.getSubFunctionName());
} }
@Test @Test
public void sumPattern() { void sumPattern() {
final Pattern pattern = new SumPattern( final Pattern pattern = new SumPattern(
new SubFunctionPattern("x"), new SubFunctionPattern("x"),
new SubFunctionPattern("y") new SubFunctionPattern("y")
@ -69,7 +72,7 @@ public class PatternTest {
} }
@Test @Test
public void repeatedSubFunction() { void repeatedSubFunction() {
final Pattern pattern = new SumPattern( final Pattern pattern = new SumPattern(
new SubFunctionPattern("x"), new SubFunctionPattern("x"),
new SubFunctionPattern("x") new SubFunctionPattern("x")
@ -93,7 +96,7 @@ public class PatternTest {
} }
@Test @Test
public void numberPattern() { void numberPattern() {
final Pattern pattern = new NumberPattern(BigDecimal.valueOf(Math.PI)); final Pattern pattern = new NumberPattern(BigDecimal.valueOf(Math.PI));
final Function shouldNotMatch = new Number(mathContext, 2); final Function shouldNotMatch = new Number(mathContext, 2);
@ -106,7 +109,7 @@ public class PatternTest {
} }
@Test @Test
public void negativePattern() { void negativePattern() {
final Pattern pattern = new NegativePattern( final Pattern pattern = new NegativePattern(
new SubFunctionPattern("x") new SubFunctionPattern("x")
); );
@ -124,7 +127,7 @@ public class PatternTest {
} }
@Test @Test
public void negativePatternForNumber() { void negativePatternForNumber() {
final Pattern pattern = new NegativePattern( final Pattern pattern = new NegativePattern(
new NumberPattern(new BigDecimal(1)) new NumberPattern(new BigDecimal(1))
); );
@ -139,7 +142,7 @@ public class PatternTest {
} }
@Test @Test
public void undefinedPattern() { void undefinedPattern() {
final Pattern pattern = new UndefinedPattern(); final Pattern pattern = new UndefinedPattern();
final Function shouldNotMatch = new Number(mathContext, 0); final Function shouldNotMatch = new Number(mathContext, 0);
@ -152,7 +155,7 @@ public class PatternTest {
} }
@Test @Test
public void equationsSystemPattern() { void equationsSystemPattern() {
final Pattern pattern = new EquationsSystemPattern(new Pattern[]{ final Pattern pattern = new EquationsSystemPattern(new Pattern[]{
new SubFunctionPattern("x"), new SubFunctionPattern("x"),
new SubFunctionPattern("y"), new SubFunctionPattern("y"),
@ -182,7 +185,7 @@ public class PatternTest {
} }
@Test @Test
public void rootPatternForRootSquare() { void rootPatternForRootSquare() {
final Pattern pattern = new RootPattern( final Pattern pattern = new RootPattern(
new SubFunctionPattern("x"), new SubFunctionPattern("x"),
new SubFunctionPattern("y") new SubFunctionPattern("y")
@ -210,7 +213,7 @@ public class PatternTest {
} }
@Test @Test
public void constantPattern() { void constantPattern() {
final Pattern pattern = new ConstantPattern(MathematicalSymbols.PI); final Pattern pattern = new ConstantPattern(MathematicalSymbols.PI);
final Function shouldNotMatch = new Variable( final Function shouldNotMatch = new Variable(
@ -231,7 +234,7 @@ public class PatternTest {
} }
@Test @Test
public void otherBinaryPatterns() { void otherBinaryPatterns() {
final Number one = new Number(mathContext, 1); final Number one = new Number(mathContext, 1);
final Number two = new Number(mathContext, 2); final Number two = new Number(mathContext, 2);
final SubFunctionPattern x = new SubFunctionPattern("x"); final SubFunctionPattern x = new SubFunctionPattern("x");
@ -239,6 +242,7 @@ public class PatternTest {
final Function shouldNotMatch = new Sum(mathContext, one, two); final Function shouldNotMatch = new Sum(mathContext, one, two);
@SuppressWarnings("SuspiciousNameCombination")
final List<ImmutablePair<Pattern, Function>> patternsAndMatchingFunctions = Arrays.asList( final List<ImmutablePair<Pattern, Function>> patternsAndMatchingFunctions = Arrays.asList(
new ImmutablePair<>( new ImmutablePair<>(
new DivisionPattern(x, y), new DivisionPattern(x, y),
@ -278,7 +282,7 @@ public class PatternTest {
} }
@Test @Test
public void otherUnaryPatterns() { void otherUnaryPatterns() {
final Number one = new Number(mathContext, 1); final Number one = new Number(mathContext, 1);
final SubFunctionPattern x = new SubFunctionPattern("x"); final SubFunctionPattern x = new SubFunctionPattern("x");

View File

@ -10,23 +10,18 @@ import it.cavallium.warppi.math.rules.dsl.patterns.NegativePattern;
import it.cavallium.warppi.math.rules.dsl.patterns.NumberPattern; import it.cavallium.warppi.math.rules.dsl.patterns.NumberPattern;
import it.cavallium.warppi.math.rules.dsl.patterns.SubFunctionPattern; import it.cavallium.warppi.math.rules.dsl.patterns.SubFunctionPattern;
import it.cavallium.warppi.math.rules.dsl.patterns.SumPattern; import it.cavallium.warppi.math.rules.dsl.patterns.SumPattern;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.*;
public class RulesDslTest {
@org.junit.Rule
public ExpectedException thrown = ExpectedException.none();
class RulesDslTest {
@Test @Test
public void validRules() throws DslAggregateException { void validRules() throws DslAggregateException {
final List<Rule> rules = RulesDsl.makeRules( final List<Rule> rules = RulesDsl.makeRules(
"reduction test1: x -> x\n" + "reduction test1: x -> x\n" +
"expansion test2:\n" + "expansion test2:\n" +
@ -63,38 +58,35 @@ public class RulesDslTest {
} }
@Test @Test
public void lexerError() throws DslAggregateException { void lexerError() {
thrown.expect(DslAggregateException.class); final var exception = assertThrows(DslAggregateException.class, () ->
thrown.expect(equalTo( RulesDsl.makeRules("reduction test: 2. 5 -> 1")
new DslAggregateException(Collections.singletonList( );
final var expectedErrors = Collections.singletonList(
new IncompleteNumberLiteral(16, "2.") new IncompleteNumberLiteral(16, "2.")
)) );
)); assertEquals(expectedErrors, exception.getErrors());
RulesDsl.makeRules("reduction test: 2. 5 -> 1");
} }
@Test @Test
public void parserError() throws DslAggregateException { void parserError() {
thrown.expect(DslAggregateException.class); final var exception = assertThrows(DslAggregateException.class, () ->
thrown.expect(equalTo( RulesDsl.makeRules("existence test: x + y ->")
new DslAggregateException(Collections.singletonList( );
final var expectedErrors = Collections.singletonList(
new UnexpectedToken(new Token(TokenType.EOF, "", 24)) new UnexpectedToken(new Token(TokenType.EOF, "", 24))
)) );
)); assertEquals(expectedErrors, exception.getErrors());
RulesDsl.makeRules("existence test: x + y ->");
} }
@Test @Test
public void undefinedSubFunction() throws DslAggregateException { void undefinedSubFunction() {
thrown.expect(DslAggregateException.class); final var exception = assertThrows(DslAggregateException.class, () ->
thrown.expect(equalTo( RulesDsl.makeRules("expansion test: x -> x + y")
new DslAggregateException(Collections.singletonList( );
final var expectedErrors = Collections.singletonList(
new UndefinedSubFunction(new Token(TokenType.IDENTIFIER, "y", 25)) new UndefinedSubFunction(new Token(TokenType.IDENTIFIER, "y", 25))
)) );
)); assertEquals(expectedErrors, exception.getErrors());
RulesDsl.makeRules("expansion test: x -> x + y");
} }
} }

View File

@ -1,16 +1,16 @@
package it.cavallium.warppi.math.rules.dsl.errorutils; package it.cavallium.warppi.math.rules.dsl.errorutils;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class LineMapTest { class LineMapTest {
@Test @Test
public void emptyText() { void emptyText() {
String text = ""; String text = "";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -18,7 +18,7 @@ public class LineMapTest {
} }
@Test @Test
public void noLineSeparators() { void noLineSeparators() {
String text = "single line"; String text = "single line";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -29,7 +29,7 @@ public class LineMapTest {
} }
@Test @Test
public void trailingLf() { void trailingLf() {
String text = "single line\n"; String text = "single line\n";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -40,7 +40,7 @@ public class LineMapTest {
} }
@Test @Test
public void trailingCr() { void trailingCr() {
String text = "single line\r"; String text = "single line\r";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -51,7 +51,7 @@ public class LineMapTest {
} }
@Test @Test
public void trailingCrLf() { void trailingCrLf() {
String text = "single line\r\n"; String text = "single line\r\n";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -62,7 +62,7 @@ public class LineMapTest {
} }
@Test @Test
public void multipleNonEmptyLines() { void multipleNonEmptyLines() {
String text = "line 1\nline 2\rline 3\r\nline 4"; String text = "line 1\nline 2\rline 3\r\nline 4";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -76,7 +76,7 @@ public class LineMapTest {
} }
@Test @Test
public void singleEmptyLine() { void singleEmptyLine() {
String text = "\n"; String text = "\n";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -87,7 +87,7 @@ public class LineMapTest {
} }
@Test @Test
public void multipleEmptyLines() { void multipleEmptyLines() {
String text = "\r\n\n\r"; String text = "\r\n\n\r";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -100,7 +100,7 @@ public class LineMapTest {
} }
@Test @Test
public void mixedEmptyAndNonEmptyLines() { void mixedEmptyAndNonEmptyLines() {
String text = "line 1\nline 2\r\r\nline 4\n\n"; String text = "line 1\nline 2\r\r\nline 4\n\n";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -115,7 +115,7 @@ public class LineMapTest {
} }
@Test @Test
public void emptySubstrings() { void emptySubstrings() {
String text = "single line\n"; String text = "single line\n";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);
@ -128,7 +128,7 @@ public class LineMapTest {
} }
@Test @Test
public void substringIsJustLineSeparator() { void substringIsJustLineSeparator() {
String separator = "\n"; String separator = "\n";
String text = "line 1" + separator + "line 2"; String text = "line 1" + separator + "line 2";
LineMap map = new LineMap(text); LineMap map = new LineMap(text);

View File

@ -1,8 +1,8 @@
package it.cavallium.warppi.math.rules.dsl.frontend; package it.cavallium.warppi.math.rules.dsl.frontend;
import it.cavallium.warppi.math.rules.dsl.DslError; import it.cavallium.warppi.math.rules.dsl.DslError;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -10,18 +10,18 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import static it.cavallium.warppi.math.rules.dsl.frontend.TokenType.*; import static it.cavallium.warppi.math.rules.dsl.frontend.TokenType.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class LexerTest { class LexerTest {
private final List<DslError> errors = new ArrayList<>(); private final List<DslError> errors = new ArrayList<>();
@Before @BeforeEach
public void setUp() { void setUp() {
errors.clear(); errors.clear();
} }
@Test @Test
public void emptyInput() { void emptyInput() {
final Lexer lexer = new Lexer("", errors::add); final Lexer lexer = new Lexer("", errors::add);
final List<Token> expected = Collections.singletonList( final List<Token> expected = Collections.singletonList(
new Token(EOF, "", 0) new Token(EOF, "", 0)
@ -30,7 +30,7 @@ public class LexerTest {
} }
@Test @Test
public void validRule() { void validRule() {
final Lexer lexer = new Lexer( final Lexer lexer = new Lexer(
"reduction TestRule_123:\n" + "reduction TestRule_123:\n" +
" x + y * z = -(a_123 +- 3 / 2.2) -> [\n" + " x + y * z = -(a_123 +- 3 / 2.2) -> [\n" +
@ -85,7 +85,7 @@ public class LexerTest {
} }
@Test @Test
public void incompleteNumberOtherChar() { void incompleteNumberOtherChar() {
final Lexer lexer = new Lexer("2. 5 + 3", errors::add); final Lexer lexer = new Lexer("2. 5 + 3", errors::add);
final List<Token> expectedTokens = Arrays.asList( final List<Token> expectedTokens = Arrays.asList(
@ -103,7 +103,7 @@ public class LexerTest {
} }
@Test @Test
public void incompleteNumberEof() { void incompleteNumberEof() {
final Lexer lexer = new Lexer("2.", errors::add); final Lexer lexer = new Lexer("2.", errors::add);
final List<Token> expectedTokens = Collections.singletonList( final List<Token> expectedTokens = Collections.singletonList(
@ -118,7 +118,7 @@ public class LexerTest {
} }
@Test @Test
public void unexpectedCharacters() { void unexpectedCharacters() {
final Lexer lexer = new Lexer("reduction @| .: {}", errors::add); final Lexer lexer = new Lexer("reduction @| .: {}", errors::add);
final List<Token> expectedTokens = Arrays.asList( final List<Token> expectedTokens = Arrays.asList(
@ -137,7 +137,7 @@ public class LexerTest {
} }
@Test @Test
public void unterminatedComment() { void unterminatedComment() {
final Lexer lexer = new Lexer("reduction /* test:\n x -> x", errors::add); final Lexer lexer = new Lexer("reduction /* test:\n x -> x", errors::add);
final List<Token> expectedTokens = Arrays.asList( final List<Token> expectedTokens = Arrays.asList(
@ -153,7 +153,7 @@ public class LexerTest {
} }
@Test @Test
public void errorOrder() { void errorOrder() {
final Lexer lexer = new Lexer(".2. @", errors::add); final Lexer lexer = new Lexer(".2. @", errors::add);
final List<Token> expectedTokens = Collections.singletonList( final List<Token> expectedTokens = Collections.singletonList(

View File

@ -7,8 +7,8 @@ import it.cavallium.warppi.math.rules.dsl.Pattern;
import it.cavallium.warppi.math.rules.dsl.PatternRule; import it.cavallium.warppi.math.rules.dsl.PatternRule;
import it.cavallium.warppi.math.rules.dsl.patterns.*; import it.cavallium.warppi.math.rules.dsl.patterns.*;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -19,18 +19,18 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static it.cavallium.warppi.math.rules.dsl.frontend.TokenType.*; import static it.cavallium.warppi.math.rules.dsl.frontend.TokenType.*;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
public class ParserTest { class ParserTest {
private final List<DslError> errors = new ArrayList<>(); private final List<DslError> errors = new ArrayList<>();
@Before @BeforeEach
public void setUp() { void setUp() {
errors.clear(); errors.clear();
} }
@Test @Test
public void noRules() { void noRules() {
final List<Token> tokens = Collections.singletonList( final List<Token> tokens = Collections.singletonList(
new Token(EOF, "", 0) new Token(EOF, "", 0)
); );
@ -39,7 +39,7 @@ public class ParserTest {
} }
@Test @Test
public void validRuleMultipleReplacements() { void validRuleMultipleReplacements() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "TestRule_123", 10), new Token(IDENTIFIER, "TestRule_123", 10),
@ -127,7 +127,7 @@ public class ParserTest {
} }
@Test @Test
public void validRuleNoReplacements() { void validRuleNoReplacements() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -154,7 +154,7 @@ public class ParserTest {
} }
@Test @Test
public void validRuleOneReplacement() { void validRuleOneReplacement() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -188,7 +188,7 @@ public class ParserTest {
} }
@Test @Test
public void validRuleOneReplacementBrackets() { void validRuleOneReplacementBrackets() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -232,7 +232,7 @@ public class ParserTest {
} }
@Test @Test
public void multipleValidRules() { void multipleValidRules() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test1", 0), new Token(IDENTIFIER, "test1", 0),
@ -291,7 +291,7 @@ public class ParserTest {
} }
@Test @Test
public void subFunctionIdentifiers() { void subFunctionIdentifiers() {
final List<ReferenceEqualityToken> rule0x = new ArrayList<>(); final List<ReferenceEqualityToken> rule0x = new ArrayList<>();
final List<ReferenceEqualityToken> rule1x = new ArrayList<>(); final List<ReferenceEqualityToken> rule1x = new ArrayList<>();
final List<ReferenceEqualityToken> rule1y = new ArrayList<>(); final List<ReferenceEqualityToken> rule1y = new ArrayList<>();
@ -400,8 +400,8 @@ public class ParserTest {
// The EOF token is inserted by the lexer, therefore it can only be missing // The EOF token is inserted by the lexer, therefore it can only be missing
// in case of programming errors, and not directly because of user input. // in case of programming errors, and not directly because of user input.
@Test(expected = RuntimeException.class) @Test
public void missingEof() { void missingEof() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -414,11 +414,11 @@ public class ParserTest {
new Token(RIGHT_BRACKET, "]", 0) new Token(RIGHT_BRACKET, "]", 0)
); );
final Parser parser = new Parser(tokens, errors::add); final Parser parser = new Parser(tokens, errors::add);
parser.parse(); assertThrows(RuntimeException.class, parser::parse);
} }
@Test @Test
public void incompleteRule() { void incompleteRule() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -440,7 +440,7 @@ public class ParserTest {
} }
@Test @Test
public void missingRuleType() { void missingRuleType() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
new Token(EOF, "", 0) new Token(EOF, "", 0)
@ -457,7 +457,7 @@ public class ParserTest {
} }
@Test @Test
public void unexpectedTokenPrimary() { void unexpectedTokenPrimary() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -481,7 +481,7 @@ public class ParserTest {
} }
@Test @Test
public void missingRuleName() { void missingRuleName() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(COLON, ":", 0), new Token(COLON, ":", 0),
@ -499,7 +499,7 @@ public class ParserTest {
} }
@Test @Test
public void missingColon() { void missingColon() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -520,7 +520,7 @@ public class ParserTest {
} }
@Test @Test
public void missingArrow() { void missingArrow() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -541,7 +541,7 @@ public class ParserTest {
} }
@Test @Test
public void missingRightBracket() { void missingRightBracket() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -564,7 +564,7 @@ public class ParserTest {
} }
@Test @Test
public void missingOneArgFunctionLeftParen() { void missingOneArgFunctionLeftParen() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -589,7 +589,7 @@ public class ParserTest {
} }
@Test @Test
public void missingOneArgFunctionRightParen() { void missingOneArgFunctionRightParen() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -614,7 +614,7 @@ public class ParserTest {
} }
@Test @Test
public void missingTwoArgFunctionLeftParen() { void missingTwoArgFunctionLeftParen() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -641,7 +641,7 @@ public class ParserTest {
} }
@Test @Test
public void missingTwoArgFunctionComma() { void missingTwoArgFunctionComma() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -668,7 +668,7 @@ public class ParserTest {
} }
@Test @Test
public void missingTwoArgFunctionRightParen() { void missingTwoArgFunctionRightParen() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -695,7 +695,7 @@ public class ParserTest {
} }
@Test @Test
public void missingExpressionRightParen() { void missingExpressionRightParen() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(EXISTENCE, "existence", 0), new Token(EXISTENCE, "existence", 0),
new Token(IDENTIFIER, "test", 0), new Token(IDENTIFIER, "test", 0),
@ -719,7 +719,7 @@ public class ParserTest {
} }
@Test @Test
public void recoveryToNextRule() { void recoveryToNextRule() {
final List<Token> tokens = Arrays.asList( final List<Token> tokens = Arrays.asList(
new Token(REDUCTION, "reduction", 0), new Token(REDUCTION, "reduction", 0),
new Token(IDENTIFIER, "test1", 0), new Token(IDENTIFIER, "test1", 0),

View File

@ -92,9 +92,9 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit</artifactId> <artifactId>junit-jupiter</artifactId>
<version>4.12</version> <version>5.5.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>