test-allclose
Utility for tape to compare numbers, arrays, or nested arrays up to some tolerance, with helpful error output on test failure. Uses allclose and inspired by test-fuzzy-array.
install
use npm
npm install test-allclose
usage
require with
var allclose =
then use with a test instance t
of tape
or similar
var close =
to get a function close(a, b, [atol], [rtol])
that, when called on two arrays a
and b
, will execute tests using the test instance t
and generate useful output on test failure
examples
setup tests using tape
as usual
var test =
then inside a test call
you can test numbers
1 1> test passes 1 2> test fails
or arrays
1 2 1 2> test passes 1 2 1 3> test fails
or nested arrays
1 2 3 4 1 2 3 4> test passes 1 2 3 4 1 2 3 5> test fails
and you can optionally specify a tolerance
1 2 1 21> test fails 1 2 1 21 03> test passes