Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay evaluation of it blocks until test execution #73

Closed
wants to merge 1 commit into from

Conversation

zyla
Copy link
Contributor

@zyla zyla commented Sep 2, 2018

Motivation:

Sometimes even pure code can have crashes (example: messing up the FFI when binding to a JavaScript library). I'd argue that test suites should deal with that, as they are a development tool.

Consider this test case:

spec :: Spec Unit
spec = do
  it "failure" do 
    unsafeCrashWith "failure"

Any program containing this definition will crash while loading the module, before it even calls main, because unsafeCrashWith is not under any lambda, so it's evaluated immediately. The same example would work just fine (i.e. the crash would be caught by test runner) in Haskell and hspec, thanks to lazy evaluation.

We can emulate the desired behavior using a hack that effectively wraps every it block in a lambda in the generated code.

This would be a breaking change. "Normal" test code should compile just fine, but code that uses it in a generic way may need some eta-expansion to deal with the constrained type.

@safareli safareli mentioned this pull request Jan 10, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant