Class: HaskellTestHook

Inherits:
HaskellFileHook show all
Defined in:
lib/test_hook.rb

Instance Method Summary collapse

Methods inherited from HaskellFileHook

#cleanup_raw_result, #tempfile_extension

Instance Method Details

#command_line(filename) ⇒ Object



42
43
44
# File 'lib/test_hook.rb', line 42

def command_line(filename)
  "runhaskell #{filename}"
end

#compile_file_content(req) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/test_hook.rb', line 9

def compile_file_content(req)
  <<-EOF
{-# OPTIONS_GHC -fdefer-type-errors #-}
import Test.Hspec
import Test.Hspec.Runner (hspecWith, defaultConfig, Config (configFormatter))
import Test.QuickCheck
import Test.Hspec.Formatters

import qualified Control.Exception as Exception

import Data.List

structured :: Formatter
structured = silent {
exampleSucceeded = \\p ->
  writeTerm [formatPath p, "passed", ""],
exampleFailed    = \\p result -> case result of
    (Right e) -> writeTerm [formatPath p, "failed", e]
    (Left e)  -> writeTerm [formatPath p, "failed", show e],
headerFormatter  = write $ "@@@RESULTS-START@@@[",
footerFormatter  = write $ "null]"
}
where formatPath (ps, p) = intercalate " " $ (ps ++ [p])
      writeTerm = write.(++",").show

#{req.content}
#{req.extra}
main :: IO ()
main = hspecWith defaultConfig {configFormatter = Just structured} $ do
#{req.test.lines.map {|it| '    ' + it}.join}
EOF
end

#to_structured_result(result) ⇒ Object



4
5
6
7
# File 'lib/test_hook.rb', line 4

def to_structured_result(result)
  result = result.split('@@@RESULTS-START@@@').last
  super(result).compact
end