[erlang-questions] Cannot make PropEr bitstring(B, U) generator to work
Tue Sep 11 16:40:41 CEST 2012
PropEr first tries to resolve the expression "bitstring(8, 1)" to a
generator, but that fails, because bitstring/2 is not a predefined
generator, and there's no custom generator with that signature declared
inside the module.
PropEr then tries to find a type with that name, but that fails as well:
bitstring/2 is not a predifined type (the way to express the same thing
in the type language is <<_:8,_:_*1>>), and there's no local type with
Quick fix: If you're OK with using only unit values of either 8 or 1,
then you can use the predefined generator binary(Base) or
bitstring(Base) respectively. If you need other unit values, you'll have
to write a custom generator.
One might have expected something like the following to work:
-type my_bitstring() :: <<_:16, _:_*3>>.
prop_foo() -> ?FORALL(B, my_bitstring(), true).
But PropEr will currently reject this for unit values other than 1 and
8, because I suck at predicting what features people will want to use,
and thought this was a safe one to skip.
On 09/11/2012 05:06 PM, Motiejus Jakštys wrote:
> I cannot get bitstring(B, U) to work. Here is a test case:
> bitstring(8, 1),
> I get this error when trying to execute it:
> Error: The typeserver encountered an error:
> What am I doing wrong?
> Tested on PropEr v1.0 and v1.0-62-g80c2c73 (latest master).
> Motiejus Jakštys
More information about the erlang-questions