haskell-src-match: Testing code generators piece by piece.

[ bsd3, library, testing ] [ Propose Tags ] [ Report a vulnerability ]

Matching of Haskell source fragments for code generator unit tests.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0.0.1
Change log ChangeLog.md
Dependencies base (>=4.3 && <4.15), containers, haskell-src-exts, interpolatedstring-perl6, pretty-simple, split, template-haskell, transformers [details]
License BSD-3-Clause
Copyright 2018-2019, Migamake Pte Ltd
Author Dmitry Krylov, Michal J. Gajda
Maintainer haskell-src-match@migamake.com
Category testing
Home page https://github.com/migamake/haskell-src-match#readme
Bug tracker https://github.com/migamake/haskell-src-match/issues
Source repo head: git clone https://github.com/migamake/haskell-src-match
Uploaded by MichalGajda at 2020-08-23T17:38:24Z
Distributions
Downloads 240 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-08-23 [all 1 reports]

Readme for haskell-src-match-0.0.0.1

[back to package description]

Goal

Leverage your knowledge of haskell-src-exts for parsing Haskell source files, and checking that they contain prescribed fragments. This is a general problem of functional testing of code generators: One would like to make it modular, but at the same time as close to produced source as possible. I propose that you parse a Haskell output from code generator with haskell-src-exts and then match on the produced file. Matching would be best done using TemplateHaskell. Or you may also use Haskell-src-exts here in quasiquotes. so this could be an independent library that we use to make xml-typelift and json-autotype better.

Milestones

  1. Parse input module with haskell-src-exts, and get a list of type declarations, and a list of instance declarations. (Easy)
  2. Use haskell-src-exts to get a data structure from quasiquote.
  3. Make a matching function out of a data structure returned by quasiquote.
  4. Add convenience interface to parse output file with haskell-src-exts and match patterns.
  5. Change all identifiers starting with an underbar (like _function) to be variables. Modify matching function accordingly
  6. Change all type identifiers starting with an U_ to be variables.
  7. Change all class identitifers starting with an U_ to be variables.
  8. Make a test suite for xml-typelift using this.

Possible improvements for the future

Not yet clear that we need this last feature for testing:

  • Generate variable substitutions from successful match.