Functional Weave
Code in Python

text.integer-to-words@1.0.0

vectors.json

2,723 bytes · view raw

[
  { "name": "zero is a word, not an empty string", "args": [0], "expect": "zero" },
  { "name": "a single digit", "args": [7], "expect": "seven" },
  { "name": "the teens are their own words", "args": [13], "expect": "thirteen" },
  { "name": "a round ten has no hyphen", "args": [20], "expect": "twenty" },
  { "name": "tens and units are hyphenated", "args": [21], "expect": "twenty-one" },
  { "name": "the largest two-digit number", "args": [99], "expect": "ninety-nine" },
  { "name": "a round hundred has no and", "args": [100], "expect": "one hundred" },
  { "name": "British English puts and after the hundred", "args": [101], "expect": "one hundred and one" },
  { "name": "and before a round ten", "args": [110], "expect": "one hundred and ten" },
  { "name": "the largest three-digit number", "args": [999], "expect": "nine hundred and ninety-nine" },
  { "name": "a round thousand", "args": [1000], "expect": "one thousand" },
  { "name": "and before a final group under a hundred", "args": [1001], "expect": "one thousand and one" },
  { "name": "and before a final round ten", "args": [1010], "expect": "one thousand and ten" },
  { "name": "no and before a final group of a hundred or more", "args": [1100], "expect": "one thousand one hundred" },
  { "name": "the cheque example", "args": [1234], "expect": "one thousand two hundred and thirty-four" },
  { "name": "a hyphenated number of thousands", "args": [21000], "expect": "twenty-one thousand" },
  { "name": "a hundred thousand has no and", "args": [100000], "expect": "one hundred thousand" },
  { "name": "and reaches across empty groups to the final one", "args": [1000001], "expect": "one million and one" },
  { "name": "a middle group does not get an and", "args": [2005000], "expect": "two million five thousand" },
  { "name": "a billion is the short scale, ten to the ninth", "args": [1000000000], "expect": "one billion" },
  { "name": "negative numbers read as minus", "args": [-42], "expect": "minus forty-two" },
  { "name": "the largest supported magnitude", "args": [9007199254740991], "expect": "nine quadrillion seven trillion one hundred and ninety-nine billion two hundred and fifty-four million seven hundred and forty thousand nine hundred and ninety-one" },
  { "name": "the most negative supported value", "args": [-9007199254740991], "expect": "minus nine quadrillion seven trillion one hundred and ninety-nine billion two hundred and fifty-four million seven hundred and forty thousand nine hundred and ninety-one" },
  { "name": "one past the safe integer range is refused", "args": [9007199254740992], "expectError": "out of range" },
  { "name": "a fraction is refused", "args": [1.5], "expectError": "whole number" }
]