@@ -1440,6 +1440,105 @@ TEST(Evaluator_2020_12, dynamicRef_1) {
14401440 " The value was expected to be of type string" );
14411441}
14421442
1443+ TEST (Evaluator_2020_12, dynamicRef_2) {
1444+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
1445+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1446+ "$dynamicRef": "https://example.com/target#meta",
1447+ "$defs": {
1448+ "target": {
1449+ "$id": "https://example.com/target",
1450+ "$dynamicAnchor": "meta",
1451+ "type": "boolean"
1452+ },
1453+ "other": {
1454+ "$id": "https://example.com/other",
1455+ "$dynamicAnchor": "meta",
1456+ "type": "number"
1457+ }
1458+ }
1459+ })JSON" )};
1460+
1461+ const sourcemeta::core::JSON instance{true };
1462+ EVALUATE_WITH_TRACE_FAST_SUCCESS (schema, instance, 4 );
1463+
1464+ EVALUATE_TRACE_PRE (0 , ControlMark, " " , " https://example.com/other" , " " );
1465+ EVALUATE_TRACE_PRE (1 , ControlMark, " " , " https://example.com/target" , " " );
1466+ EVALUATE_TRACE_PRE (2 , ControlDynamicAnchorJump, " /$dynamicRef" ,
1467+ " #/$dynamicRef" , " " );
1468+ EVALUATE_TRACE_PRE (3 , AssertionTypeStrict, " /$dynamicRef/type" ,
1469+ " https://example.com/target#/type" , " " );
1470+
1471+ EVALUATE_TRACE_POST_SUCCESS (0 , ControlMark, " " , " https://example.com/other" ,
1472+ " " );
1473+ EVALUATE_TRACE_POST_SUCCESS (1 , ControlMark, " " , " https://example.com/target" ,
1474+ " " );
1475+ EVALUATE_TRACE_POST_SUCCESS (2 , AssertionTypeStrict, " /$dynamicRef/type" ,
1476+ " https://example.com/target#/type" , " " );
1477+ EVALUATE_TRACE_POST_SUCCESS (3 , ControlDynamicAnchorJump, " /$dynamicRef" ,
1478+ " #/$dynamicRef" , " " );
1479+
1480+ EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
1481+ " The schema location was marked for future use" );
1482+ EVALUATE_TRACE_POST_DESCRIBE (instance, 1 ,
1483+ " The schema location was marked for future use" );
1484+ EVALUATE_TRACE_POST_DESCRIBE (instance, 2 ,
1485+ " The value was expected to be of type boolean" );
1486+ EVALUATE_TRACE_POST_DESCRIBE (
1487+ instance, 3 ,
1488+ " The boolean value was expected to validate against the first subschema "
1489+ " in scope that declared the dynamic anchor \" meta\" " );
1490+ }
1491+
1492+ TEST (Evaluator_2020_12, dynamicRef_3) {
1493+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
1494+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1495+ "$dynamicRef": "https://example.com/target#meta",
1496+ "$defs": {
1497+ "target": {
1498+ "$id": "https://example.com/target",
1499+ "$dynamicAnchor": "meta",
1500+ "type": "boolean"
1501+ },
1502+ "other": {
1503+ "$id": "https://example.com/other",
1504+ "$dynamicAnchor": "meta",
1505+ "type": "number"
1506+ }
1507+ }
1508+ })JSON" )};
1509+
1510+ const sourcemeta::core::JSON instance{1 };
1511+ EVALUATE_WITH_TRACE_FAST_FAILURE (schema, instance, 4 );
1512+
1513+ EVALUATE_TRACE_PRE (0 , ControlMark, " " , " https://example.com/other" , " " );
1514+ EVALUATE_TRACE_PRE (1 , ControlMark, " " , " https://example.com/target" , " " );
1515+ EVALUATE_TRACE_PRE (2 , ControlDynamicAnchorJump, " /$dynamicRef" ,
1516+ " #/$dynamicRef" , " " );
1517+ EVALUATE_TRACE_PRE (3 , AssertionTypeStrict, " /$dynamicRef/type" ,
1518+ " https://example.com/target#/type" , " " );
1519+
1520+ EVALUATE_TRACE_POST_SUCCESS (0 , ControlMark, " " , " https://example.com/other" ,
1521+ " " );
1522+ EVALUATE_TRACE_POST_SUCCESS (1 , ControlMark, " " , " https://example.com/target" ,
1523+ " " );
1524+ EVALUATE_TRACE_POST_FAILURE (2 , AssertionTypeStrict, " /$dynamicRef/type" ,
1525+ " https://example.com/target#/type" , " " );
1526+ EVALUATE_TRACE_POST_FAILURE (3 , ControlDynamicAnchorJump, " /$dynamicRef" ,
1527+ " #/$dynamicRef" , " " );
1528+
1529+ EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
1530+ " The schema location was marked for future use" );
1531+ EVALUATE_TRACE_POST_DESCRIBE (instance, 1 ,
1532+ " The schema location was marked for future use" );
1533+ EVALUATE_TRACE_POST_DESCRIBE (instance, 2 ,
1534+ " The value was expected to be of type boolean "
1535+ " but it was of type integer" );
1536+ EVALUATE_TRACE_POST_DESCRIBE (
1537+ instance, 3 ,
1538+ " The integer value was expected to validate against the first subschema "
1539+ " in scope that declared the dynamic anchor \" meta\" " );
1540+ }
1541+
14431542TEST (Evaluator_2020_12, definitions_1) {
14441543 const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
14451544 "$schema": "https://json-schema.org/draft/2020-12/schema",
0 commit comments