@@ -1880,6 +1880,200 @@ TEST(Evaluator_2020_12, unevaluatedItems_4_exhaustive) {
18801880 " described by related keywords" );
18811881}
18821882
1883+ TEST (Evaluator_2020_12, unevaluatedItems_5) {
1884+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
1885+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1886+ "contains": { "type": "boolean" },
1887+ "unevaluatedItems": { "type": "number" }
1888+ })JSON" )};
1889+
1890+ const sourcemeta::core::JSON instance{
1891+ sourcemeta::core::parse_json (" [ true, 1, false, 2 ]" )};
1892+
1893+ EVALUATE_WITH_TRACE_FAST_SUCCESS (schema, instance, 10 );
1894+
1895+ EVALUATE_TRACE_PRE (0 , LoopContains, " /contains" , " #/contains" , " " );
1896+ EVALUATE_TRACE_PRE (1 , AssertionTypeStrict, " /contains/type" ,
1897+ " #/contains/type" , " /0" );
1898+
1899+ // TODO: Avoid emitting these additional confusing evaluation traces
1900+ EVALUATE_TRACE_PRE (2 , ControlEvaluate, " /contains" , " #/contains" , " /0" );
1901+
1902+ EVALUATE_TRACE_PRE (3 , AssertionTypeStrict, " /contains/type" ,
1903+ " #/contains/type" , " /1" );
1904+ EVALUATE_TRACE_PRE (4 , AssertionTypeStrict, " /contains/type" ,
1905+ " #/contains/type" , " /2" );
1906+
1907+ // TODO: Avoid emitting these additional confusing evaluation traces
1908+ EVALUATE_TRACE_PRE (5 , ControlEvaluate, " /contains" , " #/contains" , " /2" );
1909+
1910+ EVALUATE_TRACE_PRE (6 , AssertionTypeStrict, " /contains/type" ,
1911+ " #/contains/type" , " /3" );
1912+ EVALUATE_TRACE_PRE (7 , LoopItemsUnevaluated, " /unevaluatedItems" ,
1913+ " #/unevaluatedItems" , " " );
1914+ EVALUATE_TRACE_PRE (8 , AssertionTypeStrictAny, " /unevaluatedItems/type" ,
1915+ " #/unevaluatedItems/type" , " /1" );
1916+ EVALUATE_TRACE_PRE (9 , AssertionTypeStrictAny, " /unevaluatedItems/type" ,
1917+ " #/unevaluatedItems/type" , " /3" );
1918+
1919+ EVALUATE_TRACE_POST_SUCCESS (0 , AssertionTypeStrict, " /contains/type" ,
1920+ " #/contains/type" , " /0" );
1921+ EVALUATE_TRACE_POST_SUCCESS (1 , ControlEvaluate, " /contains" , " #/contains" ,
1922+ " /0" );
1923+ EVALUATE_TRACE_POST_FAILURE (2 , AssertionTypeStrict, " /contains/type" ,
1924+ " #/contains/type" , " /1" );
1925+ EVALUATE_TRACE_POST_SUCCESS (3 , AssertionTypeStrict, " /contains/type" ,
1926+ " #/contains/type" , " /2" );
1927+ EVALUATE_TRACE_POST_SUCCESS (4 , ControlEvaluate, " /contains" , " #/contains" ,
1928+ " /2" );
1929+ EVALUATE_TRACE_POST_FAILURE (5 , AssertionTypeStrict, " /contains/type" ,
1930+ " #/contains/type" , " /3" );
1931+ EVALUATE_TRACE_POST_SUCCESS (6 , LoopContains, " /contains" , " #/contains" , " " );
1932+ EVALUATE_TRACE_POST_SUCCESS (7 , AssertionTypeStrictAny,
1933+ " /unevaluatedItems/type" ,
1934+ " #/unevaluatedItems/type" , " /1" );
1935+ EVALUATE_TRACE_POST_SUCCESS (8 , AssertionTypeStrictAny,
1936+ " /unevaluatedItems/type" ,
1937+ " #/unevaluatedItems/type" , " /3" );
1938+ EVALUATE_TRACE_POST_SUCCESS (9 , LoopItemsUnevaluated, " /unevaluatedItems" ,
1939+ " #/unevaluatedItems" , " " );
1940+
1941+ EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
1942+ " The value was expected to be of type boolean" );
1943+ EVALUATE_TRACE_POST_DESCRIBE (instance, 1 ,
1944+ " The instance location was marked as evaluated" );
1945+ EVALUATE_TRACE_POST_DESCRIBE (instance, 2 ,
1946+ " The value was expected to be of type boolean "
1947+ " but it was of type integer" );
1948+ EVALUATE_TRACE_POST_DESCRIBE (instance, 3 ,
1949+ " The value was expected to be of type boolean" );
1950+ EVALUATE_TRACE_POST_DESCRIBE (instance, 4 ,
1951+ " The instance location was marked as evaluated" );
1952+ EVALUATE_TRACE_POST_DESCRIBE (instance, 5 ,
1953+ " The value was expected to be of type boolean "
1954+ " but it was of type integer" );
1955+ EVALUATE_TRACE_POST_DESCRIBE (
1956+ instance, 6 ,
1957+ " The array value was expected to contain at least 1 item that validates "
1958+ " against the given subschema" );
1959+ EVALUATE_TRACE_POST_DESCRIBE (instance, 7 ,
1960+ " The value was expected to be of type number" );
1961+ EVALUATE_TRACE_POST_DESCRIBE (instance, 8 ,
1962+ " The value was expected to be of type number" );
1963+ EVALUATE_TRACE_POST_DESCRIBE (
1964+ instance, 9 ,
1965+ " The array items not covered by other array keywords, if any, were "
1966+ " expected to validate against this subschema" );
1967+ }
1968+
1969+ TEST (Evaluator_2020_12, unevaluatedItems_5_exhaustive) {
1970+ const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
1971+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1972+ "contains": { "type": "boolean" },
1973+ "unevaluatedItems": { "type": "number" }
1974+ })JSON" )};
1975+
1976+ const sourcemeta::core::JSON instance{
1977+ sourcemeta::core::parse_json (" [ true, 1, false, 2 ]" )};
1978+
1979+ EVALUATE_WITH_TRACE_EXHAUSTIVE_SUCCESS (schema, instance, 14 );
1980+
1981+ EVALUATE_TRACE_PRE (0 , LoopContains, " /contains" , " #/contains" , " " );
1982+ EVALUATE_TRACE_PRE (1 , AssertionTypeStrict, " /contains/type" ,
1983+ " #/contains/type" , " /0" );
1984+ EVALUATE_TRACE_PRE_ANNOTATION (2 , " /contains" , " #/contains" , " " );
1985+ EVALUATE_TRACE_PRE (3 , ControlEvaluate, " /contains" , " #/contains" , " /0" );
1986+ EVALUATE_TRACE_PRE (4 , AssertionTypeStrict, " /contains/type" ,
1987+ " #/contains/type" , " /1" );
1988+ EVALUATE_TRACE_PRE (5 , AssertionTypeStrict, " /contains/type" ,
1989+ " #/contains/type" , " /2" );
1990+ EVALUATE_TRACE_PRE_ANNOTATION (6 , " /contains" , " #/contains" , " " );
1991+ EVALUATE_TRACE_PRE (7 , ControlEvaluate, " /contains" , " #/contains" , " /2" );
1992+ EVALUATE_TRACE_PRE (8 , AssertionTypeStrict, " /contains/type" ,
1993+ " #/contains/type" , " /3" );
1994+ EVALUATE_TRACE_PRE (9 , LoopItemsUnevaluated, " /unevaluatedItems" ,
1995+ " #/unevaluatedItems" , " " );
1996+ EVALUATE_TRACE_PRE (10 , AssertionTypeStrictAny, " /unevaluatedItems/type" ,
1997+ " #/unevaluatedItems/type" , " /1" );
1998+ EVALUATE_TRACE_PRE (11 , AnnotationToParent, " /unevaluatedItems" ,
1999+ " #/unevaluatedItems" , " " );
2000+ EVALUATE_TRACE_PRE (12 , AssertionTypeStrictAny, " /unevaluatedItems/type" ,
2001+ " #/unevaluatedItems/type" , " /3" );
2002+ EVALUATE_TRACE_PRE (13 , AnnotationToParent, " /unevaluatedItems" ,
2003+ " #/unevaluatedItems" , " " );
2004+
2005+ EVALUATE_TRACE_POST_SUCCESS (0 , AssertionTypeStrict, " /contains/type" ,
2006+ " #/contains/type" , " /0" );
2007+ EVALUATE_TRACE_POST_ANNOTATION (1 , " /contains" , " #/contains" , " " , 0 );
2008+ EVALUATE_TRACE_POST_SUCCESS (2 , ControlEvaluate, " /contains" , " #/contains" ,
2009+ " /0" );
2010+ EVALUATE_TRACE_POST_FAILURE (3 , AssertionTypeStrict, " /contains/type" ,
2011+ " #/contains/type" , " /1" );
2012+ EVALUATE_TRACE_POST_SUCCESS (4 , AssertionTypeStrict, " /contains/type" ,
2013+ " #/contains/type" , " /2" );
2014+ EVALUATE_TRACE_POST_ANNOTATION (5 , " /contains" , " #/contains" , " " , 2 );
2015+ EVALUATE_TRACE_POST_SUCCESS (6 , ControlEvaluate, " /contains" , " #/contains" ,
2016+ " /2" );
2017+ EVALUATE_TRACE_POST_FAILURE (7 , AssertionTypeStrict, " /contains/type" ,
2018+ " #/contains/type" , " /3" );
2019+ EVALUATE_TRACE_POST_SUCCESS (8 , LoopContains, " /contains" , " #/contains" , " " );
2020+ EVALUATE_TRACE_POST_SUCCESS (9 , AssertionTypeStrictAny,
2021+ " /unevaluatedItems/type" ,
2022+ " #/unevaluatedItems/type" , " /1" );
2023+ EVALUATE_TRACE_POST_ANNOTATION (10 , " /unevaluatedItems" , " #/unevaluatedItems" ,
2024+ " " , true );
2025+ EVALUATE_TRACE_POST_SUCCESS (11 , AssertionTypeStrictAny,
2026+ " /unevaluatedItems/type" ,
2027+ " #/unevaluatedItems/type" , " /3" );
2028+ EVALUATE_TRACE_POST_ANNOTATION (12 , " /unevaluatedItems" , " #/unevaluatedItems" ,
2029+ " " , true );
2030+ EVALUATE_TRACE_POST_SUCCESS (13 , LoopItemsUnevaluated, " /unevaluatedItems" ,
2031+ " #/unevaluatedItems" , " " );
2032+
2033+ EVALUATE_TRACE_POST_DESCRIBE (instance, 0 ,
2034+ " The value was expected to be of type boolean" );
2035+ EVALUATE_TRACE_POST_DESCRIBE (
2036+ instance, 1 ,
2037+ " The item at index 0 of the array value successfully validated against "
2038+ " the containment check subschema" );
2039+ EVALUATE_TRACE_POST_DESCRIBE (instance, 2 ,
2040+ " The instance location was marked as evaluated" );
2041+ EVALUATE_TRACE_POST_DESCRIBE (instance, 3 ,
2042+ " The value was expected to be of type boolean "
2043+ " but it was of type integer" );
2044+ EVALUATE_TRACE_POST_DESCRIBE (instance, 4 ,
2045+ " The value was expected to be of type boolean" );
2046+ EVALUATE_TRACE_POST_DESCRIBE (
2047+ instance, 5 ,
2048+ " The item at index 2 of the array value successfully validated against "
2049+ " the containment check subschema" );
2050+ EVALUATE_TRACE_POST_DESCRIBE (instance, 6 ,
2051+ " The instance location was marked as evaluated" );
2052+ EVALUATE_TRACE_POST_DESCRIBE (instance, 7 ,
2053+ " The value was expected to be of type boolean "
2054+ " but it was of type integer" );
2055+ EVALUATE_TRACE_POST_DESCRIBE (
2056+ instance, 8 ,
2057+ " The array value was expected to contain at least 1 item that validates "
2058+ " against the given subschema" );
2059+ EVALUATE_TRACE_POST_DESCRIBE (instance, 9 ,
2060+ " The value was expected to be of type number" );
2061+ EVALUATE_TRACE_POST_DESCRIBE (
2062+ instance, 10 ,
2063+ " At least one item of the array value successfully validated against the "
2064+ " subschema for unevaluated items" );
2065+ EVALUATE_TRACE_POST_DESCRIBE (instance, 11 ,
2066+ " The value was expected to be of type number" );
2067+ EVALUATE_TRACE_POST_DESCRIBE (
2068+ instance, 12 ,
2069+ " At least one item of the array value successfully validated against the "
2070+ " subschema for unevaluated items" );
2071+ EVALUATE_TRACE_POST_DESCRIBE (
2072+ instance, 13 ,
2073+ " The array items not covered by other array keywords, if any, were "
2074+ " expected to validate against this subschema" );
2075+ }
2076+
18832077TEST (Evaluator_2020_12, unevaluatedProperties_1) {
18842078 const sourcemeta::core::JSON schema{sourcemeta::core::parse_json (R"JSON( {
18852079 "$schema": "https://json-schema.org/draft/2020-12/schema",
0 commit comments