Chapter

Implementation and Application of Functional Languages

Volume 4449 of the series Lecture Notes in Computer Science pp 217-234

Testing Properties of Generic Functions

  • Patrik JanssonAffiliated withCSE, Chalmers University of Technology
  • , Johan JeuringAffiliated withICS, Utrecht University
  • , Laurence CabendaAffiliated withCSE, Chalmers University of Technology
  • , Gerbo EngelsAffiliated withStudents of the Utrecht University Generic Programming class
  • , Jacob KleerekoperAffiliated withStudents of the Utrecht University Generic Programming class
  • , Sander MakAffiliated withStudents of the Utrecht University Generic Programming class
  • , Michiel OvereemAffiliated withStudents of the Utrecht University Generic Programming class
  • , Kees VisserAffiliated withStudents of the Utrecht University Generic Programming class

* Final gross prices may vary according to local VAT.

Get Access

Abstract

A datatype-generic function is a family of functions indexed by (the structure of) a type. Examples include equality tests, maps and pretty printers. Property based testing tools like QuickCheck and Gast support the definition of properties and test-data generators, and they check if a monomorphic property is satisfied by the test cases. Generic functions satisfy generic properties and this paper discusses specifying and testing such properties. It shows how generic properties and generators can be expressed, and explains three bugs we found and corrected in the Generic Haskell library.