-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No function clause when trying to generate pos_integer()
#211
Comments
@adkron, I guess you are omitting something. To put your example in a full property I did this property "let with pos_integer fails", [:verbose] do
our_list = let count <- pos_integer() do
(1..count) |> Enum.to_list()
end
forall l <- our_list do
(length(l) >= 1)
|> measure("PosInt List length", length l)
|> collect(length l)
end
end Works without any problems (and I would be very surprised if you really find a bug in the |
For this to be called with
@adkron did you maybe use |
I did not try to configure I was able to narrow it down, and I don't know if this should work or not. I am using |
Ouch, that feels like too many levels of abstractions :-) if I understand your statement correctly. The tuple return value of |
I can produce a similar crash with this example: defmodule BlablaTest do
use ExUnit.Case
use PropCheck
property "boom" do
gen = let x <- pos_integer() do
{:ok, some_other} = produce(pos_integer())
{x, some_other}
end
forall {x, y} <- gen do
x + y >= 0
end
end
end Stacktrace:
@adkron Do you need to use produce in a let? Note that you can also nest |
I don't need to use the 'let'. I worked around it. We use produce in some tests that aren't properties to generate some random test data. The bigger issue is that it isn't clear that you can't use produce inside the 'let'. The error message isn't helpful either. It leads to wrong assumptions. Great example. Here is the crazy part on my system. When I was trying this if the call to 'pos_integer' on the 'let' line is changed to something like 'oneof([1, 2, 3])' I wouldn't get an error. That made it seem like the 'let' line was the issue. I think that this will bite people and they won't know the issue. If there is a way that we can save them some time if we can't make it work. I'm happy to help. I've been digging in and trying to figure out where to solve this. I'm not at a computer so I can't test this at the moment but I will later. |
property "boom" do
gen = let x <- oneof([1,2,3]) do
{:ok, some_other} = produce(pos_integer())
{x, some_other}
end
forall {x, y} <- gen do
x + y >= 0
end
end It is verified that this passes. The issue only occurs with there is an integer generator inside an integer generator. |
I can support this, also floats do not work. Binaries are not problem. Since PropCheck delegates to the PropEr for the implementation of of the generators, I assume that we experience the same strange things also in Erlang. On the other hand, the use of |
Using I'm throwing out an idea here. Should |
That's a good idea! Detecting "improper" use of If we do that, we need to declare |
I like the idea of putting some functions in a "interactive" or "console" package. The notion would be that these functions are usually used in an interactive setting to try out things, but most often not used in test suites. We would need than an explicit warning of the strange behaviour of |
I use |
Version
Propcheck v 1.4.1
Example Code
Error
The text was updated successfully, but these errors were encountered: