Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test for epochTime

  • Loading branch information...
commit 125ff41ecf41e571cd0391025ce040e759912c75 1 parent a071b09
@jystic authored
View
1  .gitignore
@@ -1,3 +1,4 @@
/dist/
+/test/dist/
*.swp
View
33 test/Tests.hs
@@ -0,0 +1,33 @@
+{-# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #-}
+
+import Test.Framework.TH
+import Test.Framework.Providers.HUnit
+import Test.HUnit
+
+import Control.Monad
+
+import System.PosixCompat (usingPortableImpl)
+import qualified System.Posix.Time as Time
+import qualified System.PosixCompat.Time as CompatTime
+
+main = $(defaultMainGenerator)
+
+case_running_portable_build = assertBool msg usingPortableImpl
+ where msg = "tests are only valid when run against the portable build\n" ++
+ "try rebuilding unix-compat using -fportable"
+
+
+case_epochTime = do
+ time <- Time.epochTime
+ compatTime <- CompatTime.epochTime
+ assertWithin 1 time compatTime
+
+
+assertWithin delta expected actual =
+ assertBool msg ok
+ where
+ ok = abs (expected - actual) <= delta
+ msg = "expected: " ++ show expected ++
+ " ±" ++ show delta ++
+ "\n but got: " ++ show actual
+
View
9 test/run-tests.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+test_dir=$(dirname $0)
+cd $test_dir
+
+cabal clean &&
+cabal configure --disable-optimization &&
+cabal build &&
+./dist/build/testsuite/testsuite
View
24 test/unix-compat-testsuite.cabal
@@ -0,0 +1,24 @@
+name: unix-compat-testsuite
+version: 0.1
+build-type: Simple
+cabal-version: >= 1.6
+
+Executable testsuite
+ main-is: Tests.hs
+
+ build-depends:
+ base == 4.*,
+ unix == 2.4.*,
+ unix-compat == 0.2.*
+
+ build-depends:
+ HUnit,
+ test-framework,
+ test-framework-hunit,
+ test-framework-th
+
+ -- The test suite must be run on POSIX
+ -- so that portable functions can be
+ -- compared to the real thing.
+ if os(windows)
+ buildable: False
Please sign in to comment.
Something went wrong with that request. Please try again.