Property-based testing is a powerful method to validate program correctness. It is, however, not widely use in industry as the barrier of entry can be very high. One of the hindrances is to write the generators that are needed to generate randomised input data. Program properties often take complicated data structures as inputs and, it requires a significant amount of effort to write generators for such structures in a invariant preserving way. In this paper, we suggest and formalise a new programming language \textsf{pun}; a simple functional programming with properties as a built-in mechanism for program validation. We show how to generate input for \textsf{pun} properties automatically, thus, providing the programmer with a low barrier of entry for using property-based testing. We evaluate our work a on library for binary search trees and compare the test results to a similar library in Haskell.
翻译:基于属性的测试是一种验证程序正确性的有力方法。然而,由于入门门槛较高,该方法在工业界尚未得到广泛应用。其中一个主要障碍在于需要编写用于生成随机输入数据的生成器。程序属性通常以复杂数据结构作为输入,而编写能够保持不变性约束的此类结构生成器需要耗费大量精力。本文提出并形式化了一种新型编程语言\textsf{pun},这是一种将属性作为内置程序验证机制的简单函数式编程语言。我们展示了如何自动为\textsf{pun}属性生成输入,从而降低程序员使用基于属性测试的入门门槛。我们通过二叉搜索树库对工作进行了评估,并将测试结果与类似Haskell库进行了比较。