Upgrade to Pro — share decks privately, control downloads, hide ads and more …

test.check + core.logic: Generating the tests. And the solutions.

test.check + core.logic: Generating the tests. And the solutions.

Nicolás Berger

July 08, 2015
Tweet

More Decks by Nicolás Berger

Other Decks in Programming

Transcript

  1. Core.logic • miniKanren implementation: “an embedded DSL for logic programming”

    • “kanren”: “relation” in japanese • Declarative programming→ WHAT not HOW “Separate the search algorithm from the logical construction”
  2. test.check • Property-based testing • Generate → Run → Shrink

    • Generate: random generators, use existing or combine to create new ones • Run: Assert properties for every input • Shrink: Find a smaller input that still fails Do not write the tests. Generate them!
  3. Exemplos de core.logic • Puzzles (sudoku, who owns the zebra?)

    • Genealogic tree • Knapsack • Malware & threat analysis (threatgrid) • Static code analyzer (kibit) • Type inferencer (lambda calculus)
  4. Links / Referencias • John Hughes - Testing the Hard

    Stuff and Staying Sane https://www.youtube.com/watch?v=zi0rHwfiX1Q • David Nolen https://skillsmatter.com/skillscasts/3553-the-refined-clojurist • Zebra puzzle: https://github.com/swannodette/logic-tutorial#zebras • https://github.com/jonase/kibit • https://github.com/frenchy64/Logic-Starter/wiki • http://minikanren.org/ • http://yellerapp.com/posts/2015-04-13-effective-test-check.html • http://www.philandstuff.com/slides/2014/euroclojure.html • http://blog.guillermowinkler.com/blog/2015/04/12/verifying-state-machine-behavior-us ing-test-dot-check/ • http://stackoverflow.com/questions/28467011/what-are-the-main-technical-difference s-between-prolog-and-minikanren-with-resp