This test turned out to be a very discerning one. Adding it uncovered
numerous bugs, large and small, in the TypeDispatcher. The most major
one was that a Map distinguishes keys by strict equality, and hence
since every lookup for a cached behavior was using a newly-generated array
of types, the cache was never being hit. So it looked like methods were
being updated as dependencies changed, when what was really happening
was that the behavior was simply being regenerated from scratch on every
call, which would not be performant as the prototype scaled.
This bug is now fixed (by switching to a third-party ArrayKeyedMap), along
with many smaller bugs too numerous to list.
It should now be feasible to go through Pocomath and add all of the functions
that depend on numbers and booleans only.
We use [mocha](https://mochajs.org/) as the test framework, as it is
the tool used by mathjs and we would like to make tests as similar
as possible. However, to tighten the linkage between source code and
tests, we adopt a somewhat different file organization: unit tests
for a given source file `blah/foo.js` are in `blah/__test__/foo.spec.js`.
To run all unit tests, execute the script `pnpm test`.
Resolves#3.
Reviewed-on: glen/nanomath#5
Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Co-committed-by: Glen Whitney <glen@studioinfinity.org>