skip to main content
article
Public Access

A promise checked is a promise kept: inspection testing

Published:17 September 2018Publication History
Skip Abstract Section

Abstract

Occasionally, developers need to ensure that the compiler treats their code in a specific way that is only visible by inspecting intermediate or final compilation artifacts. This is particularly common with carefully crafted compositional libraries, where certain usage patterns are expected to trigger an intricate sequence of compiler optimizations – stream fusion is a well-known example.

The developer of such a library has to manually inspect build artifacts and check for the expected properties. Because this is too tedious to do often, it will likely go unnoticed if the property is broken by a change to the library code, its dependencies or the compiler. The lack of automation has led to released versions of such libraries breaking their documented promises.

This indicates that there is an unrecognized need for a new testing paradigm, inspection testing, where the programmer declaratively describes non-functional properties of an compilation artifact and the compiler checks these properties. We define inspection testing abstractly, implement it in the context of the Haskell Compiler GHC and show that it increases the quality of such libraries.

References

  1. Lennart Augustsson. 2008. djinn: Generate Haskell code from a type. http://hackage.haskell.org/package/djinn. (2008).Google ScholarGoogle Scholar
  2. Joachim Breitner. 2014. list-fusion-probe: testing list fusion for success. http://hackage.haskell.org/package/list-fusion-probe. (2014).Google ScholarGoogle Scholar
  3. Joachim Breitner. 2018. ghc-justdoit: A magic typeclass that just does it. http://hackage.haskell.org/package/ghc-justdoit. (2018).Google ScholarGoogle Scholar
  4. Manuel M. T. Chakravarty, Gabriele Keller, Simon L. Peyton Jones, and Simon Marlow. 2005. Associated types with class. In POPL. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. James Cheney and Ralf Hinze. 2003. First-Class Phantom Types. Technical Report. Cornell University.Google ScholarGoogle Scholar
  6. Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Nils Anders Danielsson and Patrik Jansson. 2004. Chasing Bottoms: A Case Study in Program Verification in the Presence of Partial and Infinite Values. In MPC (LNCS), Vol. 3125. Springer.Google ScholarGoogle ScholarCross RefCross Ref
  8. Roy Dyckhoff. 1992. Contraction-Free Sequent Calculi for Intuitionistic Logic. Journal of Symbolic Logic 57, 3 (1992).Google ScholarGoogle ScholarCross RefCross Ref
  9. Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In ESOP (LNCS), Vol. 9632. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Kenneth Foner, Hengchu Zhang, and Leonidas Lampropoulos. 2018. Keep your Laziness in Check. (2018). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Dean Herington and Simon Hegel. 2006. HUnit: A unit testing framework for Haskell. http://hackage.haskell.org/package/HUnit. (2006).Google ScholarGoogle Scholar
  12. Csongor Kiss. 2017. generic-lens: Generic data-structure operations exposed as lenses. http://hackage.haskell.org/package/generic-lens. (2017).Google ScholarGoogle Scholar
  13. Csongor Kiss, Matthew Pickering, and Toby Shaw. 2017. Deriving lenses using generics. In IFL.Google ScholarGoogle Scholar
  14. Csongor Kiss, Matthew Pickering, and Nicolas Wu. 2018. Generic Deriving of Generic Traversals. In ICFP. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. The Haskell library maintainers. 2007. containers: Assorted concrete container types. http://hackage.haskell.org/package/containers. (2007).Google ScholarGoogle Scholar
  16. José Pedro Magalhães, Atze Dijkstra, Johan Jeuring, and Andres Löh. 2010. A generic deriving mechanism for Haskell. In Haskell Symposium. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Nicholas Nethercote and Julian Seward. 2007. Valgrind: A Framework for Heavyweight Dynamic Binary Instrumentation. In Programming Language Design and Implementation (PLDI). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Bryan O'Sullivan and Tom Harper. 2017. text: An efficient packed Unicode text type. http://hackage.haskell.org/package/text-1.2.2.2. (2017).Google ScholarGoogle Scholar
  19. Will Partain. 1993. The nofib Benchmark Suite of Haskell Programs. In Functional Programming 1992 (Workshops in Computing). Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Simon L. Peyton Jones and Simon Marlow. 2002. Secrets of the Glasgow Haskell Compiler Inliner. Journal of Functional Programming 12, 5 (2002). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Simon L. Peyton Jones, Andrew Tolmach, and Tony Hoare. 2001. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Haskell Workshop.Google ScholarGoogle Scholar
  22. Tiark Rompf and Martin Odersky. 2012. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. Commun. ACM 55, 6 (2012). Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Tim Sheard and Simon L. Peyton Jones. 2002. Template meta-programming for Haskell. SIGPLAN Notices 37, 12 (2002). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Niki Vazou, Joachim Breitner, Rose Kunkel, David Van Horn, and Graham Hutton. 2018. Theorem proving for all. (2018).Google ScholarGoogle Scholar
  25. Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon L. Peyton Jones. 2014. Refinement types for Haskell. In ICFP. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Sergei Winitzki. 2001. curryhoward: Automatic code generation for Scala functions and expressions via the Curry-Howard isomorphism. https://github.com/Chymyst/curryhoward. (2001).Google ScholarGoogle Scholar

Index Terms

  1. A promise checked is a promise kept: inspection testing

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 53, Issue 7
          Haskell '18
          July 2018
          185 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/3299711
          Issue’s Table of Contents
          • cover image ACM Conferences
            Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell
            September 2018
            185 pages
            ISBN:9781450358354
            DOI:10.1145/3242744

          Copyright © 2018 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 17 September 2018

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!