File: HUnitTestExc.lhs

package info (click to toggle)
hunit 1.0-8
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 172 kB
  • ctags: 15
  • sloc: haskell: 577; makefile: 74
file content (39 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
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
HUnitTestExc.lhs  --  test for HUnit, using Haskell language system "Exc"

$Id: HUnitTestExc.lhs,v 1.1 2002/02/19 17:12:47 heringto Exp $

> module Main (main) where

> import HUnit
> import HUnitTestBase
> import qualified Exception (assert)


 assertionMessage = "HUnitTestExc.lhs:13: Assertion failed\n"
 assertion = Exception.assert False (return ())



> main = runTestTT (test [baseTests, excTests])

> excTests = test [

    -- Hugs and GHC don't currently catch arithmetic exceptions.
   "div by 0" ~:
     expectUnspecifiedError (TestCase ((3 `div` 0) `seq` return ())),

    -- GHC doesn't currently catch array-related exceptions.
   "array ref out of bounds" ~:
     expectUnspecifiedError (TestCase (... `seq` return ())),

>   "error" ~:
>     expectError "error" (TestCase (error "error")),

>   "tail []" ~:
>     expectUnspecifiedError (TestCase (tail [] `seq` return ()))

   -- Hugs doesn't provide `assert`.
   "assert" ~:
     expectError assertionMessage (TestCase assertion)

>  ]