Re: proper char() type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Ryan Maclear
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Ryan Maclear
Hi All,

I've gone through the code for the integer() type and have found where my issue arises from.

the proper_gen:pick/1 function has a default Size of 10, but the proper_gen:pick/2 function provides for a size to be passed.

If I call:

proper_gen:pick(proper_types:char(), 1114111), I get results as expected.

Since the definition of char() is equivalent to integer(0,16#10ffff), I would have expected the proper_gen:pick_type(proper_types:char()) call to result in the arity 2 version of this function being called, or at least have the Size set to the upper bound of the integer range in the integer_gen function call, either in proper_types:integer_gen/2 function call.

Does this make sense or am I missing something?

Regards,
Ryan Maclear




On 17 May 2018 at 11:08, Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Jesper Louis Andersen-2
In reply to this post by Ryan Maclear
Most QuickCheck systems have an internal size parameter which is slowly increased over the course of testing. If you manually bump it by a lot, you get a better range:

16> proper_gen:pick(proper_types:resize(8000, proper_types:integer(0, 16#10ffff))).
{ok,5050}

However, I feel most of propers generators are botched and don't really check what they should. EQC Mini for instance:

5> eqc_gen:sample(eqc_gen:choose(0, 16#10ffff)).
482145
1062500
211296
269049
863625
4346
441921
719972
62442
703915
944194
ok

which is far more the range you would expect. Also note that the pick/1 function is kind of dangerous since it leads people down a path where their generators have less randomness than they should have. The right solution often involves ?LET(X, generator(), <[X] E x>) and friends.



On Thu, May 17, 2018 at 11:34 AM Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Ryan Maclear
Ah ok, that makes perfect sense. So manually calling the pick/1 function with just the type will always start with the Size parameter set to 10, but over time the internals would increase this for repeated calls, and thus stretching the sample space to the max range.

Thanks for clearing that up.

Kind Regards,
Ryan Maclear


On 17 May 2018 at 12:02, Jesper Louis Andersen <[hidden email]> wrote:
Most QuickCheck systems have an internal size parameter which is slowly increased over the course of testing. If you manually bump it by a lot, you get a better range:

16> proper_gen:pick(proper_types:resize(8000, proper_types:integer(0, 16#10ffff))).
{ok,5050}

However, I feel most of propers generators are botched and don't really check what they should. EQC Mini for instance:

5> eqc_gen:sample(eqc_gen:choose(0, 16#10ffff)).
482145
1062500
211296
269049
863625
4346
441921
719972
62442
703915
944194
ok

which is far more the range you would expect. Also note that the pick/1 function is kind of dangerous since it leads people down a path where their generators have less randomness than they should have. The right solution often involves ?LET(X, generator(), <[X] E x>) and friends.



On Thu, May 17, 2018 at 11:34 AM Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Pierre Fenoll-2
You should also take a look at
proper_gen:sample and sampleshrink ;)

Also Fred Herbet’s propertesting.com!

On Thu 17 May 2018 at 12:36, Ryan Maclear <[hidden email]> wrote:
Ah ok, that makes perfect sense. So manually calling the pick/1 function with just the type will always start with the Size parameter set to 10, but over time the internals would increase this for repeated calls, and thus stretching the sample space to the max range.

Thanks for clearing that up.

Kind Regards,
Ryan Maclear


On 17 May 2018 at 12:02, Jesper Louis Andersen <[hidden email]> wrote:
Most QuickCheck systems have an internal size parameter which is slowly increased over the course of testing. If you manually bump it by a lot, you get a better range:

16> proper_gen:pick(proper_types:resize(8000, proper_types:integer(0, 16#10ffff))).
{ok,5050}

However, I feel most of propers generators are botched and don't really check what they should. EQC Mini for instance:

5> eqc_gen:sample(eqc_gen:choose(0, 16#10ffff)).
482145
1062500
211296
269049
863625
4346
441921
719972
62442
703915
944194
ok

which is far more the range you would expect. Also note that the pick/1 function is kind of dangerous since it leads people down a path where their generators have less randomness than they should have. The right solution often involves ?LET(X, generator(), <[X] E x>) and friends.



On Thu, May 17, 2018 at 11:34 AM Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
--

Cheers,
-- 
Pierre Fenoll


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Jesper Louis Andersen-2
In reply to this post by Ryan Maclear
I don't think you are missing anything.

Some QuickCheck systems will use a size parameter like 1-100 and then they "scale" the range over that size. If you ask for, say, 30 test cases, they usually scale 1-100 over the first 15, and then they run 15 with the full range.

The idea, roughly, is that while you eventually want to check a full range, but many errors occur when a range is small. And small cases are often easier to debug.

This notion goes hand in hand with shrinking: if you _do_ find a large test case, pick a strategy for finding a failure, but for a simpler generated input.

As for integers, I often use something like:

%% @doc pow_2_int/0 generates integers close to a power of two
%% It turns out that integers around powers of two are often able to mess up stuff
%% because of their bitwise representation. This generator generates integers close
%% to a power of two deliberately.
%% @end
pow_2_int() ->
    ?LET({Sign, Exponent, Perturb}, {sign(), choose(0, 128), choose(-3, 3)},
        Sign * pow(2, Exponent) + Perturb).

sign() -> elements([1, -1]).

pow(0, 0) -> 0;
pow(_Base, 0) -> 1;
pow(Base, N) -> Base * pow(Base, N-1).

(This is from [0])

It doesn't generate any integer, but since a lot of systems cannot handle corner case integers well, this is an excellent way to check them. Especially if they have two-complement representations and have one more negative value than positive. The above code sequence has found bugs in Erlangs bignum handling btw.

On Thu, May 17, 2018 at 12:35 PM Ryan Maclear <[hidden email]> wrote:
Hi All,

I've gone through the code for the integer() type and have found where my issue arises from.

the proper_gen:pick/1 function has a default Size of 10, but the proper_gen:pick/2 function provides for a size to be passed.

If I call:

proper_gen:pick(proper_types:char(), 1114111), I get results as expected.

Since the definition of char() is equivalent to integer(0,16#10ffff), I would have expected the proper_gen:pick_type(proper_types:char()) call to result in the arity 2 version of this function being called, or at least have the Size set to the upper bound of the integer range in the integer_gen function call, either in proper_types:integer_gen/2 function call.

Does this make sense or am I missing something?

Regards,
Ryan Maclear




On 17 May 2018 at 11:08, Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: proper char() type

Ryan Maclear
In reply to this post by Pierre Fenoll-2
Yip - I'm working through propertesting.com again, but paying more attention and looking at it a lot closer this time as I have a real need for doing some stateful property testing.

It really is a great resource.
 

On 17 May 2018 at 14:04, Pierre Fenoll <[hidden email]> wrote:
You should also take a look at
proper_gen:sample and sampleshrink ;)

Also Fred Herbet’s propertesting.com!

On Thu 17 May 2018 at 12:36, Ryan Maclear <[hidden email]> wrote:
Ah ok, that makes perfect sense. So manually calling the pick/1 function with just the type will always start with the Size parameter set to 10, but over time the internals would increase this for repeated calls, and thus stretching the sample space to the max range.

Thanks for clearing that up.

Kind Regards,
Ryan Maclear


On 17 May 2018 at 12:02, Jesper Louis Andersen <[hidden email]> wrote:
Most QuickCheck systems have an internal size parameter which is slowly increased over the course of testing. If you manually bump it by a lot, you get a better range:

16> proper_gen:pick(proper_types:resize(8000, proper_types:integer(0, 16#10ffff))).
{ok,5050}

However, I feel most of propers generators are botched and don't really check what they should. EQC Mini for instance:

5> eqc_gen:sample(eqc_gen:choose(0, 16#10ffff)).
482145
1062500
211296
269049
863625
4346
441921
719972
62442
703915
944194
ok

which is far more the range you would expect. Also note that the pick/1 function is kind of dangerous since it leads people down a path where their generators have less randomness than they should have. The right solution often involves ?LET(X, generator(), <[X] E x>) and friends.



On Thu, May 17, 2018 at 11:34 AM Ryan Maclear <[hidden email]> wrote:
Appologies, I hit send before finisinh the email. Here is the complete mail:

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for

proper_gen:pick(proper_types:range(0,16#10ffff)).

which I believe is equivalent.

I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan


On 17 May 2018 at 11:07, Ryan Maclear <[hidden email]> wrote:
Good Day,

I'm busy learning to use proper and have the following issue. When calling the function

From the API docs, the char() type has a range of 0 to (1114111) 16#10ffff.

When calling the function

proper_gen
:pick(proper_types:term()).


manually many times (I've tried in around 3000 times) and on different VMs, the function always seems to return only one of the following values:

{ok,0},
{ok,2},
{ok,3},
{ok,6}
{ok,12} and
{ok,13}

I see the same behaviour for


I have tried on erlang 19.3.6.9, erlang 20.3.6 on a Mac as well as on a ubuntu trusty docker image with erlang 19.3.

In all three vms I see the same set of results being returned.

Is there something else I need to do before calling this function?

Thanks,
Ryan

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
--

Cheers,
-- 
Pierre Fenoll



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions