10 Commits

Author SHA1 Message Date
Erik Rauer
5e87478ceb Add tests for vector/_butlast
This adds tests for `vector/_butlast`.
2020-12-29 14:43:39 -06:00
Nic McPhee
957af4fc06 Use new gen-specs macro for other test cases
This moved the new `gen-specs` macro to the top of the file, and uses it to simplify the generation for the existing specifications. This allowed us to remove quite a lot of code.

We also had to change the order of arguments for all the "old" check functions so that `value-type` comes first. We renamed a few check functions so the naming is more consistent.
2020-12-28 15:45:45 -06:00
Nic McPhee
d30f7c195e Write generalized spec generation macro
This add `gen-spec` which provides a fairly general macro for creating `test.check` specifications for vector instructions.  It takes a string used to generate specification names, a function used to check the state after running the function under test, and a list of keywords indicating types for arguments generated by `test.check` and passed to the check function.

Keywords like `:integer` and `:string` are associated with "simple" generators such as `gen/small-integer` and `gen/string`. The keyword `:vector` is used to generate a vector of items whose type is specified by the `generator` argument to `generator-for-arg-type`. This allows us to loop over all of the supported vector item types in the macro and generate a separate specification for each type.

We moved the `value-type` argument for the `check` functions to the front to simplify passing in the value type arguments, which can vary in number.
2020-12-28 15:27:10 -06:00
Erik Rauer
b41c35582a Make prop/for-all call more consistent throughout the vector specs
The specs for `vector/_emptyvector`, `vector/_first`, and `vector/_last` all called `prop/for-all` within their 'check' functions, whereas the other specs all called it within their macros. This change makes the three specs mentioned more consistent with the rest of the specs by having them also call `prop/for-all` within their macros.
2020-12-27 15:33:56 -06:00
Erik Rauer
a606a47ce1 Add tests for vector/_contains
This adds the tests for `vector/_contains`
2020-12-27 15:08:51 -06:00
Nic McPhee
9028a8e174 "Simplify" the testing for concat and subvec
This introduces some fancy macro action that allows us to skip the four calls to `(concat-spec …)` with the different generators and types.

@ErikRauer and I wrestled with this for a _long_ time today, and it turned out that it was absolutely necessary to quote the generators in `gen-type-pairs on lines 10-13. I'm not 100% sure why, but it seems that without that something (perhaps a level of macro-ness) got unwrapped too early and then it couldn't find the generator because it had lost the namespace it belonged in.

Whether this actually _simplifies_ things is really up for debate. If this is as far as we get, it's probably not worth it. If we can find a reasonable way to reduce the other sources of duplication, however, it might be worth it?
2020-12-21 16:59:04 -06:00
Nic McPhee
bd59045767 Add tests for vector/_concat
This adds tests for `vector/_concat`.
2020-12-21 16:40:22 -06:00
Nic McPhee
ab1f6d4396 Add tests for vector/_last
This adds test.check tests for `vector/_last`. This is _really_ similar to `vector/_first` (and the other vector tests), so I think there are definitely ways to extract common logic from these.
2020-12-18 17:02:18 -06:00
Nic McPhee
f2eecc774f Add tests for vector/_first
These turned up an oversight in the implementation in `vector/_first` that is addressed in the next commit.
2020-12-17 18:42:57 -06:00
Nic McPhee
d1e863a23a Start test.check tests on vector instructions
This is a start on using `test.check` to write tests for the vector instructions. We currently have tests for:

   * `vector/_emptyvector`
   * `vector/_indexof`
   * `vector/_subvec`

There are _lots_ of other functions still to be tested.

This did reveal errors in `vector/_subvec`, which will be addressed in the next commit.

We used macros to make it easy to generate tests for each of the four vector types; this should be extensible to additional vector types in the future if needed.
2020-12-17 15:56:27 -06:00