Testing of parametrically polymorphic functions is nontrivial because an inappropriate type instantiation may lead to overlooking bugs. Several studies have discussed sufficient conditions for complete testing, i.e., a set of tests that can find every incorrect input-output behavior. This paper studies finite complete testing, namely complete testing by instantiating type parameters with finite-domain types (Boolean type, in particular). The finiteness brings not only exhaustive testing but also simpler test cases and debugging than the existing state-of-the-art method, which may derive complicated types whose elements are costly or even computationally infeasible to identify. Based on the theory of parametric polymorphism, known as relational parametricity or Wadler’s free theorem, we formulate a sufficient condition for finite complete testing; moreover, we provide a transformation that yields functions more suitable for applying the theorem. Our theory only examines types and hence applies even to black-box testing. A preliminary experiment with the Haskell 98 Prelude library demonstrated the promise of the current proposal, enabling finite complete testing of 57 functions among 79 polymorphic functions.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Test Your Polymorphic Functions with Boolean Values

  • Akimasa Morihata

摘要

Testing of parametrically polymorphic functions is nontrivial because an inappropriate type instantiation may lead to overlooking bugs. Several studies have discussed sufficient conditions for complete testing, i.e., a set of tests that can find every incorrect input-output behavior. This paper studies finite complete testing, namely complete testing by instantiating type parameters with finite-domain types (Boolean type, in particular). The finiteness brings not only exhaustive testing but also simpler test cases and debugging than the existing state-of-the-art method, which may derive complicated types whose elements are costly or even computationally infeasible to identify. Based on the theory of parametric polymorphism, known as relational parametricity or Wadler’s free theorem, we formulate a sufficient condition for finite complete testing; moreover, we provide a transformation that yields functions more suitable for applying the theorem. Our theory only examines types and hence applies even to black-box testing. A preliminary experiment with the Haskell 98 Prelude library demonstrated the promise of the current proposal, enabling finite complete testing of 57 functions among 79 polymorphic functions.