Name Date Size #Lines LOC

..--

README.mdH A D25-Apr-20253.1 KiB4232

data-model-errors.jsonH A D25-Apr-20251.2 KiB3332

syntax-errors.jsonH A D25-Apr-20251.5 KiB5756

test-core.jsonH A D25-Apr-20254.9 KiB213212

test-core.json.d.tsH A D25-Apr-20251,004 2612

test-functions.jsonH A D25-Apr-20258.9 KiB323322

test-functions.json.d.tsH A D25-Apr-2025270 93

README.md

1# Test Data for CLDR MessageFormat 2.0 Tech Preview
2
3For information about MessageFormat 2.0, see [Unicode Locale Data Markup Language (LDML): Part 9: Message Format](../../../docs/ldml/tr35-messageFormat.md)
4
5The files in this directory were originally copied from the [messageformat project](https://github.com/messageformat/messageformat/tree/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/__fixtures)
6and are here relicensed by their original author (Eemeli Aro) under the Unicode License.
7
8These test files are intended to be useful for testing multiple different message processors in different ways:
9
10- `syntax-errors.json` — An array of strings that should produce a Syntax Error when parsed.
11
12- `data-model-errors.json` - An object with string keys and arrays of strings as values,
13     where each key is the name of an error and its value is an array of strings that
14     should produce `error` when processed.
15     Error names are defined in ["MessageFormat 2.0 Errors"](../../../docs/ldml/tr35-messageFormat.md#errors) in the spec.
16
17- `test-core.json` — An array of test cases that do not depend on any registry definitions.
18  Each test may include some of the following fields:
19  - `src: string` (required) — The MF2 syntax source.
20  - `exp: string` (required) — The expected result of formatting the message to a string.
21  - `locale: string` — The locale to use for formatting. Defaults to 'en-US'.
22  - `params: Record<string, string | number | null | undefined>` — Parameters to pass in to the formatter for resolving external variables.
23  - `parts: object[]` — The expected result of formatting the message to parts.
24  - `cleanSrc: string` — A normalixed form of `src`, for testing stringifiers.
25  - `errors: { type: string }[]` — The runtime errors expected to be emitted when formatting the message.
26     If `errors` is either absent or empty, the message must be formatted without errors.
27  - `only: boolean` — Normally not set. A flag to use during development to only run one or more specific tests.
28
29- `test-function.json` — An object with string keys and arrays of test cases as values,
30  using the same definition as for `test-core.json`.
31  The keys each correspond to a function that is used in the tests.
32  Since the behavior of built-in formatters is implementation-specific,
33  the `exp` field should generally be omitted,
34  except for error cases.
35
36TypeScript `.d.ts` files are included for `test-core.json` and `test-function.json` with the above definition.
37
38Some examples of test harnesses using these tests, from the source repository:
39- [CST parse/stringify tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/cst/cst.test.ts)
40- [Data model stringify tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/data-model/stringify.test.ts)
41- [Formatting tests](https://github.com/messageformat/messageformat/blob/11c95dab2b25db8454e49ff4daadb817e1d5b770/packages/mf2-messageformat/src/messageformat.test.ts)
42