Skip to main content

Automatic Testing of Higher Order Functions

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNPSE,volume 4279)

Abstract

This paper tackles a problem often overlooked in functional programming community: that of testing. Fully automatic test tools like Quickcheck and G ∀  ST can test first order functions successfully. Higher order functions, HOFs, are an essential and distinguishing part of functional languages. Testing HOFs automatically is still troublesome since it requires the generation of functions as test argument for the HOF to be tested. Also the functions that are the result of the higher order function needs to be identified. If a counter example is found, the generated and resulting functions should be printed, but that is impossible in most functional programming languages. Yet, bugs in HOFs do occur and are usually more subtle due to the high abstraction level.

In this paper we present an effective and efficient technique to test higher order functions by using intermediate data types. Such a data type mimics and controls the structure of the function to be generated. A simple additional function transforms this data structure to the function needed. We use a continuation based parser library as main example of the tests. Our automatic testing method for HOFs reveals errors in the library that was used for a couple of years without problems.

Keywords

  • Data Type
  • Automatic Test
  • Functional Programming
  • Generate Test Case
  • High Order Function

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (Canada)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (Canada)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Alimarine, A., Plasmeijer, R.: A Generic Programming Extension for Clean. In: Arts, T., Mohnen, M. (eds.) IFL 2002. LNCS, vol. 2312, pp. 168–185. Springer, Heidelberg (2002)

    CrossRef  Google Scholar 

  2. Claessen, K., Hughes, J.: QuickCheck: A lightweight Tool for Random Testing of Haskell Programs. In: ICFP, pp. 268–279. ACM, New York (2000)

    CrossRef  Google Scholar 

  3. Danvy, O., Nielsen, L.R.: Defunctionalization at Work. In: PPDP 2001 Proceedings, pp. 162–174 (2001)

    Google Scholar 

  4. Koopman, P., Plasmeijer, R.: Efficient Combinator Parsers. In: Hammond, K., Davie, T., Clack, C. (eds.) IFL 1998. LNCS, vol. 1595, pp. 120–136. Springer, Heidelberg (1999)

    CrossRef  Google Scholar 

  5. Koopman, P., Alimarine, A., Tretmans, J., Plasmeijer, R.: Gast: Generic Automated Software Testing. In: Peña, R., Arts, T. (eds.) IFL 2002. LNCS, vol. 2670, pp. 84–100. Springer, Heidelberg (2003)

    CrossRef  Google Scholar 

  6. Koopman, P., Plasmeijer, R.: Generic Generation of Elements of Types. In: Sixth Symposium on Trends in Functional Programming (TFP 2005) (2005)

    Google Scholar 

  7. Malcom, G.: Algebraic Data Types and Program Transformations, Thesis (1990)

    Google Scholar 

  8. Plasmeijer, R., van Eekelen, M.: Concurrent Clean Language Report (version 2.1.1) (2005), www.cs.ru.nl/~clean

  9. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation 11(4), 363–397 (1998); Reprinted from the Proceedings of the 25th ACM National Conference (1972)

    CrossRef  MATH  Google Scholar 

  10. Wadler, P.: Monads for functional programming. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925. Springer, Heidelberg (1995)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Koopman, P., Plasmeijer, R. (2006). Automatic Testing of Higher Order Functions. In: Kobayashi, N. (eds) Programming Languages and Systems. APLAS 2006. Lecture Notes in Computer Science, vol 4279. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11924661_9

Download citation

  • DOI: https://doi.org/10.1007/11924661_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-48937-5

  • Online ISBN: 978-3-540-48938-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics