Deduplicate testing code - with typeclasses
Description of the change
This PR demonstrates another testing strategy that accomplishes the following:
- Encourages API consistency
- It lets the compiler help us fix #183 and prevent future API gaps.
- Reuses tests
- Common tests were previously duplicated 4+ times for the different list types.
- This strategy could be extended to allow reuse across a variety of container/collection types.
- It looks like many of the tests in this lists library were initially copied over from the arrays library, so it would be great if we could let these be reused when possible.
This new testing strategy involves creating testing-specific typeclasses that cluster common APIs. This lets the compiler enforce common interfaces during library development, but doesn't expose this misuse of typeclasses to library consumers (see #184 for more discussion on typeclasses as interfaces).
These changes are additive at the moment, but we could also delete any duplicated tests as they are migrated to these common tests. The goal is to migrate all preexisting tests.
Progress:
- [x] Typeclass interfaces for full API coverage (see proposed API list in https://github.com/purescript/purescript-lists/issues/183#issuecomment-825460643). Note that some "common" APIs may be split across multiple typeclasses due to non-identical type signatures.
- [x]
unsafeCrashWithplaceholders for missing APIs. - [ ] Copy over existing tests or create new tests for full API coverage.
- [ ] Enhancement: Convert
asserttoassertEqualfor better printing of testing mismatches.
PR Checklist:
- [ ] Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
- [ ] Linked any existing issues or proposals that this pull request should close
- [ ] Updated or added relevant documentation
- [x] Added a test for the contribution (if applicable)
Having issues reproducing the CI failure locally. Don't know why. I believe versions are the same:
$ pulp --version
Pulp version 15.0.0
purs version 0.14.1 using /home/miles/.nvm/versions/node/v14.9.0/bin/purs
$ pulp build -- --censor-lib --strict --censor-codes='UserDefinedWarning'
* Building project in /home/miles/projects/purescript/lists
Invalid option `--censor-lib'
Usage: purs COMMAND
The PureScript compiler and tools
* ERROR: Subcommand terminated with exit code 1
Looks like you don’t have psa installed — you can either install it or omit the flags passed to pulp. The error you’re seeing is because of a compiler warning introduced in 0.14.1 that warns on unused names.