-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I've started learning rescript-fast-check with the bundled example program test/ExampleTest.res code:
open RescriptMocha
open Mocha
open FastCheck;
open Arbitrary
open Property.Sync
// Code under test
let contains = (text, pattern) => text->Js.String2.indexOf(pattern) >= 0
// Properties
describe("properties", () => {
// string text always contains itself
it("should always contain itself", () =>
assert_(property1(string(), text => contains(text, text)))
)
// string a + b + c always contains b, whatever the values of a, b and c
it("should always contain its substrings", () =>
assert_(property3(string(), string(), string(), (a, b, c) => contains(a ++ (b ++ c), b)))
)
})
// Recommended alternative: use a convenience method to avoid the weird `assert_` name
describe("properties using rescript-fast-check shorthand", () => {
it("should always contain itself", () => assertProperty1(string(), text => contains(text, text)))
it("should always contain its substrings", () =>
assertProperty3(string(), string(), string(), (a, b, c) => contains(a ++ (b ++ c), b))
)
})
This compiles successfully, but gives these run-time errors:
~> node_modules/mocha/bin/mocha examples/example.mjs
properties
✔ should always contain itself
✔ should always contain its substrings
properties using rescript-fast-check shorthand
1) should always contain itself
2) should always contain its substrings
2 passing (10ms)
2 failing
1) properties using rescript-fast-check shorthand
should always contain itself:
TypeError: this.arb.withBias is not a function
at ConverterToNext.generate (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/arbitrary/definition/ConverterToNext.js:29:55)
at AlwaysShrinkableArbitrary.generate (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/arbitrary/_internals/AlwaysShrinkableArbitrary.js:10:32)
at file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/arbitrary/_internals/TupleArbitrary.js:43:62
at Array.map (<anonymous>)
at TupleArbitrary.generate (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/arbitrary/_internals/TupleArbitrary.js:43:49)
at Property.generate (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/property/Property.generic.js:25:32)
at Object.value (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/Tosser.js:6:28)
at SourceValuesIterator.next (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/SourceValuesIterator.js:14:35)
at RunnerIterator.next (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/RunnerIterator.js:14:43)
at runIt (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/Runner.js:12:16)
at check (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/Runner.js:60:11)
at Module.assert (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/node_modules/fast-check/lib/esm/check/runner/Runner.js:63:17)
at Object.assertProperty1 (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-fast-check/src/Property.mjs:19:13)
at file:///Users/stu/projects/mathe/rescript/examples/example.mjs:26:41
at Module._1 (file:///Users/stu/projects/mathe/rescript/node_modules/rescript/lib/es6/curry.js:32:12)
at Context.<anonymous> (file:///Users/stu/projects/mathe/rescript/node_modules/rescript-mocha/src/Internal.mjs:28:24)
at process.processImmediate (node:internal/timers:475:21)
<snipped>
It's likely that I've misunderstood something about using this library.
Metadata
Metadata
Assignees
Labels
No labels