{
  "$schema": "../cases.schema.json",
  "format": 1,
  "domain": "currency",
  "title": {
    "en": "Currency (BRL)",
    "pt-BR": "Moeda (real)"
  },
  "functions": [
    {
      "id": "currency.convertToWords",
      "level": "core",
      "summary": "Formats an amount in Brazilian reais as its \"por extenso\" text, the style people use to write out an amount by hand on checks and contracts.",
      "description": "Writes an amount in reais in Brazilian Portuguese words (\"por extenso\"), as on checks and contracts.\n\nFor example, `1523.45` becomes `\"mil quinhentos e vinte e três reais e quarenta e cinco centavos\"`.\n\n- The function truncates `value` (does not round it) to 2 decimal places.\n- Singular and plural agree (\"um real\", \"um centavo\", \"zero reais\"). Every other amount takes the plural (\"dois reais\", \"um milhão e um reais\").\n- The function adds the prefix \"menos\" to a negative amount, except when the amount truncates to nothing: `-0.001` is \"zero reais\".\n- The function takes no options. A round million, billion or trillion of reais takes \"de\" (\"um milhão de reais\"), and the centavos, when there are any, follow (\"um bilhão de reais e cinquenta centavos\").\n- Above about 90 trillion reais (`Number.MAX_SAFE_INTEGER / 100`) a number cannot hold cents, so the amount is read as whole reais. The cents are read off the decimal notation of the value, so floating point noise does not change them (`1.15` is \"um real e quinze centavos\").\n- Pending decision (findings §1b): the reference (JS) writes all lower case with no comma between groups. Several libraries capitalize the first word and some add commas.\n- Pending decision (findings §2 #9): for invalid input or an amount above 999 trillion reais, the reference (JS) returns an empty string.",
      "params": [
        {
          "name": "value",
          "type": "number"
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "currency.convertToWords#zero",
          "args": [
            0
          ],
          "expect": {
            "returns": "zero reais"
          }
        },
        {
          "id": "currency.convertToWords#one-cent",
          "args": [
            0.01
          ],
          "expect": {
            "returns": "um centavo"
          }
        },
        {
          "id": "currency.convertToWords#one-real",
          "args": [
            1
          ],
          "expect": {
            "returns": "um real"
          }
        },
        {
          "id": "currency.convertToWords#one-real-one-cent",
          "args": [
            1.01
          ],
          "expect": {
            "returns": "um real e um centavo"
          }
        },
        {
          "id": "currency.convertToWords#only-cents",
          "args": [
            0.5
          ],
          "expect": {
            "returns": "cinquenta centavos"
          }
        },
        {
          "id": "currency.convertToWords#cem",
          "args": [
            100
          ],
          "expect": {
            "returns": "cem reais"
          }
        },
        {
          "id": "currency.convertToWords#summary-example",
          "args": [
            1523.45
          ],
          "expect": {
            "returns": "mil quinhentos e vinte e três reais e quarenta e cinco centavos"
          }
        },
        {
          "id": "currency.convertToWords#round-million",
          "args": [
            1000000
          ],
          "expect": {
            "returns": "um milhão de reais"
          }
        },
        {
          "id": "currency.convertToWords#round-millions",
          "args": [
            2000000
          ],
          "expect": {
            "returns": "dois milhões de reais"
          }
        },
        {
          "id": "currency.convertToWords#million-and-more",
          "args": [
            1000230
          ],
          "expect": {
            "returns": "um milhão duzentos e trinta reais"
          }
        },
        {
          "id": "currency.convertToWords#negative",
          "args": [
            -5.5
          ],
          "expect": {
            "returns": "menos cinco reais e cinquenta centavos"
          }
        },
        {
          "id": "currency.convertToWords#truncates-sub-cent",
          "args": [
            1.999
          ],
          "expect": {
            "returns": "um real e noventa e nove centavos"
          },
          "note": "the reference truncates (does not round) beyond 2 decimal places; asserted by the reference (JS) unit tests"
        },
        {
          "id": "currency.convertToWords#[-0.01]",
          "args": [
            -0.01
          ],
          "expect": {
            "returns": "menos um centavo"
          },
          "note": "JavaScript's own test: should prefix negative amounts with 'menos'"
        },
        {
          "id": "currency.convertToWords#[-0.001]",
          "args": [
            -0.001
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: zero amounts should not prefix 'menos' when a negative amount truncates to nothing"
        },
        {
          "id": "currency.convertToWords#[-0.009]",
          "args": [
            -0.009
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: zero amounts should not prefix 'menos' when a negative amount truncates to nothing"
        },
        {
          "id": "currency.convertToWords#[0.004]",
          "args": [
            0.004
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: zero amounts should return 'zero reais' for an amount below one centavo"
        },
        {
          "id": "currency.convertToWords#[100000000000000.02]",
          "args": [
            100000000000000.02
          ],
          "expect": {
            "returns": "cem trilhões de reais"
          },
          "note": "JavaScript's own test: amounts too large to carry cents should read an amount above Number.MAX_SAFE_INTEGER cents as whole reais"
        },
        {
          "id": "currency.convertToWords#[90071992547409.9]",
          "args": [
            90071992547409.9
          ],
          "expect": {
            "returns": "noventa trilhões setenta e um bilhões novecentos e noventa e dois milhões quinhentos e quarenta e sete mil quatrocentos e nove reais e noventa centavos"
          },
          "note": "JavaScript's own test: amounts too large to carry cents should still report cents exactly at the Number.MAX_SAFE_INTEGER cents boundary, reading the 90 cents the double holds (90071992547409.9 is exactly 90071992547409.90625, the 91st cent only shows up when 9007199254740990.625 is scaled and rounded to Number.MAX_SAFE_INTEGER)"
        },
        {
          "id": "currency.convertToWords#[0.009999999]",
          "args": [
            0.009999999
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: floating point precision should not carry an amount over a cent boundary while truncating it"
        },
        {
          "id": "currency.convertToWords#[1.999999999]",
          "args": [
            1.999999999
          ],
          "expect": {
            "returns": "um real e noventa e nove centavos"
          },
          "note": "JavaScript's own test: floating point precision should not carry an amount over a cent boundary while truncating it"
        },
        {
          "id": "currency.convertToWords#[1.15]",
          "args": [
            1.15
          ],
          "expect": {
            "returns": "um real e quinze centavos"
          },
          "note": "JavaScript's own test: floating point precision should absorb the noise of scaling a two decimal amount to cents"
        },
        {
          "id": "currency.convertToWords#[0.29]",
          "args": [
            0.29
          ],
          "expect": {
            "returns": "vinte e nove centavos"
          },
          "note": "JavaScript's own test: floating point precision should absorb the noise of scaling a two decimal amount to cents"
        },
        {
          "id": "currency.convertToWords#[19.99]",
          "args": [
            19.99
          ],
          "expect": {
            "returns": "dezenove reais e noventa e nove centavos"
          },
          "note": "JavaScript's own test: floating point precision should absorb the noise of scaling a two decimal amount to cents"
        },
        {
          "id": "currency.convertToWords#[1000000000000.0099]",
          "args": [
            1000000000000.0099
          ],
          "expect": {
            "returns": "um trilhão de reais"
          },
          "note": "JavaScript's own test: floating point precision should not invent a cent for a large amount whose sub cent part scales to a hair below the next integer (1000000000000.0099 * 100 is 100000000000000.98)"
        },
        {
          "id": "currency.convertToWords#[1.5e-7]",
          "args": [
            1.5e-7
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: floating point precision should return 'zero reais' for an amount so small that it is written in exponent notation"
        },
        {
          "id": "currency.convertToWords#[-1.5e-7]",
          "args": [
            -1.5e-7
          ],
          "expect": {
            "returns": "zero reais"
          },
          "note": "JavaScript's own test: floating point precision should return 'zero reais' for an amount so small that it is written in exponent notation"
        },
        {
          "id": "currency.convertToWords#[1000]",
          "args": [
            1000
          ],
          "expect": {
            "returns": "mil reais"
          },
          "note": "JavaScript's own test: letter case should always keep the result lowercase"
        },
        {
          "id": "currency.convertToWords#[1000000000000000]",
          "args": [
            1000000000000000
          ],
          "expect": {
            "returns": ""
          },
          "note": "JavaScript's own test: amounts above 999 trillion reais give an empty string"
        },
        {
          "id": "currency.convertToWords#[999999999999999]",
          "args": [
            999999999999999
          ],
          "expect": {
            "returns": "novecentos e noventa e nove trilhões novecentos e noventa e nove bilhões novecentos e noventa e nove milhões novecentos e noventa e nove mil novecentos e noventa e nove reais"
          },
          "note": "the largest amount accepted, 999 trillion reais"
        },
        {
          "id": "currency.convertToWords#[100000000000000]",
          "args": [
            100000000000000
          ],
          "expect": {
            "returns": "cem trilhões de reais"
          },
          "note": "a round trillion of reais takes de"
        },
        {
          "id": "currency.convertToWords#[1000000000.5]",
          "args": [
            1000000000.5
          ],
          "expect": {
            "returns": "um bilhão de reais e cinquenta centavos"
          },
          "note": "a round billion of reais takes de, and the centavos follow"
        }
      ]
    },
    {
      "id": "currency.format",
      "level": "core",
      "summary": "Formats a value as a currency string in Brazilian real (BRL).",
      "description": "Formats a number in the BRL pattern `1.234,56`.\n\n- A number keeps its sign and its decimals. `options.symbol` (default `false`) prefixes the result with `R$` (`-R$ 1,50` for a negative one). `options.precision` sets the decimal places (default 2, clamped to 0 to 20; a precision that is not a finite number is 2).\n- The function reads a string as `currency.parse` reads it, except that a value without any separator is whole units (`1234` formats as `1.234,00`).\n- A string with no digit reads as 0: `abc` and the empty string format as `0,00`, and `null` also gives `0,00`. A value that is not a finite number (`NaN`, infinite) or cannot be coerced to a number (a symbol, a plain object) returns an empty string. Any other non-string value goes through `Number()`, so `true` formats as `1,00` and `[]` as `0,00`.\n- Pending decision (findings §1b): the reference (JS) adds no currency symbol by default (the `R$ ` prefix is opt-in through `options.symbol`). The other libraries prefix `R$ `.\n- Pending decision (findings §2 #9): for a non-finite or non-numeric value, the reference (JS) returns an empty string. Other libraries return `null`.",
      "params": [
        {
          "name": "value",
          "type": "string | number"
        },
        {
          "name": "options",
          "type": "FormatCurrencyOptions",
          "optional": true
        }
      ],
      "returns": "string",
      "cases": [
        {
          "id": "currency.format#thousands",
          "args": [
            1000.01
          ],
          "expect": {
            "returns": "1.000,01"
          },
          "note": "without options the reference prints no currency symbol (`{ symbol: true }` adds `R$ `); asserted by the reference (JS) unit tests"
        },
        {
          "id": "currency.format#cents",
          "args": [
            0.01
          ],
          "expect": {
            "returns": "0,01"
          }
        },
        {
          "id": "currency.format#integer",
          "args": [
            1
          ],
          "expect": {
            "returns": "1,00"
          }
        },
        {
          "id": "currency.format#millions",
          "args": [
            1000000.01
          ],
          "expect": {
            "returns": "1.000.000,01"
          }
        },
        {
          "id": "currency.format#negative",
          "args": [
            -10.1
          ],
          "expect": {
            "returns": "-10,10"
          }
        },
        {
          "id": "currency.format#string-dot-decimal",
          "args": [
            "1234.56"
          ],
          "expect": {
            "returns": "1.234,56"
          }
        },
        {
          "id": "currency.format#string-brazilian",
          "args": [
            "1.234,56"
          ],
          "expect": {
            "returns": "1.234,56"
          }
        },
        {
          "id": "currency.format#string-with-symbol",
          "args": [
            "R$ 1.234,56"
          ],
          "expect": {
            "returns": "1.234,56"
          }
        },
        {
          "id": "currency.format#[0.1]",
          "args": [
            0.1
          ],
          "expect": {
            "returns": "0,10"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[10]",
          "args": [
            10
          ],
          "expect": {
            "returns": "10,00"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[10.1]",
          "args": [
            10.1
          ],
          "expect": {
            "returns": "10,10"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[10.01]",
          "args": [
            10.01
          ],
          "expect": {
            "returns": "10,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[100.01]",
          "args": [
            100.01
          ],
          "expect": {
            "returns": "100,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[10000.01]",
          "args": [
            10000.01
          ],
          "expect": {
            "returns": "10.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[100000.01]",
          "args": [
            100000.01
          ],
          "expect": {
            "returns": "100.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL"
        },
        {
          "id": "currency.format#[-0.01]",
          "args": [
            -0.01
          ],
          "expect": {
            "returns": "-0,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-0.1]",
          "args": [
            -0.1
          ],
          "expect": {
            "returns": "-0,10"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-1]",
          "args": [
            -1
          ],
          "expect": {
            "returns": "-1,00"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-10]",
          "args": [
            -10
          ],
          "expect": {
            "returns": "-10,00"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-10.01]",
          "args": [
            -10.01
          ],
          "expect": {
            "returns": "-10,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-100.01]",
          "args": [
            -100.01
          ],
          "expect": {
            "returns": "-100,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-1000.01]",
          "args": [
            -1000.01
          ],
          "expect": {
            "returns": "-1.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-10000.01]",
          "args": [
            -10000.01
          ],
          "expect": {
            "returns": "-10.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-100000.01]",
          "args": [
            -100000.01
          ],
          "expect": {
            "returns": "-100.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[-1000000.01]",
          "args": [
            -1000000.01
          ],
          "expect": {
            "returns": "-1.000.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL"
        },
        {
          "id": "currency.format#[0.01,{\"symbol\":true}]",
          "args": [
            0.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 0,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[0.1,{\"symbol\":true}]",
          "args": [
            0.1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 0,10"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[1,{\"symbol\":true}]",
          "args": [
            1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 1,00"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[10,{\"symbol\":true}]",
          "args": [
            10,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 10,00"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[10.1,{\"symbol\":true}]",
          "args": [
            10.1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 10,10"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[10.01,{\"symbol\":true}]",
          "args": [
            10.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 10,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[100.01,{\"symbol\":true}]",
          "args": [
            100.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 100,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[1000.01,{\"symbol\":true}]",
          "args": [
            1000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 1.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[10000.01,{\"symbol\":true}]",
          "args": [
            10000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 10.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[100000.01,{\"symbol\":true}]",
          "args": [
            100000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 100.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[1000000.01,{\"symbol\":true}]",
          "args": [
            1000000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 1.000.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency positive currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-0.01,{\"symbol\":true}]",
          "args": [
            -0.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 0,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-0.1,{\"symbol\":true}]",
          "args": [
            -0.1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 0,10"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-1,{\"symbol\":true}]",
          "args": [
            -1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 1,00"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-10,{\"symbol\":true}]",
          "args": [
            -10,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 10,00"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-10.1,{\"symbol\":true}]",
          "args": [
            -10.1,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 10,10"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-10.01,{\"symbol\":true}]",
          "args": [
            -10.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 10,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-100.01,{\"symbol\":true}]",
          "args": [
            -100.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 100,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-1000.01,{\"symbol\":true}]",
          "args": [
            -1000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 1.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-10000.01,{\"symbol\":true}]",
          "args": [
            -10000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 10.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-100000.01,{\"symbol\":true}]",
          "args": [
            -100000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 100.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[-1000000.01,{\"symbol\":true}]",
          "args": [
            -1000000.01,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 1.000.000,01"
          },
          "note": "JavaScript's own test: should formatCurrency negative currency into BRL with currency sign"
        },
        {
          "id": "currency.format#[0.01,{\"precision\":3}]",
          "args": [
            0.01,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "0,010"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[0.1,{\"precision\":3}]",
          "args": [
            0.1,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "0,100"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[1.1,{\"precision\":3}]",
          "args": [
            1.1,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1,100"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[1.01,{\"precision\":3}]",
          "args": [
            1.01,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1,010"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[1.001,{\"precision\":3}]",
          "args": [
            1.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[10.001,{\"precision\":3}]",
          "args": [
            10.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "10,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[100.001,{\"precision\":3}]",
          "args": [
            100.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "100,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[1000.001,{\"precision\":3}]",
          "args": [
            1000.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1.000,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[10000.001,{\"precision\":3}]",
          "args": [
            10000.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "10.000,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[100000.001,{\"precision\":3}]",
          "args": [
            100000.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "100.000,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[1000000.001,{\"precision\":3}]",
          "args": [
            1000000.001,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1.000.000,001"
          },
          "note": "JavaScript's own test: should formatCurrency with different precision"
        },
        {
          "id": "currency.format#[\"1234,56\"]",
          "args": [
            "1234,56"
          ],
          "expect": {
            "returns": "1.234,56"
          },
          "note": "JavaScript's own test: should read the separators of string inputs"
        },
        {
          "id": "currency.format#[\"1234.56\",{\"precision\":3}]",
          "args": [
            "1234.56",
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "1.234,560"
          },
          "note": "JavaScript's own test: should read the separators of string inputs"
        },
        {
          "id": "currency.format#[\"1.234,5\"]",
          "args": [
            "1.234,5"
          ],
          "expect": {
            "returns": "1.234,50"
          },
          "note": "JavaScript's own test: should read the separators of string inputs"
        },
        {
          "id": "currency.format#[\"R$ 1.234\"]",
          "args": [
            "R$ 1.234"
          ],
          "expect": {
            "returns": "1.234,00"
          },
          "note": "JavaScript's own test: should read the separators of string inputs"
        },
        {
          "id": "currency.format#[\"-10.5\"]",
          "args": [
            "-10.5"
          ],
          "expect": {
            "returns": "-10,50"
          },
          "note": "JavaScript's own test: should preserve the sign of string inputs"
        },
        {
          "id": "currency.format#[\"-1.234,56\"]",
          "args": [
            "-1.234,56"
          ],
          "expect": {
            "returns": "-1.234,56"
          },
          "note": "JavaScript's own test: should preserve the sign of string inputs"
        },
        {
          "id": "currency.format#[\"-R$ 1,00\",{\"symbol\":true}]",
          "args": [
            "-R$ 1,00",
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "-R$ 1,00"
          },
          "note": "JavaScript's own test: should preserve the sign of string inputs"
        },
        {
          "id": "currency.format#[\"\"]",
          "args": [
            ""
          ],
          "expect": {
            "returns": "0,00"
          },
          "note": "JavaScript's own test: should read plain digit strings as whole units"
        },
        {
          "id": "currency.format#[\"0\"]",
          "args": [
            "0"
          ],
          "expect": {
            "returns": "0,00"
          },
          "note": "JavaScript's own test: should read plain digit strings as whole units"
        },
        {
          "id": "currency.format#[\"123456\"]",
          "args": [
            "123456"
          ],
          "expect": {
            "returns": "123.456,00"
          },
          "note": "JavaScript's own test: should read plain digit strings as whole units"
        },
        {
          "id": "currency.format#[\"-1234\"]",
          "args": [
            "-1234"
          ],
          "expect": {
            "returns": "-1.234,00"
          },
          "note": "JavaScript's own test: should read plain digit strings as whole units"
        },
        {
          "id": "currency.format#[1.5,{\"precision\":-1}]",
          "args": [
            1.5,
            {
              "precision": -1
            }
          ],
          "expect": {
            "returns": "2"
          },
          "note": "JavaScript's own test: should clamp the precision to the range accepted by Intl"
        },
        {
          "id": "currency.format#[\"1234,12345\",{\"precision\":5}]",
          "args": [
            "1234,12345",
            {
              "precision": 5
            }
          ],
          "expect": {
            "returns": "1.234,12345"
          },
          "note": "JavaScript's own test: should read as many fraction digits as the requested precision allows, not just the default 2, when reading a string"
        },
        {
          "id": "currency.format#[1234.56,{\"symbol\":true}]",
          "args": [
            1234.56,
            {
              "symbol": true
            }
          ],
          "expect": {
            "returns": "R$ 1.234,56"
          },
          "note": "JavaScript's own test: should replace the non-breaking space"
        },
        {
          "id": "currency.format#[\"abc\"]",
          "args": [
            "abc"
          ],
          "expect": {
            "returns": "0,00"
          },
          "note": "JavaScript's docs: a string with no digit reads as 0, not as an empty string"
        },
        {
          "id": "currency.format#[null]",
          "args": [
            null
          ],
          "expect": {
            "returns": "0,00"
          },
          "note": "JavaScript's docs: null also gives 0,00"
        },
        {
          "id": "currency.format#[-1050]",
          "args": [
            -1050
          ],
          "expect": {
            "returns": "-1.050,00"
          },
          "note": "JavaScript docs example (a number's sign is preserved)"
        },
        {
          "id": "currency.format#[10756.123,{\"precision\":3}]",
          "args": [
            10756.123,
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": "10.756,123"
          },
          "note": "JavaScript docs example"
        }
      ]
    },
    {
      "id": "currency.parse",
      "level": "extended",
      "summary": "Parses a string in Brazilian currency format into a number.",
      "description": "Parses a BRL amount string (such as `R$ 1.234,56`) into a number.\n\n- The last `,` or `.` followed by 1 to 2 digits (up to `options.precision`, when larger) is the decimal separator. Every other `,` or `.` is a thousands separator.\n- The function reads a value without any separator as cents (divided by 10 to the power of the precision, default 2).\n- Only a `-` before the first digit makes the result negative (`-R$ 1,00` is -1). An accounting negative such as `(R$ 1,00)` or a trailing sign as in `1,00-` parses to 1. An empty string is 0.\n- Every character that is not a digit or a separator is dropped, so `1e5` reads as the digits `15` and parses to 0.15.\n- `options.precision` (default 2, clamped to 0 to 20) is the number of digits read as minor units: the divisor for a value without separator and the largest decimal group. A precision that is not a finite number is 2.",
      "params": [
        {
          "name": "value",
          "type": "string"
        },
        {
          "name": "options",
          "type": "ParseCurrencyOptions",
          "optional": true
        }
      ],
      "returns": "number",
      "cases": [
        {
          "id": "currency.parse#with-symbol",
          "args": [
            "R$ 1.234,56"
          ],
          "expect": {
            "returns": 1234.56
          }
        },
        {
          "id": "currency.parse#comma-decimal",
          "args": [
            "1234,56"
          ],
          "expect": {
            "returns": 1234.56
          }
        },
        {
          "id": "currency.parse#cents",
          "args": [
            "R$ 0,50"
          ],
          "expect": {
            "returns": 0.5
          }
        },
        {
          "id": "currency.parse#millions",
          "args": [
            "1.000.000,50"
          ],
          "expect": {
            "returns": 1000000.5
          }
        },
        {
          "id": "currency.parse#negative",
          "args": [
            "-1.234,56"
          ],
          "expect": {
            "returns": -1234.56
          }
        },
        {
          "id": "currency.parse#zero",
          "args": [
            "0,00"
          ],
          "expect": {
            "returns": 0
          }
        },
        {
          "id": "currency.parse#digits-only-read-as-cents",
          "args": [
            "1234"
          ],
          "expect": {
            "returns": 12.34
          },
          "note": "CONTENTIOUS: a value with no separator is read as cents by the reference (asserted by its tests; formatCurrency reads '1234' as whole units)"
        },
        {
          "id": "currency.parse#empty",
          "args": [
            ""
          ],
          "expect": {
            "returns": 0
          },
          "note": "the reference returns 0 for an empty string (asserted by its tests)"
        },
        {
          "id": "currency.parse#[\"0\"]",
          "args": [
            "0"
          ],
          "expect": {
            "returns": 0
          },
          "note": "JavaScript's own test: should return correct values when parsing zero"
        },
        {
          "id": "currency.parse#[\"R$ 10.000,00\"]",
          "args": [
            "R$ 10.000,00"
          ],
          "expect": {
            "returns": 10000
          },
          "note": "JavaScript's own test: should return correct values when parsing large values"
        },
        {
          "id": "currency.parse#[\"R$ 1,00\"]",
          "args": [
            "R$ 1,00"
          ],
          "expect": {
            "returns": 1
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 1,10\"]",
          "args": [
            "R$ 1,10"
          ],
          "expect": {
            "returns": 1.1
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 1,01\"]",
          "args": [
            "R$ 1,01"
          ],
          "expect": {
            "returns": 1.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 10,01\"]",
          "args": [
            "R$ 10,01"
          ],
          "expect": {
            "returns": 10.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 100,01\"]",
          "args": [
            "R$ 100,01"
          ],
          "expect": {
            "returns": 100.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 1.000,01\"]",
          "args": [
            "R$ 1.000,01"
          ],
          "expect": {
            "returns": 1000.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 10.000,01\"]",
          "args": [
            "R$ 10.000,01"
          ],
          "expect": {
            "returns": 10000.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 100.000,01\"]",
          "args": [
            "R$ 100.000,01"
          ],
          "expect": {
            "returns": 100000.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"R$ 1.000.000,01\"]",
          "args": [
            "R$ 1.000.000,01"
          ],
          "expect": {
            "returns": 1000000.01
          },
          "note": "JavaScript's own test: should return 0 should transform a formatted value into a float"
        },
        {
          "id": "currency.parse#[\"-R$ 1,00\"]",
          "args": [
            "-R$ 1,00"
          ],
          "expect": {
            "returns": -1
          },
          "note": "JavaScript's own test: should preserve the sign when the value is negative"
        },
        {
          "id": "currency.parse#[\"R$ -0,50\"]",
          "args": [
            "R$ -0,50"
          ],
          "expect": {
            "returns": -0.5
          },
          "note": "JavaScript's own test: should preserve the sign when the value is negative"
        },
        {
          "id": "currency.parse#[\"R$ 1.234,5\"]",
          "args": [
            "R$ 1.234,5"
          ],
          "expect": {
            "returns": 1234.5
          },
          "note": "JavaScript's own test: should read the separators when the fraction is shorter than the precision"
        },
        {
          "id": "currency.parse#[\"R$ 1.234.5\"]",
          "args": [
            "R$ 1.234.5"
          ],
          "expect": {
            "returns": 1234.5
          },
          "note": "JavaScript's own test: should read the separators when the fraction is shorter than the precision"
        },
        {
          "id": "currency.parse#[\"1234.56\"]",
          "args": [
            "1234.56"
          ],
          "expect": {
            "returns": 1234.56
          },
          "note": "JavaScript's own test: should read the separators when the separator is a dot"
        },
        {
          "id": "currency.parse#[\"12.34\"]",
          "args": [
            "12.34"
          ],
          "expect": {
            "returns": 12.34
          },
          "note": "JavaScript's own test: should read the separators when the separator is a dot"
        },
        {
          "id": "currency.parse#[\"R$ 1.234\"]",
          "args": [
            "R$ 1.234"
          ],
          "expect": {
            "returns": 1234
          },
          "note": "JavaScript's own test: should read the separators when there is only a thousands separator"
        },
        {
          "id": "currency.parse#[\"R$ 1.000.000\"]",
          "args": [
            "R$ 1.000.000"
          ],
          "expect": {
            "returns": 1000000
          },
          "note": "JavaScript's own test: should read the separators when there is only a thousands separator"
        },
        {
          "id": "currency.parse#[\"1,5\"]",
          "args": [
            "1,5"
          ],
          "expect": {
            "returns": 1.5
          },
          "note": "JavaScript's own test: should read the separators when there is only a thousands separator"
        },
        {
          "id": "currency.parse#[\"1.059\"]",
          "args": [
            "1.059"
          ],
          "expect": {
            "returns": 1059
          },
          "note": "JavaScript's own test: should read the separators when there is only a thousands separator"
        },
        {
          "id": "currency.parse#[\"R$ 50\"]",
          "args": [
            "R$ 50"
          ],
          "expect": {
            "returns": 0.5
          },
          "note": "JavaScript's own test: should keep the cents convention for plain digit strings when there is no separator at all"
        },
        {
          "id": "currency.parse#[\"1234\",{\"precision\":0}]",
          "args": [
            "1234",
            {
              "precision": 0
            }
          ],
          "expect": {
            "returns": 1234
          },
          "note": "JavaScript's own test: should keep the cents convention for plain digit strings when there is no separator at all"
        },
        {
          "id": "currency.parse#[\"1,001\",{\"precision\":3}]",
          "args": [
            "1,001",
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": 1.001
          },
          "note": "JavaScript's own test: should honor the precision option when precision is 3"
        },
        {
          "id": "currency.parse#[\"R$ 1.000,001\",{\"precision\":3}]",
          "args": [
            "R$ 1.000,001",
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": 1000.001
          },
          "note": "JavaScript's own test: should honor the precision option when precision is 3"
        },
        {
          "id": "currency.parse#[\"R$ 1,50\",{\"precision\":-1}]",
          "args": [
            "R$ 1,50",
            {
              "precision": -1
            }
          ],
          "expect": {
            "returns": 1.5
          },
          "note": "JavaScript's own test: should honor the precision option when the precision is out of range"
        },
        {
          "id": "currency.parse#[\"R$ 150\",{\"precision\":-1}]",
          "args": [
            "R$ 150",
            {
              "precision": -1
            }
          ],
          "expect": {
            "returns": 150
          },
          "note": "JavaScript's own test: should honor the precision option when the precision is out of range"
        },
        {
          "id": "currency.parse#[\"(R$ 1,00)\"]",
          "args": [
            "(R$ 1,00)"
          ],
          "expect": {
            "returns": 1
          },
          "note": "JavaScript docs: only a leading - makes the value negative; an accounting negative parses to 1"
        },
        {
          "id": "currency.parse#[\"1,00-\"]",
          "args": [
            "1,00-"
          ],
          "expect": {
            "returns": 1
          },
          "note": "only a leading - makes the value negative; a trailing sign is dropped"
        },
        {
          "id": "currency.parse#[\"1e5\"]",
          "args": [
            "1e5"
          ],
          "expect": {
            "returns": 0.15
          },
          "note": "characters that are not digits or separators are dropped, so 1e5 reads as 15 cents"
        },
        {
          "id": "currency.parse#[\"R$ 1,001\",{\"precision\":3}]",
          "args": [
            "R$ 1,001",
            {
              "precision": 3
            }
          ],
          "expect": {
            "returns": 1.001
          },
          "note": "JavaScript docs example"
        }
      ]
    }
  ]
}
