Abstract
This paper is concerned with testing properties of polymorphic functions. The problem is that testing can only be performed on specific monomorphic instances, whereas parametrically polymorphic functions are expected to work for any type. We present a schema for constructing a monomorphic instance for a polymorphic property, such that correctness of that single instance implies correctness for all other instances. We also give a formal definition of the class of polymorphic properties the schema can be used for. Compared to the standard method of testing such properties, our schema leads to a significant reduction of necessary test cases.
Keywords
References
Abbott, M., Altenkirch, T., Ghani, N.: Categories of containers. In: Gordon, A.D. (ed.) FOSSACS 2003. LNCS, vol. 2620, pp. 23–38. Springer, Heidelberg (2003)
Arts, T., Hughes, J., Johansson, J., Wiger, U.: Testing telecoms software with quviq QuickCheck. In: Proc. of the 2006 ACM SIGPLAN workshop on Erlang, pp. 2–10. ACM, New York (2006)
Bagge, A.H., David, V., Haveraaen, M.: Axiom-based testing for C++. In: Companion to the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications, pp. 721–722. ACM, New York (2008)
Bird, R., de Moor, O.: Algebra of programming. Prentice-Hall, Englewood Cliffs (1997)
Böhm, C., Berarducci, A.: Automatic synthesis of typed lambda-programs on term algebras. Theoretical Computer Science 39(2-3), 135–154 (1985)
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: Proc. of the fifth ACM SIGPLAN international conference on Functional programming, pp. 268–279. ACM, New York (2000)
Danielsson, N.A., Gibbons, J., Hughes, J., Jansson, P.: Fast and loose reasoning is morally correct. In: POPL 2006, pp. 206–217. ACM Press, New York (2006)
Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: Proc. of the 3rd ACM SIGPLAN international conference on Principles and practice of declarative programming, pp. 162–174. ACM, New York (2001)
Davey, B.A., Priestley, H.A.: Introduction to lattices and order. Cambridge University Press, Cambridge (2002)
Day, N.A., Launchbury, J., Lewis, J.: Logical abstractions in Haskell. In: Proc. of the 1999 Haskell Workshop (1999)
Fegaras, L., Sheard, T.: Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In: Proc. of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 284–294. ACM, New York (1996)
Fokkinga, M.M.: Datatype laws without signatures. Mathematical Structures in Computer Science 6(01), 1–32 (1996)
Gill, A., Launchbury, J., Peyton Jones, S.L.: A short cut to deforestation. In: Proc. of the conference on Functional programming languages and computer architecture, pp. 223–232. ACM, New York (1993)
Hinze, R.: Church numerals, twice! J. of Funct. Program 15(01), 1–13 (2005)
Hoffman, D., Nair, J., Strooper, P.: Testing generic Ada packages with APE. Ada Lett. XVIII(6), 255–262 (1998)
Jansson, P., Jeuring, J., Cabenda, L., Engels, G., Kleerekoper, J., Mak, S., Overeem, M., Visser, K.: Testing properties of generic functions. In: Horváth, Z., Zsók, V., Butterfield, A. (eds.) IFL 2006. LNCS, vol. 4449, pp. 217–234. Springer, Heidelberg (2007)
Johann, P., Voigtländer, J.: Free theorems in the presence of seq. In: Proc. of the 31st ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 99–110. ACM, New York (2004)
Knuth, D.E.: The Art of Computer Programming, 2nd edn. Sorting and Searching, vol. 3. Addison-Wesley Professional, Reading (1998)
Nilsson, R.: ScalaCheck (2009), http://code.google.com/p/scalacheck/
Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization and concretization. Higher-Order Symbol. Comput. 19(1), 125–162 (2006)
Reynolds, J.C.: Definitional interpreters for Higher-Order programming languages. Higher Order Symbol. Comput. 11(4), 363–397 (1998)
Runciman, C., Naylor, M., Lindblad, F.: Smallcheck and lazy smallcheck: automatic exhaustive testing for small values. In: Proc. of the first ACM SIGPLAN symposium on Haskell, pp. 37–48. ACM, New York (2008)
Saff, D.: Theory-infected: or how i learned to stop worrying and love universal quantification. In: Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companion, pp. 846–847. ACM, New York (2007)
Sheeran, M.: Hardware design and functional programming: a perfect match. Talk at Hardware Design and Functional Languages (2007)
Svenningsson, J.: Shortcut fusion for accumulating parameters & zip-like functions. In: Proc. of the seventh ACM SIGPLAN international conference on Functional programming, vol. 37, pp. 124–132. ACM, New York (2002)
Tillmann, N., Schulte, W.: Parameterized unit tests. SIGSOFT Softw. Eng. Notes 30(5), 253–262 (2005)
Voigtländer, J.: Much ado about two (pearl): a pearl on parallel prefix computation. SIGPLAN Not. 43(1), 29–35 (2008)
Wadler, P.: Theorems for free! In: Proc. of the fourth international conference on Functional programming languages and computer architecture, pp. 347–359. ACM, New York (1989)
Washburn, G., Weirich, S.: Boxes go bananas: encoding higher-order abstract syntax with parametric polymorphism. In: Proc. of the eighth ACM SIGPLAN international conference on Functional programming, pp. 249–262. ACM, New York (2003)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bernardy, JP., Jansson, P., Claessen, K. (2010). Testing Polymorphic Properties. In: Gordon, A.D. (eds) Programming Languages and Systems. ESOP 2010. Lecture Notes in Computer Science, vol 6012. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-11957-6_8
Download citation
DOI: https://doi.org/10.1007/978-3-642-11957-6_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-11956-9
Online ISBN: 978-3-642-11957-6
eBook Packages: Computer ScienceComputer Science (R0)