
rustkas
Property-Based Testing with PropEr, Erlang, and Elixir: Finding a simplified case of inconsistency (page 146)
I noticed that the necessary inconsistence, which describes in an example PropEr framework does not find a discrepancy in the RFC 4180 specification, is far from at once. I was surprised when I ran the property several times and didn’t get the error I was looking for.
$ rebar3 proper
===> Testing prop_csv:prop_roundtrip()
....................................................................................................
OK: Passed 100 test(s).
===>
1/1 properties passed
When I increased the number of tests to 1000, the framework reproduced the necessary use case.
$ rebar3 proper -n 1000
===> Testing prop_csv:prop_roundtrip()
..........................!
Failed: After 27 test(s).
[#{[40,36] => []},#{[40,36] => []}]
Shrinking .......(7 time(s))
[#{[66,65] => []},#{[66,65] => []}]
===>
0/1 properties passed, 1 failed
===> Failed test cases:
prop_csv:prop_roundtrip() -> false
PropEr can help us in it better. As we know about a possible problem we can narrow Size
to 1
. For this task we can add simplified generator and property-based test:
%%%%%%%%%%%%%%%%%%
%%% Properties %%%
%%%%%%%%%%%%%%%%%%
prop_roundtrip_01() ->
?FORALL(Maps,
csv_source_01(),
Maps
=:= bday_csv:decode(
bday_csv:encode(Maps))).
%%%%%%%%%%%%%%%%%%
%%% Generators %%%
%%%%%%%%%%%%%%%%%%
csv_source_01() ->
?LET(Keys, header(1), list(entry(1, Keys))).
Launching that property we get the expected error has gotten every time:
$ rebar3 proper -d apps/bday/test -p prop_roundtrip_01
===> Linking _build/default/plugins/rebar3_format to _build/test/plugins/rebar3_format
===> Linking _build/default/plugins/katana_code to _build/test/plugins/katana_code
===> Verifying dependencies...
===> Linking _build/default/plugins/covertool to _build/test/plugins/covertool
===> Compiling bday
===> Testing prop_csv:prop_roundtrip_01()
.......!
Failed: After 8 test(s).
[#{[125] => [75,85,50]},#{[125] => []},#{[125] => []}]
Shrinking ......(6 time(s))
[#{[65] => []},#{[65] => []}]
===>
0/1 properties passed, 1 failed
===> Failed test cases:
prop_csv:prop_roundtrip_01() -> false
Popular Pragmatic Bookshelf topics

The answer to 3rd Problem of Chapter 5 (Making Choices) of “Practical Programming, Third Edition” seems incorrect in the given answer ke...
New

Hi everyone!
There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New

When I try the command to create a pair of migration files I get an error.
user=> (create-migration "guestbook")
Execution error (Ill...
New

Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New

Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New

When trying to run tox in parallel as explained on page 151, I got the following error:
tox: error: argument -p/–parallel: expected one...
New

Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New

@mfazio23
I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New

root_layout: {PentoWeb.LayoutView, :root},
This results in the following following error:
no “root” html template defined for PentoWeb...
New

From page 13:
On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New
Other popular topics

I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New

I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New

Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face:
https://on...
New

On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New

I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl:
The Ser...
New

API 4
Path:
/user/following/
Method:
GET
Description:
Returns the list of all names of people whom the user follows
Response
[
{ ...
New

Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New

If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol:
bre...
New
Latest in PragProg Customers
Latest (all)
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /react-native
- /sublime-text
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim