Skip to content

Commit

Permalink
Updating java to use records
Browse files Browse the repository at this point in the history
  • Loading branch information
madsravn committed Oct 30, 2023
1 parent 7919fb0 commit e149b32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,7 @@

public class EvaluatorTest {

//TODO: Use record instead. Then we get all of this
private class EvalIntegerData {
public String input;
public int value;
public EvalIntegerData(String input, int value) {
this.input = input;
this.value = value;
}
}
private record EvalIntegerData(String input, int value) { }

@Test
public void testEvalIntegerExpression() {
Expand Down
68 changes: 6 additions & 62 deletions src/test/java/dk/madsravn/interpreter/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,7 @@ public void testIntegerLiteralExpression() {


// TODO: InfixDataBoolean and InfixDataInteger needs to be merged somehow
private class InfixDataBoolean {
public String input;
public String operator;
public boolean leftValue;
public boolean rightValue;
public InfixDataBoolean(String input, boolean leftValue, String operator, boolean rightValue) {
this.input = input;
this.leftValue = leftValue;
this.operator = operator;
this.rightValue = rightValue;
}
}
private record InfixDataBoolean(String input, boolean leftValue, String operator, boolean rightValue) { }

@Test
public void testParsingBooleanInfixExpressions() {
Expand Down Expand Up @@ -183,18 +172,7 @@ public void testParsingBooleanInfixExpressions() {

}

private class InfixDataInteger {
public String input;
public String operator;
public int leftValue;
public int rightValue;
public InfixDataInteger(String input, int leftValue, String operator, int rightValue) {
this.input = input;
this.leftValue = leftValue;
this.operator = operator;
this.rightValue = rightValue;
}
}
private record InfixDataInteger(String input, int leftValue, String operator, int rightValue) { }

@Test
public void testParsingIntegerInfixExpressions() {
Expand Down Expand Up @@ -237,17 +215,7 @@ public void testParsingIntegerInfixExpressions() {

}

private class PrefixDataBoolean
{
public String input;
public String operator;
public boolean value;
public PrefixDataBoolean(String input, String operator, boolean value) {
this.input = input;
this.operator = operator;
this.value = value;
}
}
private record PrefixDataBoolean(String input, String operator, boolean value) { }

@Test
public void testParsingBooleanPrefixExpression() {
Expand Down Expand Up @@ -276,17 +244,7 @@ public void testParsingBooleanPrefixExpression() {
}
}

private class PrefixDataInteger
{
public String input;
public String operator;
public int integerValue;
public PrefixDataInteger(String input, String operator, int integerValue) {
this.input = input;
this.operator = operator;
this.integerValue = integerValue;
}
}
private record PrefixDataInteger(String input, String operator, int integerValue) { }

@Test
public void testParsingIntegerPrefixExpression() {
Expand Down Expand Up @@ -315,14 +273,7 @@ public void testParsingIntegerPrefixExpression() {
}
}

private class OperatorPrecedenceParsing {
public String input;
public String expected;
public OperatorPrecedenceParsing(String input, String expected) {
this.input = input;
this.expected = expected;
}
}
private record OperatorPrecedenceParsing(String input, String expected) { }

@Test
public void testOperatorPrecedenceParsing() {
Expand Down Expand Up @@ -467,14 +418,7 @@ public void testFuntionLiteralParsing() {
assertEquals(infixExpression.getOperator(), "+");
}

private class FunctionParameterData {
public String input;
public List<String> parameters;
public FunctionParameterData(String input, List<String> parameters) {
this.input = input;
this.parameters = parameters;
}
}
private record FunctionParameterData(String input, List<String> parameters) { }

@Test
public void testFuntionParameterParsing() {
Expand Down

0 comments on commit e149b32

Please sign in to comment.