[ {"fn": "convertRate", "name": "12.5 percent is 1250 basis points", "args": ["12.5", "percent", "basis-points"], "expect": "1250"}, {"fn": "convertRate", "name": "1250 basis points is 12.5 percent", "args": ["1250", "basis-points", "percent"], "expect": "12.5"}, {"fn": "convertRate", "name": "a ratio of 0.125 is 12.5 percent", "args": ["0.125", "ratio", "percent"], "expect": "12.5"}, {"fn": "convertRate", "name": "20 percent is a ratio of 0.2", "args": ["20", "percent", "ratio"], "expect": "0.2"}, {"fn": "convertRate", "name": "one basis point is a ratio of 0.0001", "args": ["1", "basis-points", "ratio"], "expect": "0.0001"}, {"fn": "convertRate", "name": "half a basis point as a ratio needs leading zeros", "args": ["0.5", "basis-points", "ratio"], "expect": "0.00005"}, {"fn": "convertRate", "name": "0.07 as a ratio is exactly 7 percent, not 7.000000000000001", "args": ["0.07", "ratio", "percent"], "expect": "7"}, {"fn": "convertRate", "name": "a negative rate keeps its sign", "args": ["-2.75", "percent", "basis-points"], "expect": "-275"}, {"fn": "convertRate", "name": "same unit gives the canonical form", "args": ["007.500", "percent", "percent"], "expect": "7.5"}, {"fn": "convertRate", "name": "zero with trailing zeros is plain zero", "args": ["0.00", "ratio", "basis-points"], "expect": "0"}, {"fn": "convertRate", "name": "negative zero is zero", "args": ["-0.0", "percent", "ratio"], "expect": "0"}, {"fn": "convertRate", "name": "a ratio of one is 10000 basis points", "args": ["1", "ratio", "basis-points"], "expect": "10000"}, {"fn": "convertRate", "name": "numbers beyond any float or integer convert exactly", "args": ["123456789012345678901.23", "percent", "basis-points"], "expect": "12345678901234567890123"}, {"fn": "convertRate", "name": "a percent sign is not part of the number", "args": ["12.5%", "percent", "basis-points"], "expectError": "is not a decimal number"}, {"fn": "convertRate", "name": "exponent notation is refused", "args": ["1e3", "basis-points", "percent"], "expectError": "is not a decimal number"}, {"fn": "convertRate", "name": "a bare leading point is refused", "args": [".5", "percent", "ratio"], "expectError": "is not a decimal number"}, {"fn": "convertRate", "name": "a decimal comma is refused", "args": ["1,5", "percent", "ratio"], "expectError": "is not a decimal number"}, {"fn": "convertRate", "name": "an empty string is refused", "args": ["", "percent", "ratio"], "expectError": "is not a decimal number"}, {"fn": "convertRate", "name": "an unknown unit is an error", "args": ["5", "permille", "percent"], "expectError": "unknown rate unit"}, {"fn": "toBasisPoints", "name": "20 percent is 2000 basis points", "args": ["20", "percent"], "expect": 2000}, {"fn": "toBasisPoints", "name": "12.5 percent is 1250 basis points", "args": ["12.5", "percent"], "expect": 1250}, {"fn": "toBasisPoints", "name": "a ratio of 0.0525 is 525 basis points", "args": ["0.0525", "ratio"], "expect": 525}, {"fn": "toBasisPoints", "name": "basis points given as basis points, trailing zeros allowed", "args": ["75.000", "basis-points"], "expect": 75}, {"fn": "toBasisPoints", "name": "a negative rate keeps its sign", "args": ["-0.75", "percent"], "expect": -75}, {"fn": "toBasisPoints", "name": "zero percent is zero", "args": ["0.00", "percent"], "expect": 0}, {"fn": "toBasisPoints", "name": "negative zero is zero", "args": ["-0", "ratio"], "expect": 0}, {"fn": "toBasisPoints", "name": "the largest safe number of basis points", "args": ["9007199254740991", "basis-points"], "expect": 9007199254740991}, {"fn": "toBasisPoints", "name": "12.345 percent is 1234.5 basis points, which no integer holds", "args": ["12.345", "percent"], "expectError": "is not a whole number of basis points"}, {"fn": "toBasisPoints", "name": "a ratio finer than a basis point is refused, not rounded", "args": ["0.00001", "ratio"], "expectError": "is not a whole number of basis points"}, {"fn": "toBasisPoints", "name": "one past 2^53 - 1 basis points is too large", "args": ["9007199254740992", "basis-points"], "expectError": "too large for integer basis points"}, {"fn": "toBasisPoints", "name": "a percent sign is not part of the number", "args": ["20%", "percent"], "expectError": "is not a decimal number"}, {"fn": "toBasisPoints", "name": "an unknown unit is an error", "args": ["5", "permille"], "expectError": "unknown rate unit"}, {"fn": "fromBasisPoints", "name": "2000 basis points is 20 percent", "args": [2000, "percent"], "expect": "20"}, {"fn": "fromBasisPoints", "name": "1250 basis points is 12.5 percent", "args": [1250, "percent"], "expect": "12.5"}, {"fn": "fromBasisPoints", "name": "1250 basis points is a ratio of 0.125", "args": [1250, "ratio"], "expect": "0.125"}, {"fn": "fromBasisPoints", "name": "one basis point is 0.01 percent", "args": [1, "percent"], "expect": "0.01"}, {"fn": "fromBasisPoints", "name": "one basis point is a ratio of 0.0001", "args": [1, "ratio"], "expect": "0.0001"}, {"fn": "fromBasisPoints", "name": "basis points to basis points is the same number", "args": [-40, "basis-points"], "expect": "-40"}, {"fn": "fromBasisPoints", "name": "a negative rate keeps its sign", "args": [-275, "percent"], "expect": "-2.75"}, {"fn": "fromBasisPoints", "name": "zero is plain zero", "args": [0, "ratio"], "expect": "0"}, {"fn": "fromBasisPoints", "name": "10000 basis points is a ratio of exactly one", "args": [10000, "ratio"], "expect": "1"}, {"fn": "fromBasisPoints", "name": "the largest safe number of basis points as a ratio", "args": [9007199254740991, "ratio"], "expect": "900719925474.0991"}, {"fn": "fromBasisPoints", "name": "2^53 basis points is outside the safe range", "args": [9007199254740992, "percent"], "expectError": "outside the safe integer range"}, {"fn": "fromBasisPoints", "name": "a fractional number of basis points is refused", "args": [12.5, "percent"], "expectError": "must be an integer"}, {"fn": "fromBasisPoints", "name": "an unknown unit is an error", "args": [100, "permille"], "expectError": "unknown rate unit"} ]