Skip to content

Commit

Permalink
Use Metapath.compile() in range tests inline (#240)
Browse files Browse the repository at this point in the history
To improve readability, it was pointed out by @david-waltermire-nist we
can use an inline compilation in the test to make the test vectors for
Metapath ranges more readable while we working on usnistgov/metaschema#239.
  • Loading branch information
aj-stein-nist authored Oct 20, 2023
1 parent f8abaa5 commit 04abb63
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ private static Stream<Arguments> provideValues() { // NOPMD - false positive
return Stream.of(
Arguments.of(
ISequence.of(integer(2), integer(3), integer(4), integer(5)),
MetapathExpression.compile("2 to 5")),
"2 to 5"),
Arguments.of(
ISequence.empty(),
MetapathExpression.compile("() to 2")),
"() to 2"),
Arguments.of(
ISequence.empty(),
MetapathExpression.compile("2 to ()")),
"2 to ()"),
Arguments.of(
ISequence.empty(),
MetapathExpression.compile("5 to 2")));
"5 to 2"));
}

@ParameterizedTest
@MethodSource("provideValues")
void testRange(@NonNull ISequence<?> expected, @NonNull MetapathExpression metapath) {
assertEquals(expected, metapath.evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()));
void testRange(@NonNull ISequence<?> expected, @NonNull String metapath) {
assertEquals(expected, MetapathExpression.compile(metapath).evaluateAs(null, MetapathExpression.ResultType.SEQUENCE, newDynamicContext()));
}
}

0 comments on commit 04abb63

Please sign in to comment.