Clojurians
#test-check
<
2017-03-02
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

gfredericks01:03:50

@andrea.crotti yep, earlier is better as you say

andrea.crotti09:03:01

cool thanks @gfredericks

andrea.crotti09:03:23

another thing, suppose I have a bag with a limited number of objects in it per type

andrea.crotti09:03:09

at the moment what I'm doing is to generate sequences picking random types and applying constraints to be sure there are never too many of a certain type

andrea.crotti09:03:54

I guess there is probably a more efficient way? in theory it's just a random selection in a list, removing the element selected each time

andrea.crotti09:03:15

any more idiomatic way to do that with test.check @gfredericks ?

andrea.crotti10:03:38

btw it looks like it's not possible to file an issue here https://github.com/clojure/test.check

andrea.crotti10:03:56

and there is no mention in the readme about how to do that either

gfredericks14:03:01

@andrea.crotti clojure and all the contribs are managed on http://dev.clojure.org/jira

gfredericks14:03:01

This is mentioned in the readme under Contributing

gfredericks14:03:55

I don't quite understand the requirements for your bag of limited number of objects question -- it would help if you could share the code you have that does that

andrea.crotti14:03:58

Ah sorry my bad

andrea.crotti14:03:22

It's the link I shared yesterday

andrea.crotti14:03:43

Just the usual scrabble bag of letters

gfredericks14:03:28

Oh so the main constraint is you can't have too many of each letter?

andrea.crotti14:03:46

Yes, there is a max quantity for each

andrea.crotti14:03:09

And applying constraints would work but I bet it's not really efficient

gfredericks14:03:24

Do you care about distribution/shrinking?

andrea.crotti14:03:26

Maybe I can write my own generator

andrea.crotti14:03:55

Potentially yes

gfredericks14:03:39

One idea is to generate a size (gen/nat) and a shuffling of a complete collection of letters, and then fmap with (take size shuffled)

gfredericks14:03:01

gen/shuffle for doing the shuffling

gfredericks14:03:58

That still does some throwaway work but it's at least conceptually simple and easy to tweak

gfredericks14:03:24

And gives you a realistic distribution in a certain sense

andrea.crotti16:03:44

ah cool yes I can check

andrea.crotti16:03:50

thanks for the idea

andrea.crotti16:03:02

writing your own generator would be problematic?

andrea.crotti16:03:43

about the issue I wanted to raise, I just wanted to say that now both "generators" and "combinators" are both in the same namespace

andrea.crotti16:03:13

and even have the same prefixed name, even if they have two quite different roles from my undertanding

andrea.crotti16:03:42

that's all I wanted to mention really

gfredericks16:03:54

@andrea.crotti what do you mean by "writing your own generator"? I would call what I just described writing your own generator

andrea.crotti16:03:46

ah ok but if it's just built using the "official" combinators and generators

andrea.crotti16:03:51

does it count as my custom generator?

gfredericks16:03:20

@andrea.crotti test.check is designed so that you shouldn't need to go beyond those

gfredericks16:03:35

so we don't usually talk about anything more custom than that

gfredericks16:03:30

if you have something you think you can't do with the combinators I'd be happy to look at it

andrea.crotti17:03:09

ok great thanks