Update spec tests to current version from message-format-wg
- Update parser for changed name-start grammar rule
- Validate number literals in :number implementation (since parser no longer does this)
- Disallow `:number`/`:integer` select option set from variable
See https://github.com/unicode-org/message-format-wg/pull/1016
As part of this, un-skip tests where the `bad-option` error is
expected, and implement validating digit size options
(pending PR https://github.com/unicode-org/icu/pull/2973 is intended
to do this more fully)
This updates the MF2 spec tests to 943479b602 with the following exceptions:
- functions/currency.json and functions/math.json are omitted because these are not yet implemented
- bidi.json will be handled in a future PR
- u-options.json will be handled in a future PR
Changes include:
* `:integer` now returns a value encapsulating the rounded numeric value of the argument, rather than
the value itself.
* Fallbacks are handled according to the current spec.
* Fallback values are not passed into functions.
* Characters inside literal fallbacks are properly escaped.
* The test runner skips null values properly.
* The test runner handles boolean `expErrors` in defaultTestProperties.
* `:string` normalizes its input and normalizeNFC() has been refactored so it can be called there.
Implement :test:format, :test:select, and :test:function, which are
required by the new `pattern-selection.json` tests.
Change the internal value representation in the formatter in order to
support some of the test cases (binding the results of selectors to a
variable).
Matching PR #883 in the message-format-wg repo.
Also move spec tests for unsupported statements and expressions into new files
to serve as syntax error tests.
Add MessageFormatter::Builder::setErrorHandlingBehavior() method
and a new enum type MessageFormatter::UMFErrorHandlingBehavior
to denote strict or best-effort behavior.
The reason for adding a single method that takes an enum is to allow
for the possibility of more error handling modes in the future.
Co-authored-by: Markus Scherer <markus.icu@gmail.com>
The implementation was keeping a cache of FormatterFactory
objects so that subsequent calls to the same formatter re-use the
same object.
The problem is that this is unsafe, because
`MFFunctionRegistry::getFormatter()` returns a non-const `FormatterFactory*`;
so if the caller deleted the resulting pointer, the formatter cache
would contain a dangling pointer.
This optimization was added because of an ICU4J test that checked for
the presence of the optimization. However, for separate reasons
(making `adoptFormatter()` actually adopt its argument), this test
was already removed.
The caching could be re-added later if that optimization is needed,
but for now, remove it (also, no tests were checking for its presence).