Skip to content

Commit 72b43e4

Browse files
authored
Add many more Draft 3 trace tests (#784)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 9ded71e commit 72b43e4

4 files changed

Lines changed: 6028 additions & 10 deletions

File tree

ports/javascript/describe.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export function describe(valid, instruction, evaluatePath,
417417
}
418418

419419
if (opcode === LOGICAL_AND) {
420-
if (keyword === 'allOf') {
420+
if (keyword === 'allOf' || keyword === 'extends') {
421421
const childCount = children ? children.length : 0;
422422
let message = 'The ' + typeName(targetType) +
423423
' value was expected to validate against the ';

src/compiler/default_compiler_draft3.h

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,18 +2303,25 @@ auto compiler_draft3_applicator_extends(const Context &context,
23032303
sourcemeta::core::empty_weak_pointer);
23042304
}
23052305

2306+
auto inner{compile(context, schema_context, relative_dynamic_context(),
2307+
sourcemeta::core::empty_weak_pointer,
2308+
sourcemeta::core::empty_weak_pointer)};
2309+
if (inner.empty()) {
2310+
return {};
2311+
}
2312+
23062313
return {make(sourcemeta::blaze::InstructionIndex::LogicalAnd, context,
23072314
schema_context, dynamic_context, ValueNone{},
2308-
compile(context, schema_context, relative_dynamic_context(),
2309-
sourcemeta::core::empty_weak_pointer,
2310-
sourcemeta::core::empty_weak_pointer))};
2315+
std::move(inner))};
23112316
}
23122317

23132318
if (!value.is_array()) {
23142319
return {};
23152320
}
23162321

2317-
assert(!value.empty());
2322+
if (value.empty()) {
2323+
return {};
2324+
}
23182325

23192326
Instructions children;
23202327

@@ -2331,11 +2338,19 @@ auto compiler_draft3_applicator_extends(const Context &context,
23312338
}
23322339

23332340
for (std::uint64_t index = 0; index < value.size(); index++) {
2334-
for (auto &&step : compile(
2335-
context, schema_context, relative_dynamic_context(),
2336-
{static_cast<sourcemeta::core::Pointer::Token::Index>(index)})) {
2337-
children.push_back(std::move(step));
2341+
auto arm{
2342+
compile(context, schema_context, relative_dynamic_context(),
2343+
{static_cast<sourcemeta::core::Pointer::Token::Index>(index)})};
2344+
if (arm.empty()) {
2345+
continue;
23382346
}
2347+
children.push_back(make(sourcemeta::blaze::InstructionIndex::ControlGroup,
2348+
context, schema_context, relative_dynamic_context(),
2349+
ValueNone{}, std::move(arm)));
2350+
}
2351+
2352+
if (children.empty()) {
2353+
return {};
23392354
}
23402355

23412356
return {make(sourcemeta::blaze::InstructionIndex::LogicalAnd, context,

src/evaluator/evaluator_describe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ auto describe(const bool valid, const Instruction &step,
365365
}
366366

367367
if (step.type == sourcemeta::blaze::InstructionIndex::LogicalAnd) {
368-
if (keyword == "allOf") {
368+
if (keyword == "allOf" || keyword == "extends") {
369369
assert(!step.children.empty());
370370
std::ostringstream message;
371371
message << "The " << type_name(target.type())

0 commit comments

Comments
 (0)