[erlang-questions] [ANN] Triq community fork
Tuncer Ayaz
tuncer.ayaz@REDACTED
Thu Sep 20 19:29:59 CEST 2018
We are pleased to announce the community fork of Triq.
Triq (Term Reductive Invariant Questant) is an Apache licensed QuickCheck
library for Erlang. It is a continuation and community fork of
https://github.com/krestenkrab/triq. This fork is in *no way* affiliated
with or a product of Trifork.
| Homepage | https://triq.gitlab.io
| Hex.pm | https://hex.pm/packages/triq
| Team | https://gitlab.com/triq/triq/project_members
If you use Triq and/or want to contribute, we do welcome new team members.
It's a community fork after all.
* Writing QuickCheck properties with Triq
To write properties with Triq, you just include triq.hrl:
-include_lib("triq/include/triq.hrl").
Modules compiled with the triq.hrl header auto-export all functions named
prop_* and have a function added, called check/0, which runs triq:check/1 on
all the properties in the module. Further, adding the attribute
-triq(eunit) will generate EUnit tests for all properties, turning your
module into a regular EUnit test suite.
If you use erlang.mk, you will typically want to use the built-in Triq
plugin (https://erlang.mk/guide/triq.html) to check properties. Otherwise,
we highly recommend letting Triq generate EUnit tests, thus arriving at a
demo module like this:
-module(triq_demo).
-include_lib("triq/include/triq.hrl").
-triq(eunit).
prop_append() ->
?FORALL({Xs,Ys},{list(int()),list(int())},
lists:reverse(Xs++Ys)
==
lists:reverse(Ys) ++ lists:reverse(Xs)).
Now, all you have to do is run rebar3 eunit:
$ rebar3 eunit -v
===> Verifying dependencies...
===> Compiling triq_demo
===> Performing EUnit tests...
======================== EUnit ========================
file "triq_demo.app"
application 'triq_demo'
triq_demo:5: append_test_ (module 'triq_demo')...[0.262 s] ok
[done in 0.269 s]
[done in 0.274 s]
=======================================================
Test passed.
If you use -triq({eunit, [{runs, N}]}), then Triq will do N runs for each
property in the module, which is equivalent to calling triq:check(Module,N).
This can be useful to make Triq try more (or less) cases than the default.
For advanced features, please consult the API docs.
* Obtaining Triq
Triq is available via Hex.pm and its git repository. If your build tool
supports it, we suggest to use the Hex.pm package.
| rebar.config | {deps, [triq]}
| erlang.mk | DEPS = triq
| mix.exs | {:triq, "~> 1.*"}
More information about the erlang-questions
mailing list