In the 5th Question of the third chapter, it was proposed to create a function, as well as a testing property to test its work. In your answer on page 411, author suggested to write in a function in a properties file. Interesting. Why did you decide to write the function under test here? May be the module solutions
in the source code folder src
would be better place for it? It is very interesting to know the course of your thoughts on this issue.
Source code of the module in the src
folder would be like this:
-module(solutions).
-export([word_count/1]).
word_count(String) ->
% ...
Property based test source code in the test
folder would be like this:
-module(prop_solutions).
-include_lib("proper/include/proper.hrl").
%%%%%%%%%%%%%%%%%%
%%% Properties %%%
%%%%%%%%%%%%%%%%%%
prop_word_count() ->
?FORALL(String, (non_empty(string())),
(word_count(String) =:= alt_word_count(String))).
% ...
I also noticed that Fred placed the call to the function under test on the left in the comparison expression. Why? He already explained this to me earlier.