Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 31d3868e3f4217be3ed5de3b0ea31d521f1b873c
core https://github.com/sourcemeta/core e4d7ae9358710fc138d2afd3179db6d850e4190f
bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e
14 changes: 10 additions & 4 deletions src/compiler/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "encoding.h"

#include <cassert> // assert

static auto
transformer_callback_noop(const sourcemeta::core::Pointer &,
const std::string_view, const std::string_view,
Expand All @@ -25,8 +27,10 @@ auto canonicalize(sourcemeta::core::JSON &schema,
sourcemeta::core::SchemaTransformer canonicalizer;
sourcemeta::core::add(canonicalizer,
sourcemeta::core::AlterSchemaMode::Canonicalizer);
canonicalizer.apply(schema, walker, make_resolver(resolver),
transformer_callback_noop, default_dialect);
[[maybe_unused]] const auto result =
canonicalizer.apply(schema, walker, make_resolver(resolver),
transformer_callback_noop, default_dialect);
assert(result.first);
}

auto make_encoding(sourcemeta::core::JSON &document,
Expand Down Expand Up @@ -83,8 +87,10 @@ auto compile(sourcemeta::core::JSON &schema,
// Numbers
mapper.add<NumberArbitrary>();

mapper.apply(schema, walker, make_resolver(resolver),
transformer_callback_noop, default_dialect);
[[maybe_unused]] const auto mapper_result =
mapper.apply(schema, walker, make_resolver(resolver),
transformer_callback_noop, default_dialect);
assert(mapper_result.first);

// The "any" encoding is always the last resort
const auto dialect{sourcemeta::core::dialect(schema)};
Expand Down
20 changes: 5 additions & 15 deletions test/compiler/2020_12_canonicalizer_any_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_1) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
{ "type": "number" },
{ "type": "string", "minLength": 0 }
]
})JSON");
Expand All @@ -85,7 +85,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_2) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
{ "type": "number" },
{ "type": "string", "minLength": 0 }
]
})JSON");
Expand Down Expand Up @@ -116,7 +116,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_3) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
{ "type": "number" },
{ "type": "string", "minLength": 0 }
]
})JSON");
Expand Down Expand Up @@ -245,12 +245,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, implicit_type_union_1) {
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
})JSON");
Expand Down Expand Up @@ -284,12 +279,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, boolean_schema_1) {
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
})JSON");
Expand Down
1 change: 0 additions & 1 deletion test/compiler/2020_12_canonicalizer_number_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ TEST(JSONBinPack_Canonicalizer_Number_2020_12, drop_non_numeric_keywords_1) {
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
"multipleOf": 1,
"maximum": 4
})JSON");

Expand Down
51 changes: 17 additions & 34 deletions test/compiler/2020_12_canonicalizer_object_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"bar": {
Expand All @@ -40,8 +39,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -75,8 +73,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"bar": {
Expand All @@ -86,8 +83,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -121,8 +117,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"foo": {
Expand All @@ -132,8 +127,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12,
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -231,8 +225,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_1) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"bar": {
Expand All @@ -242,8 +235,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_1) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"baz": {
Expand All @@ -253,8 +245,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_1) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -290,8 +281,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"baz": {
Expand All @@ -301,8 +291,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"foo": {
Expand All @@ -312,8 +301,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"qux": {
Expand All @@ -323,8 +311,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, dependent_required_tautology_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -356,8 +343,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, duplicate_required_values_1) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down Expand Up @@ -389,8 +375,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, duplicate_required_values_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"baz": {
Expand All @@ -400,8 +385,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, duplicate_required_values_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
},
"foo": {
Expand All @@ -411,8 +395,7 @@ TEST(JSONBinPack_Canonicalizer_Object_2020_12, duplicate_required_values_2) {
{ "type": "object", "minProperties": 0, "properties": {} },
{ "type": "array", "minItems": 0 },
{ "type": "string", "minLength": 0 },
{ "type": "number", "multipleOf": 1 },
{ "type": "integer", "multipleOf": 1 }
{ "type": "number" }
]
}
}
Expand Down
7 changes: 1 addition & 6 deletions test/e2e/circleciblank/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/circlecimatrix/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/commitlint/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/commitlintbasic/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/epr/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/eslintrc/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/esmrc/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/geojson/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
7 changes: 1 addition & 6 deletions test/e2e/githubfundingblank/schema-less/canonical.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"minLength": 0
},
{
"type": "number",
"multipleOf": 1
},
{
"type": "integer",
"multipleOf": 1
"type": "number"
}
]
}
Loading