Merge pull request #190 from QURIresearch/testing-discipline-one

rescript coverage reports
This commit is contained in:
Ozzie Gooen 2022-04-06 15:39:53 -04:00 committed by GitHub
commit a6b9b03941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 647 additions and 541 deletions

View File

@ -17,3 +17,5 @@ yarn-error.log
*.gen.tsx *.gen.tsx
*.gen.js *.gen.js
dist dist
*.coverage
_coverage

View File

@ -6,7 +6,7 @@ let env: DistributionOperation.env = {
xyPointLength: 100, xyPointLength: 100,
} }
let normalDist: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 5.0, stdev: 2.0})) let normalDist5: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 5.0, stdev: 2.0}))
let normalDist10: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 10.0, stdev: 2.0})) let normalDist10: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 10.0, stdev: 2.0}))
let normalDist20: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 20.0, stdev: 2.0})) let normalDist20: GenericDist_Types.genericDist = Symbolic(#Normal({mean: 20.0, stdev: 2.0}))
let uniformDist: GenericDist_Types.genericDist = Symbolic(#Uniform({low: 9.0, high: 10.0})) let uniformDist: GenericDist_Types.genericDist = Symbolic(#Uniform({low: 9.0, high: 10.0}))
@ -22,14 +22,14 @@ let toExt: option<'a> => 'a = E.O.toExt(
describe("normalize", () => { describe("normalize", () => {
test("has no impact on normal dist", () => { test("has no impact on normal dist", () => {
let result = run(FromDist(ToDist(Normalize), normalDist)) let result = run(FromDist(ToDist(Normalize), normalDist5))
expect(result)->toEqual(Dist(normalDist)) expect(result)->toEqual(Dist(normalDist5))
}) })
}) })
describe("mean", () => { describe("mean", () => {
test("for a normal distribution", () => { test("for a normal distribution", () => {
let result = DistributionOperation.run(~env, FromDist(ToFloat(#Mean), normalDist)) let result = DistributionOperation.run(~env, FromDist(ToFloat(#Mean), normalDist5))
expect(result)->toEqual(Float(5.0)) expect(result)->toEqual(Float(5.0))
}) })
}) })
@ -48,7 +48,7 @@ describe("mixture", () => {
describe("toPointSet", () => { describe("toPointSet", () => {
test("on symbolic normal distribution", () => { test("on symbolic normal distribution", () => {
let result = let result =
run(FromDist(ToDist(ToPointSet), normalDist)) run(FromDist(ToDist(ToPointSet), normalDist5))
->outputMap(FromDist(ToFloat(#Mean))) ->outputMap(FromDist(ToFloat(#Mean)))
->toFloat ->toFloat
->toExt ->toExt
@ -65,7 +65,7 @@ describe("toPointSet", () => {
Skip.test("on sample set", () => { Skip.test("on sample set", () => {
let result = let result =
run(FromDist(ToDist(ToPointSet), normalDist)) run(FromDist(ToDist(ToPointSet), normalDist5))
->outputMap(FromDist(ToDist(ToSampleSet(1000)))) ->outputMap(FromDist(ToDist(ToSampleSet(1000))))
->outputMap(FromDist(ToDist(ToPointSet))) ->outputMap(FromDist(ToDist(ToPointSet)))
->outputMap(FromDist(ToFloat(#Mean))) ->outputMap(FromDist(ToFloat(#Mean)))

View File

@ -1,6 +1,5 @@
{ {
"name": "@quri/squiggle-lang", "name": "@quri/squiggle-lang",
"reason": {},
"sources": [ "sources": [
{ {
"dir": "src/rescript", "dir": "src/rescript",
@ -28,7 +27,8 @@
"bs-dependencies": [ "bs-dependencies": [
"@glennsl/rescript-jest", "@glennsl/rescript-jest",
"@glennsl/bs-json", "@glennsl/bs-json",
"rationale" "rationale",
"bisect_ppx"
], ],
"gentypeconfig": { "gentypeconfig": {
"language": "typescript", "language": "typescript",
@ -43,5 +43,11 @@
"warnings": { "warnings": {
"number": "+A-42-48-9-30-4-102-20-27-41" "number": "+A-42-48-9-30-4-102-20-27-41"
}, },
"ppx-flags": [] "ppx-flags": [
[
"../../node_modules/bisect_ppx/ppx",
"--exclude-files",
".*_Test\\.res$$"
]
]
} }

View File

@ -2,4 +2,7 @@
module.exports = { module.exports = {
preset: 'ts-jest', preset: 'ts-jest',
testEnvironment: 'node', testEnvironment: 'node',
setupFilesAfterEnv: [
"<rootdir>/../../node_modules/bisect_ppx/src/runtime/js/jest.bs.js"
],
}; };

View File

@ -10,6 +10,7 @@
"test:reducer": "jest --testPathPattern '.*__tests__/Reducer.*'", "test:reducer": "jest --testPathPattern '.*__tests__/Reducer.*'",
"test": "jest", "test": "jest",
"test:watch": "jest --watchAll", "test:watch": "jest --watchAll",
"coverage": "rm -f *.coverage; yarn clean; BISECT_ENABLE=yes yarn build; yarn test; ./node_modules/.bin/bisect-ppx-report html",
"all": "yarn build && yarn bundle && yarn test" "all": "yarn build && yarn bundle && yarn test"
}, },
"keywords": [ "keywords": [
@ -24,7 +25,8 @@
"mathjs": "10.4.1", "mathjs": "10.4.1",
"pdfast": "^0.2.0", "pdfast": "^0.2.0",
"rationale": "0.2.0", "rationale": "0.2.0",
"rescript": "^9.1.4" "rescript": "^9.1.4",
"bisect_ppx": "^2.7.1"
}, },
"devDependencies": { "devDependencies": {
"@glennsl/rescript-jest": "^0.9.0", "@glennsl/rescript-jest": "^0.9.0",

1153
yarn.lock

File diff suppressed because it is too large Load Diff