638 Commits

Author SHA1 Message Date
Lee Spector
5891c8641d
Merge pull request #10 from NicMcPhee/test-vector-instructions
Add tests for vector instructions
2021-01-23 15:49:42 -05:00
Erik Rauer
2af20b66b2 Delete core_test.clj file
This file was rather unnecessary so we decided to remove it for the time being.
2021-01-21 15:46:10 -06:00
Erik Rauer
9694143c4e Add .clj-kondo/ to the gitignore 2021-01-21 15:27:07 -06:00
Erik Rauer
6e281b7430 Add .clj-kondo/ to the gitignore 2021-01-21 15:26:00 -06:00
Erik Rauer
68802a9e45 Merge branch 'master' into test-vector-instructions 2021-01-21 15:19:11 -06:00
Erik Rauer
81af9c8f15 Merge remote-tracking branch 'lspector/master' 2021-01-21 15:16:41 -06:00
Erik Rauer
080df4709e Add tests for vector/_iterate
Tests work by iterating the appropriate print instruction on the vector and checking that resulting string in `:output` stack is correct.
2021-01-07 15:48:28 -06:00
Erik Rauer
39626a1764 Fix vector/_replacefirst tests
This fixes the `vector/_replacefirst` tests to be consistent with the changes made to `vector/_replacefirst` in the previous commit.
2021-01-07 14:27:14 -06:00
Erik Rauer
beed85b5c0 Change vector/_replacefirst
This changes `vector/_replacefirst` to just return the original vector if the value that will be replaced was not found. This change was made in order to be more consistent with Clojush.
2021-01-07 14:23:41 -06:00
Erik Rauer
5412ff6c90 Add tests for vector/_take
This add tests for `vector/_take`.
2021-01-05 15:52:59 -06:00
Erik Rauer
7613f18c70 Fix vector/_set
This makes it so that `vector/_set` returns `:ignore-instruction` if the given vector is empty.
2021-01-05 15:47:37 -06:00
Erik Rauer
2ffffa9fd4 Add tests for vector/_set
This adds tests for `vector/_set`.
2021-01-05 15:46:38 -06:00
Erik Rauer
1c58bcca49 Fix tests for vector/_reverse 2021-01-05 15:26:11 -06:00
Erik Rauer
fce10ca97c Add tests for vector/_reverse
This adds tests for `vector/_reverse`.
2021-01-05 14:55:23 -06:00
Erik Rauer
8afa8f83e5 Add tests for vector/_rest
This adds tests for `vector/_rest`.
2021-01-05 14:49:54 -06:00
Erik Rauer
d5f115f81c Fix vector/_replacefirst
This changes the function to throw `:ignore-instruction` if the replacement value is not present in the vector.
2021-01-03 18:31:12 -06:00
Erik Rauer
bcddca184c Add tests for vector/_replacefirst
Add tests for `vector/_replacefirst`.
2021-01-03 18:29:16 -06:00
Erik Rauer
cfe91b5ced Add tests for `vector/_replace'
This adds tests for `vector/_replace`.

We might want to change `vector/_replace` to return `:ignore-instruction` when the value to be replaced is not present in the vector. Same with `vector/_remove`.
2021-01-03 17:50:42 -06:00
Erik Rauer
94d421ef0a Add tests for vector/_remove
This adds tests for `vector/_remove`.
2021-01-03 16:17:09 -06:00
Erik Rauer
f71760c08f Add tests for vector/_pushall
This adds tests for `vector/_pushall`.
2020-12-30 14:47:29 -06:00
Erik Rauer
aa2ed597a1 Add tests for vector/_occurrencesof
This adds tests for `vector/_occurrencesof`.
2020-12-30 14:23:14 -06:00
Erik Rauer
99dbabcb82 Fix error in vector/_nth
Similar to `vector/_first` and `vector/_last`, `vector/_nth` would not check for the case of an empty vector and would divide by 0. This changes the instruction so that it simply throws `:ignore-instruction` in that case.
2020-12-29 16:21:15 -06:00
Erik Rauer
bef5a398eb Add tests for vector/_nth
This adds tests for `vector/_nth`.
2020-12-29 16:18:45 -06:00
Erik Rauer
aae0873c81 Add tests for vector/_length
This adds tests for `vector/_length`.

Also moves the tests for `vector/_indexof` higher in the file in order to be more consistent with the ordering in `vector.cljc`.
2020-12-29 15:08:33 -06:00
Erik Rauer
89b861f124 Add tests for vector/_conj
This adds tests for `vector/_conj`.

Also moves the tests for `vector/_concat` towards the top of the file to be more consistent with the order in `vector.cljc`.
2020-12-29 14:55:58 -06:00
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
75de8e5be5 Comment out the boilerplate test in core-test
We should remove that, and maybe the whole file, but for now I'll just comment it out.
2020-12-21 16:39:48 -06:00
Nic McPhee
91df21dba5 Fix error in vector/_last
Similar to `vector/_first`, this didn't check for the empty vector case, so I've changed it to return `:ignore-instruction` in that case.

There's a lot of duplication between `_first` and `_last`, which makes me think there's some refactoring opportunities.
2020-12-18 17:03:56 -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
66ec0a1ebd Address the possibility of vectors being empty in vector/_first
The original version just used the built-in `first`, which returns `nil` if you give it an empty collection, which is almost certainly not a useful behavior.

This changes it to return `:ignore-instruction` if the vector is empty, thereby leaving all the stacks unchanged.
2020-12-17 18:45:06 -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
Erik Rauer
b3d9d89f4c Allow instructions to indicate they should be ignored
`make-instruction` will ignore any instructions that return `:ignore-instruction`. This allows instructions to be skipped without consuming their arguments.
2020-12-17 18:32:41 -06:00
Nic McPhee
fc26886815 Fix bugs in vector/_subvec
There were two independent bugs in `vector/_subvec` that were turned up by our `test.check` testing.

The first was that the order of the arguments was wrong and `stop-raw` and `start-raw` were flipped.

The second was that `stop` wasn't max'ed with 0, which meant it could sometimes be negative, leading to an `IndexOutOfBoundsException`.
2020-12-17 15:58:11 -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
Nic McPhee
a6e195eb0e Add data and .calva to .gitignore
We don't want to be committing the data files or the Calva files generated by running Clojure in VS Code. This fixes that.
2020-12-17 08:15:40 -06:00
Lee Spector
8cd1a79da3 Pass argmap to report 2020-12-09 10:50:49 -05:00
Lee Spector
2f4adfde7a Pass argmap to report 2020-12-09 10:49:53 -05:00
Lee Spector
b68cf4ad75 Pass argmap to plushy->post in report 2020-12-09 10:46:02 -05:00
Lee Spector
40ac1c73a4 Add uniform-replacement 2020-12-09 10:44:57 -05:00
Lee Spector
0af6aa095e Add uniform-replacement; pass argmap to plushy->push in report 2020-12-09 10:42:05 -05:00
Lee Spector
0a5a655181 Make genetic operator dispatch more modular and extensible 2020-12-08 22:59:44 -05:00
Lee Spector
180a7fdbe0 Provide more modular and and extensible approach to genetic operator dispatch 2020-12-08 22:53:37 -05:00
Lee Spector
09d5455da3 Remove extraneous argmap argument 2020-12-08 12:21:40 -05:00
Lee Spector
aed8eb8a76 Fix handling of boolean input values 2020-12-08 12:20:26 -05:00