Skip to content

Commit

Permalink
Add Markdown and test variants
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldobapvicjr committed Sep 26, 2024
1 parent 76389c5 commit 90118b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/references/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Available through the _ExpressionConfiguration.StandardFunctionsDictionary_ cons
| Name | Description |
|---------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| ABS(value) | Absolute (non-negative) value |
| AVERAGE(value, ...) | Returns the average (arithmetic mean) of all parameters. |
| AVERAGE(value, ...) | Returns the average (arithmetic mean) of all parameters. If a parameter is of type _ARRAY_, the average of all elements is calculated. |
| CEILING(value) | Rounds the given value an integer using the rounding mode CEILING |
| COALESCE(value, ...) | Returns the first non-null parameter, or NULL if all parameters are null |
| FACT(base) | Calculates the factorial of a base value |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private BigDecimal average(MathContext mathContext, EvaluationValue... parameter
}

private SumAndCount recursiveSumAndCount(EvaluationValue parameter) {
SumAndCount aux = new SumAndCount(BigDecimal.ZERO, BigDecimal.ZERO);
SumAndCount aux = new SumAndCount();
if (parameter.isArrayValue()) {
for (EvaluationValue element : parameter.getArrayValue()) {
aux = aux.plus(recursiveSumAndCount(element));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import com.ezylang.evalex.EvaluationException;
import com.ezylang.evalex.Expression;
import com.ezylang.evalex.parser.ParseException;
Expand All @@ -40,8 +42,8 @@ void testAverageSingleArray() throws EvaluationException, ParseException {

@Test
void testAverageMultipleArray() throws EvaluationException, ParseException {
Integer[] numbers1 = {1, 2, 3};
Integer[] numbers2 = {4, 5, 6};
List<Number> numbers1 = List.of(1, 2, 3);
List<Number> numbers2 = List.of(4, 5, 6);

Expression expression =
new Expression("AVERAGE(numbers1, numbers2)")
Expand All @@ -53,7 +55,7 @@ void testAverageMultipleArray() throws EvaluationException, ParseException {

@Test
void testAverageMixedArrayNumber() throws EvaluationException, ParseException {
Integer[] numbers = {1, 2, 3};
Double[] numbers = {1.0, 2.0, 3.0};

Expression expression = new Expression("AVERAGE(numbers, 4)").with("numbers", numbers);

Expand Down

0 comments on commit 90118b6

Please sign in to comment.