By Developers, For Developers

Historical errata for Property-Based Testing with PropEr, Erlang, and Elixir

PDF PgPaper PgTypeDescriptionFixed onComments
257TYPO

The Elixir translation for the key and val generators is missing. I used:

def key(), do: oneof([range(1, @cache_size), integer()])

def val(), do: integer()

2018-09-09
811SUGGEST

MIX_ENV =" test" iex -S mix

Fred Hebert. Property-Based Testing with PropEr, Erlang, and Elixir (Kindle Location 811). The Pragmatic Bookshelf, LLC.

It would help to point out that you either need to clone proper or run the mix command from deps/proper. Running this from the root of an app that uses proper (such as the one you created earlier in the chapter) will trigger the error:

(Mix) Could not start application propcheck: could not find application file: propcheck.app

2018-10-25
1875TYPO

duplcated should read duplicated

Fred Hebert. Property-Based Testing with PropEr, Erlang, and Elixir (Kindle Location 1875). The Pragmatic Bookshelf, LLC.

2018-10-25
14TYPO

In the first paragraph of the “Running A Property” section, there’s an extra word “a” after the word “have” in the sentence fragment “what we’d have a in a real project”, which appears in about the middle of the paragraph.

2018-12-07
5TYPO

First excerpt on the web, towards the bottom of page 5, “exmaple” for “example”. I don’t have the book, so I don’t know if it has been fixed already in the book.

2018-12-07
30SUGGEST

The warning on removing `_build/propcheck.ctex` is probably more useful if it is moved to PDF page 27 after the rebar3 output.

Maybe referencing propcheck issue #30 could help give context to those who are curious to know why.

2018-12-07
64SUGGEST

(Actually, I’m not sure whether it’s a suggestion, typo, or error)

Running the Elixir version still returns 50% {bio,{0,300}} most of the time (informally, 7 out of 20); that is nowhere near the output from the Erlang version.

2018-12-11This appears to be a limitation or bug of the utf8() generator directly in PropEr / PropCheck; since PropCheck does not expose the string() generator I don't really know much can be done.
76SUGGEST

Include the instructions for Elixir developers on running generating samples in iex:

$ EXPORT MIX_ENV=test
$ iex -S mix
iex(1)> ExUnit.start()
iex(2)> c “test/generators_test.exs” # compiles the test script
iex(3)> :proper_check.sample(PbtGenerators.path()) # generates samples

2018-12-07
13SUGGEST

Update mix.exs to make propcheck available to both :dev and :test environments, as suggested on propcheck’s GitHub page

{:propcheck, “~> 1.1”, only: [:test, :dev]}

2018-12-07
329TYPO

Many parts of code are formatted wrongly, e.g., code between escapable/1 and the last do_escape/1 are italicized, decode_name/1 are not colored properly and are italicized.

2018-12-12This appears to be a limitation of the PragProg Syntax highlighter for Elixir mishandling strings when using sigils approach (~s||)
xiiiSUGGEST

Last line of the page: “samples that would take a lot of place”; seems like “place” should be “space”.

2018-12-07
xivSUGGEST

2nd paragraph, 3rd sentence: “…, and may not container intermediary steps showed in the text.” Using “shown” seems more common (and comfortable). Please ignore if intended.

2018-12-07
2?SUGGEST

“familiar with thinking and properties” -> “familiar with thinking about properties” ?

2018-12-07
3SUGGEST

“helping us write them as a user as well as implementers.” ->
“helping us write them as users as well as implementers”, i.e. pluralize both to match “us”

2018-12-07
137SUGGEST

Replace integer() with pos_integer() when generating the price list. Otherwise, the generator will generate negative prices. “Technically”, it’s not wrong (and the tests pass), but feels very wrong in the real world.

2018-12-11This is acknowledged on page 164 of the book (PDF page 172) already in B4. \nIt is a bit of a deliberate choice to use any integer whatsoever, and it's part of illustrating that the tests can be good and the code can work great, but it does not necessarily mean that the solution chosen is apt :)
9696TYPO

“Commas go between fields of a records”, I think it should be “fields of a record”. 4th item in the spec list, 3rd in the actual page.

