Rename assertOk to toExn
This commit is contained in:
parent
9fb7148290
commit
98bf4f81c7
|
@ -46,7 +46,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
->expect
|
||||
->toBe(Some(2.5e1))
|
||||
})
|
||||
|
@ -60,7 +60,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -77,7 +77,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(DistributionTypes.Constructors.UsingDists.mean)
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -158,7 +158,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -173,7 +173,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.pdf(d, 1e1))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -249,7 +249,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -264,7 +264,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.cdf(d, 1e1))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -341,7 +341,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
@ -356,7 +356,7 @@ describe("(Algebraic) addition of distributions", () => {
|
|||
->E.R2.fmap(d => DistributionTypes.Constructors.UsingDists.inv(d, 2e-2))
|
||||
->E.R2.fmap(run)
|
||||
->E.R2.fmap(toFloat)
|
||||
->E.R.toExn
|
||||
->E.R.toExn("Expected float", _)
|
||||
switch received {
|
||||
| None => "algebraicAdd has"->expect->toBe("failed")
|
||||
// This is nondeterministic, we could be in a situation where ci fails but you click rerun and it passes, which is bad.
|
||||
|
|
|
@ -50,7 +50,7 @@ module Internals = {
|
|||
let dist1 = dist1'->DistributionTypes.Symbolic
|
||||
let dist2 = dist2'->DistributionTypes.Symbolic
|
||||
let received =
|
||||
distOp(dist1, dist2)->E.R2.fmap(mean)->E.R2.fmap(run)->E.R2.fmap(toFloat)->E.R.toExn
|
||||
distOp(dist1, dist2)->E.R2.fmap(mean)->E.R2.fmap(run)->E.R2.fmap(toFloat)->E.R.toExn("Expected float", _)
|
||||
let expected = floatOp(runMean(dist1), runMean(dist2))
|
||||
switch received {
|
||||
| None => expectImpossiblePath(description)
|
||||
|
@ -82,12 +82,12 @@ describe("Means are invariant", () => {
|
|||
let testAdditionMean = testOperationMean(algebraicAdd, "algebraicAdd", \"+.", ~epsilon)
|
||||
|
||||
testAll("with two of the same distribution", distributions, dist => {
|
||||
E.R.liftM2(testAdditionMean, dist, dist)->E.R.toExn
|
||||
E.R.liftM2(testAdditionMean, dist, dist)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll("with two different distributions", pairsOfDifferentDistributions, dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testAdditionMean, dist1, dist2)->E.R.toExn
|
||||
E.R.liftM2(testAdditionMean, dist1, dist2)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll(
|
||||
|
@ -95,7 +95,7 @@ describe("Means are invariant", () => {
|
|||
pairsOfDifferentDistributions,
|
||||
dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testAdditionMean, dist2, dist1)->E.R.toExn
|
||||
E.R.liftM2(testAdditionMean, dist2, dist1)->E.R.toExn("Means were not invariant", _)
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -109,12 +109,12 @@ describe("Means are invariant", () => {
|
|||
)
|
||||
|
||||
testAll("with two of the same distribution", distributions, dist => {
|
||||
E.R.liftM2(testSubtractionMean, dist, dist)->E.R.toExn
|
||||
E.R.liftM2(testSubtractionMean, dist, dist)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll("with two different distributions", pairsOfDifferentDistributions, dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testSubtractionMean, dist1, dist2)->E.R.toExn
|
||||
E.R.liftM2(testSubtractionMean, dist1, dist2)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll(
|
||||
|
@ -122,7 +122,7 @@ describe("Means are invariant", () => {
|
|||
pairsOfDifferentDistributions,
|
||||
dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testSubtractionMean, dist2, dist1)->E.R.toExn
|
||||
E.R.liftM2(testSubtractionMean, dist2, dist1)->E.R.toExn("Means were not invariant", _)
|
||||
},
|
||||
)
|
||||
})
|
||||
|
@ -136,12 +136,12 @@ describe("Means are invariant", () => {
|
|||
)
|
||||
|
||||
testAll("with two of the same distribution", distributions, dist => {
|
||||
E.R.liftM2(testMultiplicationMean, dist, dist)->E.R.toExn
|
||||
E.R.liftM2(testMultiplicationMean, dist, dist)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll("with two different distributions", pairsOfDifferentDistributions, dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testMultiplicationMean, dist1, dist2)->E.R.toExn
|
||||
E.R.liftM2(testMultiplicationMean, dist1, dist2)->E.R.toExn("Means were not invariant", _)
|
||||
})
|
||||
|
||||
testAll(
|
||||
|
@ -149,7 +149,7 @@ describe("Means are invariant", () => {
|
|||
pairsOfDifferentDistributions,
|
||||
dists => {
|
||||
let (dist1, dist2) = dists
|
||||
E.R.liftM2(testMultiplicationMean, dist2, dist1)->E.R.toExn
|
||||
E.R.liftM2(testMultiplicationMean, dist2, dist1)->E.R.toExn("Means were not invariant", _)
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -96,6 +96,6 @@ let map2 = (
|
|||
// I could prove this to the type system (say, creating a {first: float, second: float, ..., fifth: float, rest: array<float>}
|
||||
// But doing so would take too much time, so I'll leave it as an assertion
|
||||
E.A.R.firstErrorOrOpen(samples)->E.R2.fmap(x =>
|
||||
E.R.assertOk("Input of samples should be larger than 5", make(x))
|
||||
E.R.toExn("Input of samples should be larger than 5", make(x))
|
||||
)
|
||||
}
|
||||
|
|
|
@ -160,12 +160,12 @@ module R = {
|
|||
let id = e => e |> result(U.id, U.id)
|
||||
let fmap = Rationale.Result.fmap
|
||||
let bind = Rationale.Result.bind
|
||||
let toExn = Belt.Result.getExn
|
||||
let assertOk = (message: string, x: result<'a, 'b>): 'a =>
|
||||
let toExn = (msg: string, x: result<'a, 'b>): 'a =>
|
||||
switch x {
|
||||
| Ok(r) => r
|
||||
| Error(_) => raise(Assertion(message))
|
||||
| Error(_) => raise(Assertion(msg))
|
||||
}
|
||||
|
||||
let default = (default, res: Belt.Result.t<'a, 'b>) =>
|
||||
switch res {
|
||||
| Ok(r) => r
|
||||
|
|
Loading…
Reference in New Issue
Block a user