Skip to content

Commit 63593e2

Browse files
authored
Remove entrypoint and real/integer test from the JSON traces (#687)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 7848f96 commit 63593e2

3 files changed

Lines changed: 49 additions & 86 deletions

File tree

test/evaluator/evaluator_draft4.json

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -668,44 +668,6 @@
668668
]
669669
}
670670
},
671-
{
672-
"description": "ref_2_entrypoint",
673-
"schema": {
674-
"$schema": "http://json-schema.org/draft-04/schema#",
675-
"allOf": [
676-
{ "$ref": "#/definitions/string" }
677-
],
678-
"definitions": {
679-
"string": { "type": "string" }
680-
}
681-
},
682-
"instance": "foo",
683-
"valid": true,
684-
"entrypoint": "#/allOf/0",
685-
"fast": {
686-
"pre": [
687-
[ "AssertionTypeStrict", "/$ref/type", "#/definitions/string/type", "" ]
688-
],
689-
"post": [
690-
[ true, "AssertionTypeStrict", "/$ref/type", "#/definitions/string/type", "" ]
691-
],
692-
"descriptions": [ "The value was expected to be of type string" ]
693-
},
694-
"exhaustive": {
695-
"pre": [
696-
[ "ControlJump", "/$ref", "#/allOf/0/$ref", "" ],
697-
[ "AssertionTypeStrict", "/$ref/type", "#/definitions/string/type", "" ]
698-
],
699-
"post": [
700-
[ true, "AssertionTypeStrict", "/$ref/type", "#/definitions/string/type", "" ],
701-
[ true, "ControlJump", "/$ref", "#/allOf/0/$ref", "" ]
702-
],
703-
"descriptions": [
704-
"The value was expected to be of type string",
705-
"The string value was expected to validate against the referenced schema"
706-
]
707-
}
708-
},
709671
{
710672
"description": "ref_3",
711673
"schema": {
@@ -6076,44 +6038,6 @@
60766038
]
60776039
}
60786040
},
6079-
{
6080-
"description": "enum_17",
6081-
"schema": {
6082-
"$schema": "http://json-schema.org/draft-04/schema#",
6083-
"type": "integer",
6084-
"enum": [ 3.0 ]
6085-
},
6086-
"instance": 3.0,
6087-
"valid": false,
6088-
"fast": {
6089-
"pre": [
6090-
[ "AssertionEqual", "/enum", "#/enum", "" ],
6091-
[ "AssertionTypeStrict", "/type", "#/type", "" ]
6092-
],
6093-
"post": [
6094-
[ true, "AssertionEqual", "/enum", "#/enum", "" ],
6095-
[ false, "AssertionTypeStrict", "/type", "#/type", "" ]
6096-
],
6097-
"descriptions": [
6098-
"The number value 3.0 was expected to equal the number constant 3.0",
6099-
"The value was expected to be of type integer but it was of type number"
6100-
]
6101-
},
6102-
"exhaustive": {
6103-
"pre": [
6104-
[ "AssertionEqual", "/enum", "#/enum", "" ],
6105-
[ "AssertionTypeStrict", "/type", "#/type", "" ]
6106-
],
6107-
"post": [
6108-
[ true, "AssertionEqual", "/enum", "#/enum", "" ],
6109-
[ false, "AssertionTypeStrict", "/type", "#/type", "" ]
6110-
],
6111-
"descriptions": [
6112-
"The number value 3.0 was expected to equal the number constant 3.0",
6113-
"The value was expected to be of type integer but it was of type number"
6114-
]
6115-
}
6116-
},
61176041
{
61186042
"description": "enum_18",
61196043
"schema": {

test/evaluator/evaluator_draft4_test.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,3 +1322,48 @@ TEST(Evaluator_draft4, multipleOf_18) {
13221322
"The integer value 299999999999999999999999999999999998 was expected to "
13231323
"be divisible by the integer 99999999999999999999999999999999999");
13241324
}
1325+
1326+
TEST(Evaluator_draft4, ref_2_entrypoint) {
1327+
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
1328+
"$schema": "http://json-schema.org/draft-04/schema#",
1329+
"allOf": [ { "$ref": "#/definitions/string" } ],
1330+
"definitions": {
1331+
"string": { "type": "string" }
1332+
}
1333+
})JSON")};
1334+
1335+
const sourcemeta::core::JSON instance{"foo"};
1336+
1337+
EVALUATE_WITH_TRACE_FAST_SUCCESS(schema, instance, 1, "#/allOf/0");
1338+
1339+
EVALUATE_TRACE_PRE(0, AssertionTypeStrict, "/$ref/type",
1340+
"#/definitions/string/type", "");
1341+
EVALUATE_TRACE_POST_SUCCESS(0, AssertionTypeStrict, "/$ref/type",
1342+
"#/definitions/string/type", "");
1343+
EVALUATE_TRACE_POST_DESCRIBE(instance, 0,
1344+
"The value was expected to be of type string");
1345+
}
1346+
1347+
TEST(Evaluator_draft4, enum_17) {
1348+
const sourcemeta::core::JSON schema{sourcemeta::core::parse_json(R"JSON({
1349+
"$schema": "http://json-schema.org/draft-04/schema#",
1350+
"type": "integer",
1351+
"enum": [ 3.0 ]
1352+
})JSON")};
1353+
1354+
const sourcemeta::core::JSON instance{3.0};
1355+
EVALUATE_WITH_TRACE_FAST_FAILURE(schema, instance, 2, "");
1356+
1357+
EVALUATE_TRACE_PRE(0, AssertionEqual, "/enum", "#/enum", "");
1358+
EVALUATE_TRACE_PRE(1, AssertionTypeStrict, "/type", "#/type", "");
1359+
1360+
EVALUATE_TRACE_POST_SUCCESS(0, AssertionEqual, "/enum", "#/enum", "");
1361+
EVALUATE_TRACE_POST_FAILURE(1, AssertionTypeStrict, "/type", "#/type", "");
1362+
1363+
EVALUATE_TRACE_POST_DESCRIBE(
1364+
instance, 0,
1365+
"The number value 3.0 was expected to equal the number constant 3.0");
1366+
EVALUATE_TRACE_POST_DESCRIBE(
1367+
instance, 1,
1368+
"The value was expected to be of type integer but it was of type number");
1369+
}

