From 9e590625b83fa9509d1b097dae64c3558fc9f883 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Mon, 18 Nov 2024 18:02:14 +0000 Subject: [PATCH] Add tests for :currency (#940) * Add tests for :currency * Apply suggestions from code review * Update test/tests/functions/currency.json --- test/tests/functions/currency.json | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/tests/functions/currency.json diff --git a/test/tests/functions/currency.json b/test/tests/functions/currency.json new file mode 100644 index 000000000..41b79adb8 --- /dev/null +++ b/test/tests/functions/currency.json @@ -0,0 +1,61 @@ +{ + "$schema": "https://raw.githubusercontent.com/unicode-org/message-format-wg/main/test/schemas/v0/tests.schema.json", + "scenario": "Currency function", + "description": "The built-in formatter and selector for currencies.", + "defaultTestProperties": { + "bidiIsolation": "none", + "locale": "en-US" + }, + "tests": [ + { + "src": "{:currency}", + "expErrors": [{ "type": "bad-operand" }] + }, + { + "src": "{foo :currency}", + "expErrors": [{ "type": "bad-operand" }] + }, + { + "src": "{42 :currency}", + "expErrors": [{ "type": "bad-operand" }] + }, + { + "src": ".local $n = {42 :number} {{{$n :currency}}}", + "expErrors": [{ "type": "bad-operand" }] + }, + { + "src": "{42 :currency currency=EUR}", + "expErrors": false + }, + { + "src": ".local $n = {42 :number} {{{$n :currency currency=EUR}}}", + "expErrors": false + }, + { + "src": ".local $n = {42 :integer} {{{$n :currency currency=EUR}}}", + "expErrors": false + }, + { + "src": ".local $n = {42 :currency currency=EUR} {{{$n :currency}}}", + "expErrors": false + }, + { + "src": "{42 :currency currency=EUR fractionDigits=auto}", + "expErrors": false + }, + { + "src": "{42 :currency currency=EUR fractionDigits=2}", + "expErrors": false + }, + { + "src": "{$x :currency currency=EUR}", + "params": [{ "name": "x", "value": 41 }], + "expErrors": false + }, + { + "src": ".local $n = {42 :currency currency=EUR} .match $n * {{other}}", + "exp": "other", + "expErrors": false + } + ] +}