From c94a70b93ac98f9ad05245c51d69b8d160aa2ea0 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sat, 9 Apr 2022 21:56:05 -0400 Subject: [PATCH] Fixed tests --- packages/squiggle-lang/__tests__/JS__Test.ts | 3 ++- packages/squiggle-lang/src/js/index.ts | 5 +++++ .../rescript/Distributions/SampleSetDist/SampleSetDist.res | 4 +++- packages/squiggle-lang/src/rescript/TypescriptInterface.res | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/squiggle-lang/__tests__/JS__Test.ts b/packages/squiggle-lang/__tests__/JS__Test.ts index ba2f91f4..8e5961a3 100644 --- a/packages/squiggle-lang/__tests__/JS__Test.ts +++ b/packages/squiggle-lang/__tests__/JS__Test.ts @@ -1,4 +1,4 @@ -import { run, GenericDist, resultMap } from "../src/js/index"; +import { run, GenericDist, resultMap, makeSampleSetDist } from "../src/js/index"; let testRun = (x: string) => { let result = run(x); @@ -41,6 +41,7 @@ describe("Multimodal too many weights error", () => { describe("GenericDist", () => { //It's important that sampleCount is less than 9. If it's more, than that will create randomness + //Also, note, the value should be created using makeSampleSetDist() later on. let env = { sampleCount: 8, xyPointLength: 100 }; let dist = new GenericDist( { tag: "SampleSet", value: [3, 4, 5, 6, 6, 7, 10, 15, 30] }, diff --git a/packages/squiggle-lang/src/js/index.ts b/packages/squiggle-lang/src/js/index.ts index 1f67e369..4892c2f3 100644 --- a/packages/squiggle-lang/src/js/index.ts +++ b/packages/squiggle-lang/src/js/index.ts @@ -14,6 +14,7 @@ import { resultFloat, resultString, } from "../rescript/TypescriptInterface.gen"; +export {makeSampleSetDist} from "../rescript/TypescriptInterface.gen"; import { Constructors_mean, Constructors_sample, @@ -79,6 +80,10 @@ export function resultMap(r: result, mapFn: any): result { } } +export function resultExn(r: result): any { + r.value +} + export class GenericDist { t: genericDist; env: env; diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res index f8dfd84a..fcd4055d 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist.res @@ -4,8 +4,10 @@ this constructor. https://stackoverflow.com/questions/66909578/how-to-make-a-type-constructor-private-in-rescript-except-in-current-module */ module T: { + //This really should be hidden (remove the array). The reason it isn't is to act as an escape hatch in JS__Test.ts. + //When we get a good functional library in TS, we could refactor that out. @genType - type t + type t = array let make: array => result let get: t => array } = { diff --git a/packages/squiggle-lang/src/rescript/TypescriptInterface.res b/packages/squiggle-lang/src/rescript/TypescriptInterface.res index fb30ea24..6fe6f3d4 100644 --- a/packages/squiggle-lang/src/rescript/TypescriptInterface.res +++ b/packages/squiggle-lang/src/rescript/TypescriptInterface.res @@ -22,3 +22,6 @@ type resultDist = result type resultFloat = result @genType type resultString = result + +@genType +let makeSampleSetDist = SampleSetDist.make \ No newline at end of file