Skip to content

Commit

Permalink
- refactors tests to not use deprecated EvaluationValue constructor (#…
Browse files Browse the repository at this point in the history
…398)

- moves converter interface and default implementation to converter package
  • Loading branch information
uklimaschewski authored Sep 21, 2023
1 parent 34846d2 commit a659645
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package com.ezylang.evalex.config;

import com.ezylang.evalex.data.*;
import com.ezylang.evalex.data.conversion.DefaultEvaluationValueConverter;
import com.ezylang.evalex.data.conversion.EvaluationValueConverterIfc;
import com.ezylang.evalex.functions.FunctionIfc;
import com.ezylang.evalex.functions.basic.*;
import com.ezylang.evalex.functions.datetime.*;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/ezylang/evalex/data/EvaluationValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.ezylang.evalex.data;

import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.conversion.DefaultEvaluationValueConverter;
import com.ezylang.evalex.parser.ASTNode;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.EvaluationValue;

/**
* Converter interface used by the {@link com.ezylang.evalex.data.DefaultEvaluationValueConverter}.
*/
/** Converter interface used by the {@link DefaultEvaluationValueConverter}. */
public interface ConverterIfc {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.ezylang.evalex.data;
package com.ezylang.evalex.data.conversion;

import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.conversion.*;
import com.ezylang.evalex.data.EvaluationValue;
import java.util.Arrays;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.ezylang.evalex.data;
package com.ezylang.evalex.data.conversion;

import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.EvaluationValue;

/**
* Converter interface to be implemented by configurable evaluation value converters. Converts an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void testCustomConstantsMixedCase() throws EvaluationException, ParseException {
Map<String, EvaluationValue> constants =
new HashMap<>() {
{
put("A", new EvaluationValue(new BigDecimal("2.5")));
put("B", new EvaluationValue(new BigDecimal("3.9")));
put("A", EvaluationValue.numberValue(new BigDecimal("2.5")));
put("B", EvaluationValue.numberValue(new BigDecimal("3.9")));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ void testCustomConstants() {
Map<String, EvaluationValue> constants =
new HashMap<>() {
{
put("A", new EvaluationValue("a"));
put("B", new EvaluationValue("b"));
put("A", EvaluationValue.stringValue("a"));
put("B", EvaluationValue.stringValue("b"));
}
};
ExpressionConfiguration configuration =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public EvaluationValue evaluate(
Expression expression, Token operatorToken, EvaluationValue... operands) {
// dummy implementation
EvaluationValue operand = operands[0];
return new EvaluationValue(operand.getNumberValue().add(BigDecimal.ONE));
return EvaluationValue.numberValue(operand.getNumberValue().add(BigDecimal.ONE));
}
}

Expand All @@ -64,7 +64,7 @@ public EvaluationValue evaluate(
Expression expression, Token operatorToken, EvaluationValue... operands) {
// dummy implementation
EvaluationValue operand = operands[0];
return new EvaluationValue(operand.getNumberValue().add(BigDecimal.ONE));
return EvaluationValue.numberValue(operand.getNumberValue().add(BigDecimal.ONE));
}
}

Expand All @@ -74,7 +74,7 @@ public static class PostfixQuestionOperator extends AbstractOperator {
public EvaluationValue evaluate(
Expression expression, Token operatorToken, EvaluationValue... operands) {
// dummy implementation
return new EvaluationValue("?");
return EvaluationValue.stringValue("?");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.conversion.DefaultEvaluationValueConverter;
import org.junit.jupiter.api.Test;

class DefaultEvaluationValueConverterTest {
Expand Down
Loading

0 comments on commit a659645

Please sign in to comment.