DEV Community

Introduction to property based testing

Giulio Canti on March 17, 2019

In the last posts about Eq, Ord, Semigroup and Monoid we saw that instances must comply with some laws. So how can we ensure that our instances ar...
Collapse
 
tevescastro profile image
Vítor Castro

I was playing a bit with this and wondering if/how it would make sense to test a monoid for tasks. Any ideas? Particularly on generating a setoid for those types?

Collapse
 
jvanbruegge profile image
Jan van Brügge

I think you have a typo in your Monoid instance. The string should not be empty for the test to fail

Collapse
 
gcanti profile image
Giulio Canti

concat(x, empty) is equal to x + ' ' + empty by definition of concat. If x = '' then x + ' ' + empty is equal to '' + ' ' + '' which is equal to ' ' so concat(x, empty) !== x

Collapse
 
jvanbruegge profile image
Jan van Brügge

Ah, yeah, I missed the extra space in the Semigroup instance