factored into TestHelpers.ts file

This commit is contained in:
Quinn Dougherty 2022-04-19 23:42:24 -04:00
parent 1395a36c63
commit 4f5a1ff946
10 changed files with 30 additions and 53 deletions

View File

@ -81,6 +81,7 @@ jobs:
run: yarn coverage:rescript:ci run: yarn coverage:rescript:ci
- name: Upload typescript coverage report - name: Upload typescript coverage report
run: yarn coverage:ts:ci run: yarn coverage:ts:ci
components-lint: components-lint:
name: Components lint name: Components lint
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -20,3 +20,4 @@ dist
*.coverage *.coverage
_coverage _coverage
coverage coverage
.nyc_output/

View File

@ -1,19 +1,6 @@
import { import { errorValueToString } from "../../src/js/index";
run,
Distribution,
squiggleExpression,
errorValueToString,
errorValue,
result,
} from "../../src/js/index";
import * as fc from "fast-check"; import * as fc from "fast-check";
import { testRun } from "./TestHelpers";
let testRun = (x: string): any => {
//result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 1000, xyPointLength: 100 });
};
let failDefault = () => expect("codepath should never").toBe("be reached");
describe("Jstat: cumulative density function", () => { describe("Jstat: cumulative density function", () => {
test("of a normal distribution at 3 stdevs to the right of the mean is within epsilon of 1", () => { test("of a normal distribution at 3 stdevs to the right of the mean is within epsilon of 1", () => {

View File

@ -4,12 +4,9 @@ import {
errorValue, errorValue,
result, result,
} from "../../src/js/index"; } from "../../src/js/index";
import { testRun } from "./TestHelpers";
import * as fc from "fast-check"; import * as fc from "fast-check";
let testRun = (x: string): result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 1000, xyPointLength: 100 });
};
describe("Squiggle is whitespace insensitive", () => { describe("Squiggle is whitespace insensitive", () => {
test("when assigning a distribution to a name and calling that name", () => { test("when assigning a distribution to a name and calling that name", () => {
/* /*

View File

@ -1,19 +1,6 @@
import { import { Distribution } from "../../src/js/index";
run,
Distribution,
squiggleExpression,
errorValueToString,
errorValue,
result,
} from "../../src/js/index";
import * as fc from "fast-check"; import * as fc from "fast-check";
let testRun = (x: string): result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 1000, xyPointLength: 100 });
};
let failDefault = () => expect("codepath should never").toBe("be reached");
// Beware: float64Array makes it appear in an infinite loop. // Beware: float64Array makes it appear in an infinite loop.
let arrayGen = () => let arrayGen = () =>
fc.float32Array({ fc.float32Array({

View File

@ -1,18 +1,7 @@
import { import { errorValueToString } from "../../src/js/index";
run, import { testRun } from "./TestHelpers";
Distribution,
resultMap,
squiggleExpression,
errorValueToString,
errorValue,
result,
} from "../../src/js/index";
import * as fc from "fast-check"; import * as fc from "fast-check";
let testRun = (x: string): result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 100, xyPointLength: 100 });
};
describe("Scalar manipulation is well-modeled by javascript math", () => { describe("Scalar manipulation is well-modeled by javascript math", () => {
test("in the case of logarithms (with assignment)", () => { test("in the case of logarithms (with assignment)", () => {
fc.assert( fc.assert(

View File

@ -5,12 +5,9 @@ import {
errorValue, errorValue,
result, result,
} from "../../src/js/index"; } from "../../src/js/index";
import { testRun } from "./TestHelpers";
import * as fc from "fast-check"; import * as fc from "fast-check";
let testRun = (x: string): result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 100, xyPointLength: 100 });
};
describe("Symbolic mean", () => { describe("Symbolic mean", () => {
let triangularInputError = { let triangularInputError = {
tag: "Error", tag: "Error",

View File

@ -0,0 +1,17 @@
import {
run,
Distribution,
squiggleExpression,
errorValueToString,
errorValue,
result,
} from "../../src/js/index";
export function testRun(x: string): any {
//: result<squiggleExpression, errorValue> => {
return run(x, { sampleCount: 1000, xyPointLength: 100 });
}
export function failDefault() {
expect("be reached").toBe("codepath should never be");
}

View File

@ -9,5 +9,6 @@ module.exports = {
".*Fixtures.bs.js", ".*Fixtures.bs.js",
"/node_modules/", "/node_modules/",
".*Helpers.bs.js", ".*Helpers.bs.js",
".*Helpers.ts",
], ],
}; };

View File

@ -14,9 +14,9 @@
"test:reducer": "jest __tests__/Reducer*/", "test:reducer": "jest __tests__/Reducer*/",
"test:watch": "jest --watchAll", "test:watch": "jest --watchAll",
"coverage:rescript": "rm -f *.coverage; yarn clean; BISECT_ENABLE=yes yarn build; yarn test:rescript; bisect-ppx-report html", "coverage:rescript": "rm -f *.coverage; yarn clean; BISECT_ENABLE=yes yarn build; yarn test:rescript; bisect-ppx-report html",
"coverage:ts": "nyc yarn test:ts", "coverage:ts": "nyc --reporter=lcov yarn test:ts",
"coverage:rescript:ci": "yarn clean; BISECT_ENABLE=yes yarn build; yarn test; bisect-ppx-report send-to Codecov", "coverage:rescript:ci": "yarn clean; BISECT_ENABLE=yes yarn build; yarn test:rescript; bisect-ppx-report send-to Codecov",
"coverage:ts:ci": "nyc --reporter=lcov yarn test:ts && codecov", "coverage:ts:ci": "yarn coverage:ts && codecov",
"lint:rescript": "./lint.sh", "lint:rescript": "./lint.sh",
"lint:prettier": "prettier --check .", "lint:prettier": "prettier --check .",
"lint": "yarn lint:rescript && yarn lint:prettier", "lint": "yarn lint:rescript && yarn lint:prettier",