2019-01-11
337ERROR

In the Elixir translation of the command/1 callback rewritten to use the shim module, under ‘always_possible’, the arguments for ‘:find_book_by_author_unknown’ and ‘:find_book_by_title_unknown’ should be ‘[author()]’ and ‘[title()]’, respectively, rather than ‘[isbn()]’ Also, under ‘relies_on_state’, the argument for ‘:find_book_by_title_matching’ should be ‘[title(s)]’ instead of ‘[isbn(s)]’

6TYPO

2nd paragraph: “Let’s take a look at some more-expert work.” … “more-expert” was not hyphenated in B4 and it doesn’t seem like it should be.

2019-01-14
79TYPO

Between the Erlang and Elixir sample output:
“For Elixir users, the commands are bit trickier”
Should be
“For Elixir users, the commands are a bit trickier”
i.e. missing “a”

2019-01-14
165TYPO

First paragraph, second sentence: missing “of”
“and relaxing more them would likely”
should be
“and relaxing more of them would likely”

170TYPO

The Elixir code repeats the defintion of strdatetime() and datetime() instead of giving the definition of date() and year()

82ERROR

property “symbolic generator” do
forall d <- dict_symb() do
# propcheck does not automatically handle eval() calls
:proper_gen.eval(:dict.size(d)) < 5
end
end

Should be

property “symbolic generator” do
forall d <- dict_symb() do
# propcheck does not automatically handle eval() calls
:dict.size(:proper_symb.eval(d)) < 5
end
end

or

property “symbolic generator” do
forall d <- dict_symb() do
# propcheck does not automatically handle eval() calls
d |> :proper_symb.eval() |> :dict.size() < 5
end
end

d needs to be evaluated before it can be passed to :dict.size/1. :proper_gen.eval/1 is not in the 1.3 API docs, but :proper_symb.eval/1 works well.

79ERROR

When sampling the test generators in Elixir:

iex(3)> :proper_check.sample(PbtGenerators.path())

should be

iex(3)> :proper_gen.sample(PbtGenerators.path())

319TYPO

In the “For meeting hours” section “is’t” should be “isn’t”.

41ERROR

The combined properties for sorting will test true for a sorting algorithm that doesn’t handle repeated elements correctly, e.g., replacing a repeated element with another already existing element. As an example, sort([1,2,1]) = [1,2,2] is correct according to the properties. The properties given are this too weak.

181TYPO

The first paragraph mentions the direction ‘top’ in the two paths.
Ex: [left, top, left, top]
I think it should be ‘up’. Or I have just misunderstood.

22ERROR

When testing the elixir code for :proper_gen.pick, it is being called with pick/0 which throws an error on iex

(UndefinedFunctionError) function :proper_gen.pick/0 is undefined or private. Did you mean one of:

* pick/1
* pick/2
* pick/3

(proper) :proper_gen.pick()

We need to pass it a generator for it to work properly I guess, e.g

:proper_gen.pick(:proper_types.term())

335ERROR

The Elixir translation of the Thinking in Properties sample is badly broken.

Most of the ~s sigils are not closed properly. This is obvious when the syntax highlighting has broken down. It starts to go wrong at the end of escapable/1 halfway down the page.

escapable/1 should be called escapable?/1 according to normal Elixir styles.

336ERROR

body of precondition for :find_book_by_author_unknown should be replaced with

not like_author(auth)

and body of :find_book_by_title_unknown with

not like_title(title)

The current version has “not has_isbn(s, xxx)” which do not match Erlang’s version.

50TYPO

I think one of the end brackets of the function is missing (it is missing).

5> proper_gen:pick(proper_types:non_empty(proper_types:list(proper_types:number
())).

  • 1: syntax error before: ‘.’
    5> proper_gen:pick(proper_types:non_empty(proper_types:list(proper_types:number
    ()))).
    {ok,[–4,0,–6,–3.2348713277021397,5.399533300382501,
    –15.34668391096966,–3.5774318890409793,–21.17589502652329]}
    6>
216TYPO

When outputting state of the system in case of an error “History: #{inspect(history}” is missing a closing bracket.

Categories: