practicalli / practicalli/clojure
specifying args for spec/fdef
Nobody has claimed this yet.
- Dominant language
- Makefile
- Stars
- 117
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
Hi, when using s/fdef to spec a function how do you specify :args for a function that doesn’t take any arguments?
you don’t have to specify it, but (s/cat) works
So if I omit :args stest/check fails with a :no-args-spec message. But if I use the :args empty? it seems to work. (s/cat) works too..
Ah, for check you will need it (because it uses the args generator to invoke). I will note that in fp, 0 arg functions are unusual because there is exactly one input and therefore exactly one output (and thus it can be a constant instead) OR its stateful, in which case a spec may be weird.
Yeah that’s a good point. I don’t see it coming up often. It was an impure function where part of the output was random. Probably didn’t need a spec. But I’m using spec everywhere at the moment to get a feel for it
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the s/fdef and stest/check entry points described in the issue, and compare how an omitted :args spec differs from an empty (s/cat). Determine whether the expected behavior should be documented for zero-argument functions; done means the handling and the required form for stest/check are clearly recorded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100