Skip to content

Commit 9e3fcc7

Browse files
committed
add test with large array 81 element
1 parent a954cf7 commit 9e3fcc7

3 files changed

Lines changed: 991 additions & 1 deletion

File tree

src/test/java/com/dashjoin/jsonata/ArrayTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import static java.util.Arrays.asList;
55
import static java.util.Map.of;
66
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import java.io.File;
10+
import java.io.IOException;
711
import java.util.Arrays;
812
import java.util.List;
913
import java.util.Map;
1014
import org.junit.jupiter.api.Assertions;
11-
import org.junit.jupiter.api.Disabled;
1215
import org.junit.jupiter.api.Test;
1316

1417
public class ArrayTest {
@@ -83,4 +86,15 @@ public void testSortTypes() {
8386
e = jsonata("[{'value': 'b'}, {'value': 'a'}] ^(<value).value");
8487
Assertions.assertEquals(List.of("a", "b"), e.evaluate(null));
8588
}
89+
90+
//This test only shows the problem on a large array. Experiments show an error on element 81.
91+
@Test
92+
public void testSortLargeArray() throws IOException {
93+
Object data = new ObjectMapper().readValue(new File("test/ISSUE-114-largeArrayToSort.json"), Object.class);
94+
Object result = new ObjectMapper().readValue(new File("test/ISSUE-114-largeArrayResult.json"), Object.class);
95+
96+
var expression = jsonata("$sort($, function($l, $r){$l.*.rank < $r.*.rank})");
97+
Object evaluate = expression.evaluate(data);
98+
Assertions.assertEquals(result, evaluate);
99+
}
86100
}

0 commit comments

Comments
 (0)