test/evaluator/tracesuite.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ class TraceTest : public testing::Test {
4343
const auto &instance{this->data.at("instance")};
4444
const bool expected_valid{this->data.at("valid").to_boolean()};
4545

46-
std::string entrypoint;
47-
if (this->data.defines("entrypoint")) {
48-
entrypoint = this->data.at("entrypoint").to_string();
49-
}
50-
5146
const auto &mode_data{this->data.at(this->mode_key)};
5247

5348
const auto pre{
@@ -67,11 +62,10 @@ class TraceTest : public testing::Test {
6762
assert(pre.size() == trace_descriptions.size());
6863
const auto count{pre.size()};
6964

70-
const auto compiled_schema{
71-
sourcemeta::blaze::compile(schema, sourcemeta::core::schema_walker,
72-
sourcemeta::core::schema_resolver,
73-
sourcemeta::blaze::default_schema_compiler,
74-
this->mode, "", "", entrypoint)};
65+
const auto compiled_schema{sourcemeta::blaze::compile(
66+
schema, sourcemeta::core::schema_walker,
67+
sourcemeta::core::schema_resolver,
68+
sourcemeta::blaze::default_schema_compiler, this->mode)};
7569
__ASSERT_TEMPLATE_JSON_SERIALISATION(compiled_schema);
7670
EVALUATE_WITH_TRACE(compiled_schema, instance, count);
7771

0 commit comments

Comments
 (0)