
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 Prag Prog topics

As per the title, thanks.
New

Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84:
bundle exec sequel...
New

I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps.
With:
ruby-3.0.0
s...
New

Hi! I know not the intentions behind this narrative when called, on page XI:
mount() |> handle_event() |> render()
but the correc...
New

I ran this command after installing the sample application:
$ cards add do something --owner Brian
And got a file not found error:
Fil...
New

I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New

I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New

When running tox for the first time, I got the following error:
ERROR: InterpreterNotFound: python3.10
I realised that I was running ...
New

I am using Android Studio Chipmunk | 2021.2.1 Patch 2
Build #AI-212.5712.43.2112.8815526, built on July 10, 2022
Runtime version: 11.0....
New

@mfazio23
Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New
Other popular topics

What chair do you have while working… and why?
Is there a ‘best’ type of chair or working position for developers?
New

No chair. I have a standing desk.
This post was split into a dedicated thread from our thread about chairs :slight_smile:
New

You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
New

The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New

Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
New

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

Author Spotlight:
VM Brasseur
@vmbrasseur
We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New

zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig.
General-purpose programming language and toolchain for maintaini...
New

Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
Latest in PragProg
Latest (all)
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
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /julia
- /c
- /slackware
- /neovim