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 70342aaf458e6cb80baeb5b718901075fc42ede6
core https://github.com/sourcemeta/core 514001ace2da9444cfe2382a4134ed4cd773ce73
core https://github.com/sourcemeta/core 1257bcddc2797de7c95dedefebf6c2fb1e00717a
bootstrap https://github.com/twbs/bootstrap 1a6fdfae6be09b09eaced8f0e442ca6f7680a61e
2 changes: 1 addition & 1 deletion cmake/FindCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(NOT Core_FOUND)
set(SOURCEMETA_CORE_JSONL OFF CACHE BOOL "disable JSONL support")
set(SOURCEMETA_CORE_YAML OFF CACHE BOOL "disable YAML support")
set(SOURCEMETA_CORE_CONTRIB_GOOGLETEST ${JSONBINPACK_TESTS} CACHE BOOL "GoogleTest")
set(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK ${JSONBINPACK_BENCHMARK} CACHE BOOL "GoogleBenchmark")
set(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK OFF CACHE BOOL "GoogleBenchmark")
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/core")
include(Sourcemeta)
set(Core_FOUND ON)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inline auto make_resolver(const sourcemeta::core::SchemaResolver &fallback)
return [&fallback](std::string_view identifier)
-> std::optional<sourcemeta::core::JSON> {
if (identifier == ENCODING_V1) {
return sourcemeta::core::parse(R"JSON({
return sourcemeta::core::parse_json(R"JSON({
"$id": "tag:sourcemeta.com,2024:jsonbinpack/encoding/v1",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$vocabulary": {
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/include/sourcemeta/jsonbinpack/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ namespace sourcemeta::jsonbinpack {
///
/// #include <iostream>
///
/// auto schema{sourcemeta::core::parse(R"JSON({
/// auto schema{sourcemeta::core::parse_json(R"JSON({
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "type": "string"
/// })JSON")};
///
/// sourcemeta::jsonbinpack::compile(
/// schema, sourcemeta::core::default_schema_walker,
/// schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
///
/// sourcemeta::core::prettify(schema, std::cout);
Expand All @@ -67,13 +67,13 @@ auto compile(sourcemeta::core::JSON &schema,
///
/// #include <iostream>
///
/// auto schema{sourcemeta::core::parse(R"JSON({
/// auto schema{sourcemeta::core::parse_json(R"JSON({
/// "$schema": "https://json-schema.org/draft/2020-12/schema",
/// "type": "string"
/// })JSON")};
///
/// sourcemeta::jsonbinpack::canonicalize(
/// schema, sourcemeta::core::default_schema_walker,
/// schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
///
/// sourcemeta::core::prettify(schema, std::cout);
Expand Down
126 changes: 63 additions & 63 deletions test/compiler/2020_12_canonicalizer_any_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#include <sourcemeta/jsonbinpack/compiler.h>

TEST(JSONBinPack_Canonicalizer_Any_2020_12, if_without_then_else_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"if": { "minProperties": 2 }
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"minProperties": 0,
Expand All @@ -26,18 +26,18 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, if_without_then_else_1) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, then_else_without_if_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"then": { "minProperties": 2 },
"else": { "minProperties": 3 }
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"minProperties": 0,
Expand All @@ -48,7 +48,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, then_else_without_if_1) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number" },
Expand All @@ -57,11 +57,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_1) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -73,7 +73,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_1) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_2) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number" },
Expand All @@ -82,11 +82,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_2) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -98,7 +98,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_2) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_3) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number" },
Expand All @@ -114,11 +114,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_3) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"allOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -130,7 +130,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_allof_branches_3) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number" },
Expand All @@ -139,11 +139,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_1) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -155,7 +155,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_1) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_2) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number" },
Expand All @@ -164,11 +164,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_2) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -180,7 +180,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_2) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_3) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number" },
Expand All @@ -196,11 +196,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_3) {
]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "type": "number", "multipleOf": 1 },
Expand All @@ -212,16 +212,16 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, duplicate_anyof_branches_3) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "object", "array" ]
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
Expand All @@ -240,17 +240,17 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_1) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_2) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "object", "array" ],
"maxProperties": 3
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
Expand All @@ -270,7 +270,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_2) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_3) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
Expand All @@ -280,11 +280,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_3) {
}
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"minProperties": 0,
Expand All @@ -309,15 +309,15 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, type_union_anyof_3) {
}

TEST(JSONBinPack_Canonicalizer_Any_2020_12, implicit_type_union_1) {
auto schema = sourcemeta::core::parse(R"JSON({
auto schema = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema"
})JSON");

sourcemeta::jsonbinpack::canonicalize(schema,
sourcemeta::core::default_schema_walker,
sourcemeta::core::official_resolver);
sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver);

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{ "enum": [ null ] },
Expand Down Expand Up @@ -353,11 +353,11 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, boolean_schema_1) {
sourcemeta::core::JSON schema{true};

sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::default_schema_walker,
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver,
"https://json-schema.org/draft/2020-12/schema");

const auto expected = sourcemeta::core::parse(R"JSON({
const auto expected = sourcemeta::core::parse_json(R"JSON({
"anyOf": [
{ "enum": [ null ] },
{ "enum": [ false, true ] },
Expand Down Expand Up @@ -392,7 +392,7 @@ TEST(JSONBinPack_Canonicalizer_Any_2020_12, boolean_schema_2) {
sourcemeta::core::JSON schema{false};

sourcemeta::jsonbinpack::canonicalize(
schema, sourcemeta::core::default_schema_walker,
schema, sourcemeta::core::schema_official_walker,
sourcemeta::core::official_resolver,
"https://json-schema.org/draft/2020-12/schema");

Expand Down
Loading