luqui / Djest

A programming language that deduces code from tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Djest was born as an entry into the Jan 2013 PLT Games competition, Testing The Waters (but I didn't finish in time to enter). It improves Haskell's support for automated testing, by making it so you don't have to write the code you are testing at all!

succ :: Int -> Int
succ 0 == 1
succ 1 == 2
succ 10 == 11

This is enough to have Djest deduce that succ x = x + 1.

Djest uses a Djinn-like satisfier which searches for functions of a given type. The generated functions are then tested with the test suite until one that passes all the tests is found, at which point that function is taken as its definition. If it uses the wrong function, then clearly your test suite was not comprehensive!

Generated functions are tested in roughly increasing order of complexity, so simpler functions are used in preference to more complex ones. This is what allows Djest to find succ x = x + 1 instead of

succ x = case x of
             0 -> 1
             1 -> 2
             10 -> 11
             _ -> 0

which is most likely not the function the programmer had in mind.

Djest is powerful enough to deduce the predecessor function on Church numerals, which Alonzo Church himself could not find (albeit without a computer). It handles rank n polymorphism and only finds total functions (I believe it will eventually find every non-recursive function, but I am not sure).

Check out the examples/ directory.

About

A programming language that deduces code from tests


Languages

Language:Haskell 100.0%