Fork me on GitHub
#clojure-spec
<
2017-06-27
>
abhirag11:06:46

Hi, kinda new to clojure as well as clojure.spec

abhirag11:06:30

Was trying out specifying the above function and stest/check hangs forever

abhirag11:06:48

am I doing anything wrong here?

alexmiller13:06:03

@abhirag how long did you wait? (presumably not “forever” :) it works for me, but takes a while.

alexmiller13:06:21

“a while” being a couple minutes

gfredericks13:06:04

😳 why should that take a couple minutes?

alexmiller13:06:28

a fair question :)

abhirag13:06:07

I did try and restrict the count to 10 to reduce time, my dev machine might be slower than yours Alex, I will try again and try and not get afraid of the cooling fans revving up :)

abhirag13:06:32

I also tried to restrict the :test-nums to 10

abhirag13:06:03

But still the running time wasn't getting shorter

gfredericks13:06:50

that definitely sounds like a problem to me

alexmiller13:06:57

yeah, that seems weird

alexmiller13:06:20

s/coll-of with a :count parameter will create a gen/vector with a size

abhirag13:06:06

Yeah I did learn that from your guide :)

abhirag13:06:19

And also if I just specify the function using fdef and don't give an implementation

abhirag13:06:27

And then try check

abhirag13:06:39

It just gives a null pointer exception

abhirag13:06:54

No error message regarding the fact that no implementation was provided :P

abhirag13:06:03

Thought I should mention that too

alexmiller13:06:46

@gfredericks (g/sample (g/vector g/large-integer 10) 1000) seems like it should be close to what I’d expect and that’s fast

gfredericks13:06:05

alexmiller: yeah that's what I was imagining

alexmiller14:06:23

although it’s also going to put those in lists, then put that in a vector for the args, then invoke the function, then check the return is a list, reverse that list, and compare it to the input list

alexmiller14:06:19

this is indeed pretty jacked and is already logged https://dev.clojure.org/jira/browse/CLJ-2103

alexmiller14:06:33

but I did not fully understand this issue before

gfredericks15:06:54

I don't understand it at a glance; let me know if it'd be helpful for me to look closer

alexmiller13:06:44

@abhirag there is a ticket for that error case, which I think went into alpha17, not sure which you’re using

abhirag13:06:08

The version mentioned in the guide

abhirag13:06:14

Let me check

alexmiller13:06:21

I think the guide says alpha16 right now

abhirag13:06:41

Alright I will upgrade, thanks for your help :)

alexmiller14:06:31

maybe I’m confusing that with something else. if you still see, feel free to log a jira for it

abhirag14:06:15

Will do :)

abhirag14:06:37

@alexmiller I am still getting this error

abhirag14:06:20

I haven't ever logged a defect before in clojure, but if you feel that this deserves a ticket I'll log one 🙂

alexmiller14:06:25

I’m still looking at your gen stuff too. It shouldn’t be that slow. I believe it’s the :kind list? that is causing the slow-down.

abhirag14:06:33

yeah I had tried property testing in other languages before, that snippet was an overkill, my main motive with that was that if we already have a function tested and need to rewrite it for optimization etc. we could just use the old function to test it

abhirag14:06:15

now I realize that with spec all I really need is that the rewritten function have the same spec

wilkerlucio14:06:06

@abhirag I noticed on your REPL example that you didn't defined the my-reverse function

abhirag14:06:32

yeah I realize that 🙂 that was just to get that null pointer exception, I was gonna log a ticket to make that error message better

wilkerlucio14:06:31

cool, just wondered if was on purpose :)

alexmiller14:06:59

@abhirag the slow gen is actually already logged https://dev.clojure.org/jira/browse/CLJ-2103 and is definitely in need of some work

abhirag14:06:19

one more quick question (stest/check `my-reverse {:num-tests 10})

abhirag14:06:32

is this the correct way to reduce the number of tests?

abhirag14:06:31

that actually didn't throw any exception, but as I was not getting any output, there wasn't any other way to know 🙂

alexmiller14:06:41

I think

(stest/check `my-reverse {:clojure.spec.test.check/opts {:num-tests 10}})

abhirag14:06:41

alright got it, thanks 🙂

abhirag14:06:53

I'll try and use :onto vector

abhirag14:06:20

as described in the issue description

abhirag14:06:37

to get away from the slow running time for now

alexmiller14:06:17

I think using :into () in addition to :kind list? would help

abhirag14:06:00

alright will give that a try 🙂