2022-04-20 00:52:53 +00:00
|
|
|
import {
|
|
|
|
run,
|
|
|
|
squiggleExpression,
|
|
|
|
errorValue,
|
|
|
|
result,
|
|
|
|
} from "../../src/js/index";
|
2022-04-20 03:42:24 +00:00
|
|
|
import { testRun } from "./TestHelpers";
|
2022-04-20 00:52:53 +00:00
|
|
|
import * as fc from "fast-check";
|
|
|
|
|
2022-04-20 22:48:04 +00:00
|
|
|
describe("Squiggle's parser is whitespace insensitive", () => {
|
2022-04-20 00:52:53 +00:00
|
|
|
test("when assigning a distribution to a name and calling that name", () => {
|
|
|
|
/*
|
|
|
|
* intersperse varying amounts of whitespace in a squiggle string
|
|
|
|
*/
|
|
|
|
let squiggleString = (
|
|
|
|
a: string,
|
|
|
|
b: string,
|
|
|
|
c: string,
|
|
|
|
d: string,
|
|
|
|
e: string,
|
|
|
|
f: string,
|
|
|
|
g: string,
|
|
|
|
h: string
|
|
|
|
): string => {
|
|
|
|
return `theDist${a}=${b}beta(${c}4${d},${e}5e1)${f};${g}theDist${h}`;
|
|
|
|
};
|
|
|
|
let squiggleOutput = testRun(
|
|
|
|
squiggleString("", "", "", "", "", "", "", "")
|
|
|
|
);
|
2022-04-20 22:48:04 +00:00
|
|
|
|
|
|
|
// Add "\n" to this when multiline is introduced.
|
2022-04-20 00:52:53 +00:00
|
|
|
let whitespaceGen = () => {
|
|
|
|
return fc.constantFrom("", " ", "\t", " ", " ", " ", " ");
|
|
|
|
};
|
|
|
|
|
|
|
|
fc.assert(
|
|
|
|
fc.property(
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
whitespaceGen(),
|
|
|
|
(a, b, c, d, e, f, g, h) => {
|
|
|
|
expect(testRun(squiggleString(a, b, c, d, e, f, g, h))).toEqual(
|
|
|
|
squiggleOutput
|
|
|
|
);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|