Skip to content

Commit 2f8a1e8

Browse files
authored
Ensure prefixItems emits no annotations on empty arrays (#411)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 74e2d3c commit 2f8a1e8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/evaluator/evaluator_2020_12_test.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,27 @@ TEST(Evaluator_2020_12, prefixItems_2) {
572572
"the corresponding subschemas");
573573
}
574574

575+
TEST(Evaluator_2020_12, prefixItems_2_exhaustive) {
576+
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
577+
"$schema": "https://json-schema.org/draft/2020-12/schema",
578+
"prefixItems": [ { "type": "integer" }, { "type": "boolean" } ]
579+
})JSON")};
580+
581+
const sourcemeta::core::JSON instance{sourcemeta::core::parse_json("[]")};
582+
EVALUATE_WITH_TRACE_EXHAUSTIVE_SUCCESS(schema, instance, 1);
583+
584+
// Note: we don't want to emit any annotation for empty arrays
585+
EVALUATE_TRACE_PRE(0, AssertionArrayPrefix, "/prefixItems", "#/prefixItems",
586+
"");
587+
EVALUATE_TRACE_POST_SUCCESS(0, AssertionArrayPrefix, "/prefixItems",
588+
"#/prefixItems", "");
589+
590+
EVALUATE_TRACE_POST_DESCRIBE(
591+
instance, 0,
592+
"The first 2 items of the array value were expected to validate against "
593+
"the corresponding subschemas");
594+
}
595+
575596
TEST(Evaluator_2020_12, prefixItems_3) {
576597
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
577598
"$schema": "https://json-schema.org/draft/2020-12/schema",

0 commit comments

Comments
 (0)