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

23 lines
776 B
TypeScript

import { errorValueToString } from "../../src/js/index";
import { testRun } from "./TestHelpers";
import * as fc from "fast-check";
describe("Symbolic mean", () => {
test("mean(triangular(x,y,z))", () => {
fc.assert(
fc.property(fc.double(), fc.double(), fc.double(), (x, y, z) => {
if (!(x < y && y < z)) {
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."
);
}
}
})
);
});
});