Abstract
We present a technique for automatically deriving test data generators from a predicate expressed as a Boolean function. The distribution of these generators is uniform over values of a given size. To make the generation efficient we rely on laziness of the predicate, allowing us to prune the space of values quickly. In contrast, implementing test data generators by hand is labour intensive and error prone. Moreover, handwritten generators often have an unpredictable distribution of values, risking that some values are arbitrarily underrepresented. We also present a variation of the technique where the distribution is skewed in a limited and predictable way, potentially increasing the performance. Experimental evaluation of the techniques shows that the uniform derived generators are much easier to define than hand-written ones, and their performance, while lower, is adequate for some realistic applications.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Arts, T., et al.: Testing Telecoms Software with Quviq QuickCheck. In: Proc. 2006 Erlang Workshop, pp. 2–10. ACM (2006)
Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated Testing Based on Java Predicates. In: Proc. 2002 Inl. Symp. Software Testing and Analysis (ISSTA 2002), pp. 123–133. ACM (2002)
Christiansen, J., Fischer, S.: EasyCheck: test data for free. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 322–336. Springer, Heidelberg (2008)
Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: ICFP 2000, pp. 268–279. ACM (2000)
Duregard, J., Jansson, P., Wang, M.: FEAT: functional enumeration of algebraic types. In: Proc. 2012 Symp. Haskell, pp. 61–72. ACM (2012)
Feldt, R., Poulding, S.: Finding Test Data with Specific Properties viaMetaheuristic Search. In: Proc. Intl. Symp. Software Reliability Engineering (ISSRE). IEEE (2013)
Fischer, S., Kiselyov, O., Shan, C.C.: Purely functional lazy nondeterministic programming. J. Funct. Program. 21(4-5), 413–465 (2011)
Grygiel, K., Lescanne, P.: Counting and generating lambda terms. J. Funct. Program. 23, 594–628 (2013)
Palka, M.H.: Testing an Optimising Compiler by Generating Random Lambda Terms. Licentiate Thesis. Chalmers University of Technology, Gothenburg, Sweden (2012)
Runciman, C., Naylor, M., Lindblad, F.: Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In: Haskell 2008, pp. 37–48. ACM (2008)
Rodriguez Yakushev, A., Jeuring, J.: Enumerating Well-Typed Terms Generically. In: Schmid, U., Kitzelmann, E., Plasmeijer, R. (eds.) AAIP 2009. LNCS, vol. 5812, pp. 93–116. Springer, Heidelberg (2010)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2014 Springer International Publishing Switzerland
About this paper
Cite this paper
Claessen, K., Duregård, J., Pałka, M.H. (2014). Generating Constrained Random Data with Uniform Distribution. In: Codish, M., Sumii, E. (eds) Functional and Logic Programming. FLOPS 2014. Lecture Notes in Computer Science, vol 8475. Springer, Cham. https://doi.org/10.1007/978-3-319-07151-0_2
Download citation
DOI: https://doi.org/10.1007/978-3-319-07151-0_2
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-07150-3
Online ISBN: 978-3-319-07151-0
eBook Packages: Computer ScienceComputer Science (R0)