squiggle/__tests__/CDFunctor__Test.re

60 lines
1.5 KiB
ReasonML
Raw Normal View History

2020-02-21 13:17:32 +00:00
open Jest;
open Expect;
2020-02-21 13:39:55 +00:00
exception ShapeWrong(string);
2020-02-21 13:17:32 +00:00
describe("CDF", () => {
2020-02-21 13:39:55 +00:00
test("raise - w/o order", () => {
expect(() => {
module CDF =
CDFunctor.Make({
2020-02-25 05:20:11 +00:00
let shape: DistTypes.xyShape = {
2020-02-21 13:39:55 +00:00
xs: [|10., 4., 8.|],
ys: [|8., 9., 2.|],
};
});
();
})
|> toThrow
});
test("raise - with order", () => {
expect(() => {
module CDF =
CDFunctor.Make({
2020-02-25 05:20:11 +00:00
let shape: DistTypes.xyShape = {
2020-02-21 13:39:55 +00:00
xs: [|1., 4., 8.|],
ys: [|8., 9., 2.|],
};
});
();
})
|> not_
|> toThrow
});
2020-02-21 13:21:43 +00:00
test("order#1", () => {
let a = CDFunctor.order({xs: [|1., 4., 8.|], ys: [|8., 9., 2.|]});
2020-02-25 05:20:11 +00:00
let b: DistTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|8., 9., 2.|]};
2020-02-21 13:21:43 +00:00
expect(a) |> toEqual(b);
});
test("order#2", () => {
let a = CDFunctor.order({xs: [|10., 5., 12.|], ys: [|8., 9., 2.|]});
2020-02-25 05:20:11 +00:00
let b: DistTypes.xyShape = {xs: [|5., 10., 12.|], ys: [|9., 8., 2.|]};
2020-02-21 13:21:43 +00:00
expect(a) |> toEqual(b);
2020-02-21 13:17:32 +00:00
});
2020-02-21 13:50:23 +00:00
test("minX", () => {
module CDF =
CDFunctor.Make({
2020-02-25 05:20:11 +00:00
let shape: DistTypes.xyShape =
2020-02-21 13:50:23 +00:00
CDFunctor.order({xs: [|20., 4., 8.|], ys: [|8., 9., 2.|]});
});
expect(CDF.minX()) |> toEqual(4.);
});
test("maxX", () => {
module CDF =
CDFunctor.Make({
2020-02-25 05:20:11 +00:00
let shape: DistTypes.xyShape =
2020-02-21 13:50:23 +00:00
CDFunctor.order({xs: [|20., 4., 8.|], ys: [|8., 9., 2.|]});
});
expect(CDF.maxX()) |> toEqual(20.);
});
2020-02-21 13:17:32 +00:00
});