@openpronoun/conformance
v0.0.1
Published
Shared parsing/formatting fixtures for the OpenPronoun specification.
Readme
@openpronoun/conformance
Language-agnostic conformance fixtures for the
OpenPronoun Specification: the shared parsing and
formatting test cases. The canonical schema lives in
@openpronoun/schema; fixtures here validate against it. Because the
fixtures are plain JSON, the reference TypeScript library and any community port
(Python, Java, Go, …) validate against the exact same expectations.
Contents
packages/conformance/
├── package.json
├── README.md
├── parsing.json # input string -> expected PronounPreference
└── formatting.json # PronounPreference (+ options) -> expected display stringThe schema these validate against is published separately as
@openpronoun/schema.
Fixture format
Each fixture file is a JSON object:
{
"kind": "parsing" | "formatting",
"description": "...",
"cases": [ /* ... */ ]
}Parsing case — expected is a PronounPreference that validates against the
@openpronoun/schema schema. An expected of null means "no preference" (the
field is absent), which is distinct from the special none preference.
{
"category": "single-set",
"name": "single set, capitalized input",
"input": "She/Her",
"expected": [ { "subjective": "she", "objective": "her", "...": "..." } ]
}Formatting case — options.form is one of short, expanded, or detailed.
options.audience (e.g. "public") drives privacy behavior: sets with
privacy >= 1 are omitted from a public audience.
{
"name": "single set, short",
"input": [ { "subjective": "she", "...": "..." } ],
"options": { "form": "short" },
"expected": "She/Her"
}Conformance
- Parser-conformant implementations must, for every case in
parsing.json, produce output deep-equal toexpected. - Display-conformant implementations must, for every case in
formatting.json, produce a string equal toexpected.
See Conformance for the full requirement list.
Minimal runner (Node.js)
A reference parser/formatter exposing parse(input) and
format(preference, options) can be checked against the fixtures with roughly:
import assert from "node:assert";
import { readFileSync } from "node:fs";
import { parse, format } from "@openpronoun/core"; // your implementation
const parsing = JSON.parse(readFileSync(
new URL("./parsing.json", import.meta.url), "utf8"));
for (const c of parsing.cases) {
assert.deepStrictEqual(parse(c.input), c.expected, c.name);
}
const formatting = JSON.parse(readFileSync(
new URL("./formatting.json", import.meta.url), "utf8"));
for (const c of formatting.cases) {
assert.strictEqual(format(c.input, c.options), c.expected, c.name);
}
console.log("All conformance fixtures passed.");Note: the
expectedvalues encode the spec's recommended canonical forms (e.g. capitalizedShe/Hershort display,No pronouns (use name)for thenonepreference). Where the spec leaves a choice to the implementation, the fixtures pick one canonical convention so results are comparable across ports.
