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.
- Lennart Augustsson. 2008. djinn: Generate Haskell code from a type. http://hackage.haskell.org/package/djinn. (2008).Google Scholar
- Joachim Breitner. 2014. list-fusion-probe: testing list fusion for success. http://hackage.haskell.org/package/list-fusion-probe. (2014).Google Scholar
- Joachim Breitner. 2018. ghc-justdoit: A magic typeclass that just does it. http://hackage.haskell.org/package/ghc-justdoit. (2018).Google Scholar
- Manuel M. T. Chakravarty, Gabriele Keller, Simon L. Peyton Jones, and Simon Marlow. 2005. Associated types with class. In POPL. ACM. Google Scholar
Digital Library
- James Cheney and Ralf Hinze. 2003. First-Class Phantom Types. Technical Report. Cornell University.Google Scholar
- Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP. ACM. Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- Roy Dyckhoff. 1992. Contraction-Free Sequent Calculi for Intuitionistic Logic. Journal of Symbolic Logic 57, 3 (1992).Google Scholar
Cross Ref
- Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In ESOP (LNCS), Vol. 9632. Springer. Google Scholar
Digital Library
- Kenneth Foner, Hengchu Zhang, and Leonidas Lampropoulos. 2018. Keep your Laziness in Check. (2018). Google Scholar
Digital Library
- Dean Herington and Simon Hegel. 2006. HUnit: A unit testing framework for Haskell. http://hackage.haskell.org/package/HUnit. (2006).Google Scholar
- Csongor Kiss. 2017. generic-lens: Generic data-structure operations exposed as lenses. http://hackage.haskell.org/package/generic-lens. (2017).Google Scholar
- Csongor Kiss, Matthew Pickering, and Toby Shaw. 2017. Deriving lenses using generics. In IFL.Google Scholar
- Csongor Kiss, Matthew Pickering, and Nicolas Wu. 2018. Generic Deriving of Generic Traversals. In ICFP. ACM. Google Scholar
Digital Library
- The Haskell library maintainers. 2007. containers: Assorted concrete container types. http://hackage.haskell.org/package/containers. (2007).Google Scholar
- José Pedro Magalhães, Atze Dijkstra, Johan Jeuring, and Andres Löh. 2010. A generic deriving mechanism for Haskell. In Haskell Symposium. ACM. Google Scholar
Digital Library
- Nicholas Nethercote and Julian Seward. 2007. Valgrind: A Framework for Heavyweight Dynamic Binary Instrumentation. In Programming Language Design and Implementation (PLDI). ACM. Google Scholar
Digital Library
- 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 Scholar
- Will Partain. 1993. The nofib Benchmark Suite of Haskell Programs. In Functional Programming 1992 (Workshops in Computing). Springer. Google Scholar
Digital Library
- Simon L. Peyton Jones and Simon Marlow. 2002. Secrets of the Glasgow Haskell Compiler Inliner. Journal of Functional Programming 12, 5 (2002). Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- Tim Sheard and Simon L. Peyton Jones. 2002. Template meta-programming for Haskell. SIGPLAN Notices 37, 12 (2002). Google Scholar
Digital Library
- Niki Vazou, Joachim Breitner, Rose Kunkel, David Van Horn, and Graham Hutton. 2018. Theorem proving for all. (2018).Google Scholar
- Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon L. Peyton Jones. 2014. Refinement types for Haskell. In ICFP. ACM. Google Scholar
Digital Library
- Sergei Winitzki. 2001. curryhoward: Automatic code generation for Scala functions and expressions via the Curry-Howard isomorphism. https://github.com/Chymyst/curryhoward. (2001).Google Scholar
Index Terms
A promise checked is a promise kept: inspection testing
Recommendations
A promise checked is a promise kept: inspection testing
Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on HaskellOccasionally, 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, ...
Integrated language definition testing: enabling test-driven language development
OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applicationsThe reliability of compilers, interpreters, and development environments for programming languages is essential for effective software development and maintenance. They are often tested only as an afterthought. Languages with a smaller scope, such as ...
Testing domain-specific languages
OOPSLA '11: Proceedings of the ACM international conference companion on Object oriented programming systems languages and applications companionThe Spoofax testing language provides a new approach to testing domain-specific languages as they are developed. It allows test cases to be written using fragments of the language under test, providing full IDE support for writing test cases and ...







Comments