Skip to content

Commit 4bc5ade

Browse files
committed
Forgot to commit the real type for 'size' instead of using a string
1 parent 2520f32 commit 4bc5ade

File tree

8 files changed

+47
-673
lines changed

8 files changed

+47
-673
lines changed

bsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"suffix": ".bs.js",
1919
"bs-dev-dependencies": [
20-
"bs-mocha"
20+
"rescript-mocha"
2121
],
2222
"package-specs": [
2323
{

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
"author": "Andrew Herron",
3131
"license": "BSD-3-Clause",
3232
"devDependencies": {
33-
"bs-mocha": "^1.0.0",
34-
"mocha": "^9.0.1"
33+
"rescript": "^9.1.4",
34+
"rescript-mocha": "^0.9.0"
3535
},
3636
"dependencies": {
37-
"fast-check": "^2.17.0",
38-
"rescript": "^9.1.4"
37+
"fast-check": "^2.17.0"
3938
}
4039
}

src/Arbitrary.res

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ type sum<'a>
77

88
type arbitrary<'a>
99

10+
@ocaml.doc(
11+
"see https://github.com/dubzzz/fast-check/blob/main/documentation/Arbitraries.md#size-explained"
12+
)
13+
type arbitrarySize = [
14+
| #"-4"
15+
| #"-3"
16+
| #"-2"
17+
| #"-1"
18+
| #"="
19+
| #"+1"
20+
| #"+2"
21+
| #"+3"
22+
| #"+4"
23+
| #xsmall
24+
| #small
25+
| #medium
26+
| #large
27+
| #xlarge
28+
| #max
29+
]
30+
1031
// Advanced arbitraries, methods on the arbitrary instances to derive new arbitraries
1132
module Derive = {
1233
@send external chain: (arbitrary<'a>, 'a => arbitrary<'b>) => arbitrary<'b> = "chain"
@@ -62,17 +83,17 @@ module Combinators = {
6283
~maxLength: float=?,
6384
~selector: 'a => 'a=?,
6485
~comparator: [#SameValue | #SameValueZero | #IsStrictlyEqual]=?,
65-
~size: string=?,
66-
unit
86+
~size: arbitrarySize=?,
87+
unit,
6788
) => uniqueArrayOptions = ""
6889
@obj
6990
external uniqueArrayOptionsWithMethodComparator: (
7091
~minLength: float=?,
7192
~maxLength: float=?,
7293
~selector: 'a => 'a=?,
7394
~comparator: ('a, 'a) => bool=?,
74-
~size: string=?,
75-
unit
95+
~size: arbitrarySize=?,
96+
unit,
7697
) => uniqueArrayOptions = ""
7798
@module("fast-check")
7899
external uniqueArray: arbitrary<'a> => arbitrary<array<'a>> = "uniqueArray"

test/ArbitraryTest.res

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open BsMocha.Mocha
1+
open RescriptMocha.Mocha
22
open Arbitrary
33
open Property.Sync
44
module FcAssert = Property.FcAssert
@@ -102,6 +102,9 @@ describe("combinators", () => {
102102
FcAssert.sync(property1(uniqueArray(hexa()), eq))
103103
FcAssert.sync(property1(uniqueArrayWithOptions(hexa(), uniqueArrayOptions(~minLength=5., ~maxLength=10., ~comparator=#SameValue, ())), eq))
104104
FcAssert.sync(property1(uniqueArrayWithOptions(hexa(), uniqueArrayOptionsWithMethodComparator(~minLength=5., ~maxLength=10., ~comparator=\"==", ())), eq))
105+
FcAssert.sync(property1(uniqueArrayWithOptions(hexa(), uniqueArrayOptions(~size=#"+4", ())), eq))
106+
FcAssert.sync(property1(uniqueArrayWithOptions(hexa(), uniqueArrayOptions(~maxLength=50., ~size=#max, ())), eq))
107+
FcAssert.sync(property1(uniqueArrayWithOptions(hexa(), uniqueArrayOptions(~size=#xsmall, ())), eq))
105108
FcAssert.sync(property1(tuple2(hexa(), hexa()), eq))
106109
FcAssert.sync(property1(tuple3(hexa(), hexa(), hexa()), eq))
107110
FcAssert.sync(property1(tuple4(hexa(), hexa(), hexa(), hexa()), eq))
@@ -200,7 +203,7 @@ describe("complex built-in arbitraries", () => {
200203
FcAssert.sync(property1(tree, constTrue))
201204
})
202205

203-
BsMocha.Promise.it("scheduler", () =>
206+
RescriptMocha.Promise.it("scheduler", () =>
204207
Property.Async.assertProperty1(Arbitrary.Scheduler.scheduler(), s => {
205208
open Js.Promise
206209
let result = ref(0)

test/ExampleTest.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ported from the fast-check getting started guide
22
// https://github.com/dubzzz/fast-check#getting-started
3-
open BsMocha.Mocha
3+
open RescriptMocha.Mocha
44

55
// open FastCheck;
66
open Arbitrary

test/PropertyTest.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open BsMocha.Mocha
1+
open RescriptMocha.Mocha
22
open Arbitrary
33
open Property
44

@@ -192,7 +192,7 @@ describe("syncUnit property checks", () => {
192192
)
193193
})
194194

195-
open! BsMocha.Promise
195+
open! RescriptMocha.Promise
196196
describe("async property checks", () => {
197197
let eq = i => Js.Promise.resolve(i === i)
198198
let eq2 = (i, j) => Js.Promise.resolve(i === i && j === j)

test/SimpleTests.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
(at least as many as we're able to given it hasn't all been replicated in these bindings)
66
*/
77

8-
open BsMocha.Mocha
8+
open RescriptMocha.Mocha
99
open Arbitrary
1010
open Property.Sync
1111
open Combinators

0 commit comments

Comments
 (0)