"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const bignumber_js_1 = require("bignumber.js");
const range_1 = require("../range");
function asString(bn) {
    if (bignumber_js_1.BigNumber.isBigNumber(bn))
        return bn.toString();
    if (typeof bn === "object" && bn) {
        const obj = {};
        for (const k in bn) {
            obj[k] = asString(bn[k]);
        }
        return obj;
    }
    return bn;
}
test("inferDynamicRange", () => {
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(0.4)))).toMatchSnapshot();
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(1)))).toMatchSnapshot();
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(1.01)))).toMatchSnapshot();
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(10)))).toMatchSnapshot();
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(100)))).toMatchSnapshot();
    expect(asString((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(99)))).toMatchSnapshot();
});
test("projectRangeIndex", () => {
    expect(asString((0, range_1.projectRangeIndex)((0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(0.4)), 2))).toMatchSnapshot();
});
test("reverseRangeIndex", () => {
    const range = (0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(0.4));
    for (let i = 0; i < range.steps; i++) {
        const n = (0, range_1.projectRangeIndex)(range, i);
        expect((0, range_1.reverseRangeIndex)(range, n)).toBe(i);
    }
});
describe("RangeRaw", () => {
    [0.4, 1, 10, 111, 666, 99999].forEach(v => {
        test("fromRangeRaw(toRangeRaw(x)) is identity for inferred " + v, () => {
            const range = (0, range_1.inferDynamicRange)(new bignumber_js_1.BigNumber(v));
            expect((0, range_1.fromRangeRaw)((0, range_1.toRangeRaw)(range))).toEqual(range);
        });
    });
});
//# sourceMappingURL=range.js.map