squiggle/packages/squiggle-lang/__tests__/TS/Symbolic_test.ts

22 lines
722 B
TypeScript
Raw Permalink Normal View History

2022-04-20 03:42:24 +00:00
import { testRun } from "./TestHelpers";
import * as fc from "fast-check";
describe("Symbolic mean", () => {
test("mean(triangular(x,y,z))", () => {
fc.assert(
fc.property(fc.integer(), fc.integer(), fc.integer(), (x, y, z) => {
if (!(x < y && y < z)) {
2022-04-20 22:48:04 +00:00
try {
let squiggleResult = testRun(`mean(triangular(${x},${y},${z}))`);
expect(squiggleResult.value).toBeCloseTo((x + y + z) / 3);
} catch (err) {
expect((err as Error).message).toEqual(
"Expected squiggle expression to evaluate but got error: Distribution Math Error: Triangular values must be increasing order."
2022-04-20 22:48:04 +00:00
);
}
}
})
);
});
});