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中同类库进行了对比。