Test data format
Every algorithm’s test data is one JSON file in the same shape, with fields named by the same rules. Read this once and every file reads the same way. algorithms.json lists every file.
The file
| Property | Holds |
|---|---|
algorithm | The algorithm's slug, as in its page's address: wmm |
placeholder | Only while the values are made up, saying so. Never test against a file that has it. |
publishedDate | When a case last changed |
expiresDate | Only when the data behind it runs out, like a magnetic model's last day |
licence | Only when the file isn't CC0: its licence, and the credit it asks for |
earthModel | The earth the numbers are on: WGS84, or a sphere and its radius |
sources | Where the values come from: each with role, name, by, url and licence |
operations | What can be computed: each with an id, what it gives, and the names of its inputs and outputs |
fields | Every input and output name, with what it means and its range |
tolerances | How close each numeric output must be, and how near a border a list of labels may differ |
cases | The tests: each with an id, an operation, tags, an optional note saying why it exists, an input and what's expected |
The file has no version. It changes in place, and an implementation is always checked against the current file. publishedDate moves when a case’s input or expected values change; a new note doesn’t move it.
The file is written to be read: indented two spaces, with its properties in the order above and each case’s as id, operation, tags, note, input, expected. A named case has a note; its algorithm’s page lists those as its edge cases. Cases at random points don’t.
Naming
A field’s name says what it is and, for a number, its unit. The same name means the same thing in every file.
| Kind | Rule | Like |
|---|---|---|
| Every name | lowerCamelCase English words. No abbreviations but established ones. | eastingInMeters |
| A number with a unit | Ends in In and the unit, spelled out | distanceInMeters, deltaTInSeconds, precisionInDigits |
| A number without a unit | Named for what it is | julianDay, decimalYear, illuminationFraction, pointScale |
| An instant | Ends in Utc. ISO 8601 in UTC with a Z, to the second, in decimal digits only. Years −9999 to 9999; a year of more digits is outOfRange. | riseUtc "2026-06-21T12:04:00Z" |
| A calendar date | Is or ends in date. YYYY-MM-DD. | publishedDate, date |
| Text for a person | Ends in Text | bearingText "000°" |
| A choice | A lowerCamelCase word from the list in the field's meaning | hemisphere "north", phaseName "waxingCrescent" |
| Yes or no | Starts with is or has | isAlwaysUp |
| A list | Named for what it holds, plural. An input's list holds objects whose fields follow these rules. An output's list holds labels, like zone names, in any order; every other output is a single value. | constituents, timeZoneNames |
| A pair of places or bearings | Starts with from and to | fromLatitudeInDegrees |
| Angles | Degrees, except where a field says hours. East and north positive; bearings clockwise from north, 0 up to 360. An answer that would round to 360 is 0. | rightAscensionInHours |
| A number that isn't finite | JSON can't write one, so an input in a refusal case may be the string "NaN", "Infinity" or "-Infinity" | "bearingInDegrees": "NaN" |
| Operations | lowerCamelCase, a verb or the thing given | toMgrs, events |
| Case ids | kebab-case, starting with where the case came from | noaa-3, edge-svalbard-33x |
null means the thing doesn’t exist, like a sunrise on a day without one. It never means unknown.
An input whose field says it’s optional may be left out of a case, and then takes the value the field gives, like a star’s proper motion of 0. An input never says null.
Comparing
- Only the fields in
expectedare compared. An implementation may return more. - A number passes when it’s within its tolerance: absolute, in the field’s own unit, written as a decimal string. An instant’s tolerance is in seconds.
- Everything else is compared exactly: text, choices, whole numbers,
true,falseandnull. - A list of labels is compared as a set: the same labels, in any order. An empty list is right only where the expected one is empty.
- Near a border, a label may go either way. A lookup’s polygons are simplified, so close to an edge it can’t always agree with the source. A case there has
nearbyinexpected: every label whose polygon’s edge is within 1 km of the point, including those it’s in, each with the distance to that edge, like{ "timeZoneName": "America/Moncton", "distanceInMeters": 15.2 }. The list’s tolerance is in metres. A labelnearbyputs within it may be in the answer or not; every other label must be as expected.nearbyisn’t an output, and nothing returns it. - A tolerance is never loosened to make an implementation pass. If one is wrong, the file changes.
Cases
Each case’s tags say where its values came from and what it tests.
| Tag | Means |
|---|---|
published | The authority's own published value |
reference | Output of the reference program, kept with the file |
hand | Worked out from a definition, like a compass point's name |
edge | A named edge case |
polar | Near a pole |
invalid | Input that must be refused |
A case expecting refusal has "expected": { "error": "outOfRange" }. The errors are outOfRange, for input outside a field’s range, and invalidInput, for input that can’t be read.
Bad input is always refused, never answered: NaN or infinity anywhere, an instant outside its years, a value outside its field’s range. An implementation never crashes on it and never makes up an answer. Some bad input can’t be written in a file, like a date the language itself marks invalid; the implementation refuses it all the same, as outOfRange.
Implementations
An implementation is a repo that follows one contract, so it can be checked the same way in any language. The code isn’t public yet; algorithms-swift is the worked example.
-
mise installsets up its tools. -
mise run evaluatereads cases on standard input, one JSON object per line, and writes one result per line in any order. It never seesexpected. It runs once per algorithm, and answersnotImplementedfor an algorithm it doesn’t have.in: {"algorithm":"wmm","id":"noaa-table-1","operation":"field","input":{"latitudeInDegrees":80,…}} out: {"id":"noaa-table-1","output":{"magneticDeclinationInDegrees":1.28,…}} out: {"id":"invalid-after-2030","error":"outOfRange"} out: {"id":"utm-1","error":"notImplemented"}It hands every input to the algorithm as it is, with
"NaN","Infinity"and"-Infinity"read as numbers. It refuses only what the language’s types can’t hold, like a choice not on the list in a language with enums, so a refusal case tests the algorithm, not the harness.
Each implementation’s CI grades it with this site’s checker, which feeds every published file to mise run evaluate and judges each answer. Placeholder files are skipped. It runs on every push to the implementation’s main, and again whenever the test data or the checker changes, and commits the results here. The home page shows each one’s latest results, with the commit graded and the compiler that built it.
An algorithm with every case passing passes. One with a failing case fails. One with any notImplemented case is incomplete. A result against an older publishedDate counts as incomplete until the next check.