sdiehl / write-you-a-haskell

Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)
MIT License
3.34k stars 256 forks source link

test cases for poly #45

Open sdiehl opened 9 years ago

sdiehl commented 9 years ago

Add test cases to test.ml for pathological cases on pull request #40 issue

chsievers commented 9 years ago

I'd rather call them non-trivial.

The example

\f n -> if True then n else (f (n+1))

is just a trimmed down version of the useful function

let rec findfrom p n = if (p n) then n else (findfrom p (n+1))

I'd preserve "pathological" for cases like

let c x y = if True then x else y
c(c(c(c(c(c(c(c(c c))))))))

(which always worked).

sdiehl commented 9 years ago

That's fair, I'll start doing what GHC does and add a should_fail and should_pass folder for the failure cases. 53f1e5c

So now to test for regressions, it's just:

$ poly test test/should_fail/test_if.ml

For the more complicated ProtoHaskell compiler, I already use the tasty golden test runner. But it's a little heavy for these little toy language though.