]> git.scottworley.com Git - inverse-tax/blob - tax.test.js
6fcc15c74dbc39ad806c7c3961b495360ed7edf1
[inverse-tax] / tax.test.js
1 "use strict";
2
3 var assert = require('assert');
4
5 function test(description, f) {
6 f();
7 }
8
9 test("parse tax table", () => {
10 const parsed = parse_tax_table(' 1 2\n10 4\n');
11 assert.strictEqual(parsed.length, 2);
12 assert.deepStrictEqual(parsed[0], [1, 10, .02]);
13 assert.deepStrictEqual(parsed[1], [10, Infinity, .04]);
14 });
15
16 test("sum", () => {
17 assert.strictEqual(sum([]), 0);
18 assert.strictEqual(sum([7]), 7);
19 assert.strictEqual(sum([100, 1, 10]), 111);
20 });
21
22 test("tax", () => {
23 assert.strictEqual(tax([[10, 100, .01], [100, Infinity, .1]], 150), 5.9);
24 });