[Pkg-haskell-commits] [SCM] HDBC ODBC support branch, master, updated. debian/2.2.0.0-3-11-g2ee539a

John Goerzen jgoerzen at complete.org
Wed Feb 17 21:28:15 UTC 2010


The following commit has been merged in the master branch:
commit 3c4ef31af2a74c9e6686f85be89688b64701135f
Author: John Goerzen <jgoerzen at complete.org>
Date:   Wed Feb 17 15:11:19 2010 -0600

    Revert "Imported Upstream version 2.2.0.0"
    
    This reverts commit c29eb15f9939f5f0b65cf5602884c81ad2c8854e.

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..45c85c9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+all: setup
+	@echo "Please use Cabal to build this package; not make."
+	./setup configure
+	./setup build
+
+setup: Setup.hs
+	ghc --make -package Cabal -o setup Setup.hs
+
+install: setup
+	./setup install
+
+clean:
+	-runghc Setup.hs clean
+	-rm -rf html `find . -name "*.o"` `find . -name "*.hi" | grep -v debian` \
+		`find . -name "*~" | grep -v debian` *.a setup dist testsrc/runtests \
+		local-pkg doctmp
+	-rm -rf testtmp/* testtmp*
+
+.PHONY: test
+test: test-ghc test-hugs
+	@echo ""
+	@echo "All tests pass."
+
+test-hugs: setup
+	@echo " ****** Running hugs tests"
+	./setup configure -f buildtests --hugs --extra-include-dirs=/usr/lib/hugs/include
+	./setup build
+	runhugs -98 +o -P$(PWD)/dist/scratch:$(PWD)/dist/scratch/programs/runtests: \
+		dist/scratch/programs/runtests/Main.hs
+
+test-ghc: setup
+	@echo " ****** Building GHC tests"
+	./setup configure -f buildtests
+	./setup build
+	@echo " ****** Running GHC tests"
+	./dist/build/runtests/runtests
diff --git a/COPYING b/testsrc/COPYING
similarity index 100%
copy from COPYING
copy to testsrc/COPYING
diff --git a/testsrc/COPYRIGHT b/testsrc/COPYRIGHT
new file mode 100644
index 0000000..891207f
--- /dev/null
+++ b/testsrc/COPYRIGHT
@@ -0,0 +1,4 @@
+Copyright (c) 2005 John Goerzen
+
+Please see COPYING for the license.
+
diff --git a/testsrc/TestTime.hs b/testsrc/TestTime.hs
new file mode 100644
index 0000000..1c4131f
--- /dev/null
+++ b/testsrc/TestTime.hs
@@ -0,0 +1,99 @@
+module TestTime(tests) where
+import Test.HUnit
+import Database.HDBC
+import TestUtils
+import Control.Exception
+import Data.Time
+import Data.Time.LocalTime
+import Data.Time.Clock.POSIX
+import Data.Maybe
+import Data.Convertible
+import SpecificDB
+import System.Locale
+import qualified System.Time as ST
+
+instance Eq ZonedTime where
+    a == b = zonedTimeToUTC a == zonedTimeToUTC b &&
+             zonedTimeZone a == zonedTimeZone b
+
+testZonedTime :: ZonedTime
+testZonedTime = fromJust $ parseTime defaultTimeLocale (iso8601DateFormat (Just "%T %z"))
+                 "1989-08-01 15:33:01 -0500"
+
+testZonedTimeFrac :: ZonedTime
+testZonedTimeFrac = fromJust $ parseTime defaultTimeLocale (iso8601DateFormat (Just "%T%Q %z"))
+                    "1989-08-01 15:33:01.536 -0500"
+
+
+rowdata t = [[SqlInt32 100, toSql t, SqlNull]]
+
+testDTType inputdata convToSqlValue = dbTestCase $ \dbh ->
+    do run dbh ("CREATE TABLE hdbctesttime (testid INTEGER PRIMARY KEY NOT NULL, \
+                \testvalue " ++ dateTimeTypeOfSqlValue value ++ ")") []
+       finally (testIt dbh) (do commit dbh
+                                run dbh "DROP TABLE hdbctesttime" []
+                                commit dbh
+                            )
+    where testIt dbh =
+              do run dbh "INSERT INTO hdbctesttime (testid, testvalue) VALUES (?, ?)"
+                     [iToSql 5, value]
+                 commit dbh
+                 r <- quickQuery' dbh "SELECT testid, testvalue FROM hdbctesttime" []
+                 case r of
+                   [[testidsv, testvaluesv]] -> 
+                       do assertEqual "testid" (5::Int) (fromSql testidsv)
+                          assertEqual "testvalue" inputdata (fromSql testvaluesv)
+          value = convToSqlValue inputdata
+
+mkTest label inputdata convfunc =
+    TestLabel label (testDTType inputdata convfunc)
+
+tests = TestList $
+    ((TestLabel "Non-frac" $ testIt testZonedTime) :
+     if supportsFracTime then [TestLabel "Frac" $ testIt testZonedTimeFrac] else [])
+
+testIt baseZonedTime = 
+    TestList [mkTest "Day" baseDay toSql,
+              mkTest "TimeOfDay" baseTimeOfDay toSql,
+              mkTest "ZonedTimeOfDay" baseZonedTimeOfDay toSql,
+              mkTest "LocalTime" baseLocalTime toSql,
+              mkTest "ZonedTime" baseZonedTime toSql,
+              mkTest "UTCTime" baseUTCTime toSql,
+              mkTest "DiffTime" baseDiffTime toSql,
+              mkTest "POSIXTime" basePOSIXTime posixToSql,
+              mkTest "ClockTime" baseClockTime toSql,
+              mkTest "CalendarTime" baseCalendarTime toSql,
+              mkTest "TimeDiff" baseTimeDiff toSql
+             ]
+    where 
+      baseDay :: Day
+      baseDay = localDay baseLocalTime
+
+      baseTimeOfDay :: TimeOfDay
+      baseTimeOfDay = localTimeOfDay baseLocalTime
+
+      baseZonedTimeOfDay :: (TimeOfDay, TimeZone)
+      baseZonedTimeOfDay = fromSql (SqlZonedTime baseZonedTime)
+
+      baseLocalTime :: LocalTime
+      baseLocalTime = zonedTimeToLocalTime baseZonedTime
+
+      baseUTCTime :: UTCTime
+      baseUTCTime = convert baseZonedTime
+
+      baseDiffTime :: NominalDiffTime
+      baseDiffTime = basePOSIXTime
+
+      basePOSIXTime :: POSIXTime
+      basePOSIXTime = convert baseZonedTime
+
+      baseTimeDiff :: ST.TimeDiff
+      baseTimeDiff = convert baseDiffTime
+
+      -- No fractional parts for these two
+
+      baseClockTime :: ST.ClockTime
+      baseClockTime = convert testZonedTime
+
+      baseCalendarTime :: ST.CalendarTime
+      baseCalendarTime = convert testZonedTime

-- 
HDBC ODBC support



More information about the Pkg-haskell-commits mailing list