Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 2.01 KB

readme.md

File metadata and controls

48 lines (39 loc) · 2.01 KB

Jsontron conformance suite

These files are the executable form of the specification. Every implementation in this repository runs all of them; an implementation conforms when all pass.

Format

Each *.json file (except schema.json, which describes the format) is an array of groups:

[
  {
    "description": "report fails when the test is truthy",
    "schema": { "report": { "test": ".total < 0", "message": "negative total" } },
    "tests": [
      { "description": "positive total", "data": { "total": 5 }, "valid": true },
      { "description": "negative total", "data": { "total": -1 }, "valid": false,
        "errors": [ "negative total" ] }
    ]
  },
  { "description": "invalid jq in assert", "schema": { "assert": ".a |" }, "buildError": true }
]
  • schema is a JSON Schema (draft 2020-12) using the Jsontron keywords.
  • A group with buildError: true passes when compiling the schema fails.
  • Otherwise the schema must compile, and for each test data must validate as valid says.
  • errors, when present, is the list of failure texts of the Jsontron keywords (rules, assert, report) for that instance. A runner collects the messages of the validation errors those keywords raised, at any schema location, and compares the two lists sorted: the order in which a host visits schema locations is not part of the contract. Errors of standard keywords are ignored.
  • A test that is invalid without errors checks validity only: the failure comes from an evaluation error, whose text is not normative, or from a standard keyword.

Running

Implementation Command
.NET dnx --yes retest at the repository root
JavaScript npm test in js/
Python pytest in python/

Adding cases

Add the group to the file of its area, or a new file: runners pick up every *.json here. A case must follow from the specification; when it shows the specification is silent or ambiguous, change the specification in the same commit.