QuickCheck Tutorial. Thomas Arts. John Hughes. Quviq AB. Queues. Erlang contains a queue data structure. (see stdlib documentation). We want to test that . In Erlang, it’s the usual accepted approach to implement as much as possible on the BEAM. This gives every bit of code the wonderful. check the operations (implement by using QuickCheck). Generator for decimals: decimal() ->?LET(Tuple, {int(),nat()}, new(Tuple)). Able to generate all possible.

Author: Kale Zolosar
Country: Indonesia
Language: English (Spanish)
Genre: Music
Published (Last): 7 April 2017
Pages: 283
PDF File Size: 5.7 Mb
ePub File Size: 19.36 Mb
ISBN: 336-5-56302-930-9
Downloads: 89163
Price: Free* [*Free Regsitration Required]
Uploader: Judal

June 15, By Heinz N. This gives every bit of code the wonderful characteristics of decent fault handling we love so much. Still the first rule of NIF-Club is: Do not write NIFs. Before you erlahg the rotten tomatoes and raw eggs out give me a chance to defend my honor. The task of write caching is incredibly dependent on memory management and mutating data on a very high rate. Neither of those things Erlang gives you the best tools for.

Testing C code with Erlang QuickCheck – Project-FiFo Blog

I write it in Erlang. Then wrote it in Erlang with some parts in a C. And finally decided to go all the way for C and after having a working version the results are stunningly good. Writing something in C is easy!

Writing something in C that compiles is still doable. Doing so in a way that does what you want it to do is a lot harder. And finally writing something in C that does what you think it does and not randomly segfaults or overwrites memory is close to impossible — at least so I blatantly claim without proof or citation other than an empirical study with a sample size of: When testing my code, I heavily rely on QuickCheck.


Erlang QuickCheck Tutorial

It saves me from coming up with test cases myself quixkcheck rather lets me describe what I want to happen in a greater scope rather then. I implemented the logic I want in Erlang in the quickchsck straight forward and perhaps inefficient manner I could think of.

Now, with that implementation EQC sets off to do random crazy things to the code and see if something breaks. However, that is only half the story!

Once it finds something that breaks it quuickcheck then try to simply the events that lead to the disaster and present me with a hopefully minimal test case that can trigger the problem. And this works perfectly for Erlang code! Or even C code, it can even find some memory corruption issues that way. However, — yes, I know that is what everyone was waiting for, sorry it took me so long — the quickcbeck turns completely useless when the C code segfaults and brutally murders the BEAM.

Now there are a few hurdles in the way however, EQC, to my knowledge, has no build in abstraction for remote execution. So, before you do anything else you need to be sure epmd is running on the machine you want to test on. The simplest way is just to start a erl quixkcheck in another window. Once that is done you can start rebar with rebar3 as eqc eqc —sname eqc.


Then, since EQC does not know about the second node, we extract the body of the test into its own function. The rpc module will automatically escalate the remote node crashing to a quiickcheck failure.

Roberto Aloi

And this is the big part, a segfault not goes from destroying our test system, to just a type of failure we can encounter in our testing process.

Still qujckcheck in all this worked incredibly well. Heinz, the Project-FiFo founder and fearless leader.

He loves Erlang, animals, photography and anyone who takes the time to log a detailed FiFo support ticket ;- He lives in Berlin, Germany with his long term life partner. Your email address will not be published.

The code and tests of the library can be found here: Leave a Reply Cancel reply Your email address will not be published.