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

23 lines
773 B
TypeScript
Raw Normal View History

2022-04-20 04:50:46 +00:00
import { errorValueToString } from "../../src/js/index";
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.float(), fc.float(), fc.float(), (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
);
}
}
})
);
});
});