[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:49:39 UTC 2010


The following commit has been merged in the master branch:
commit 241cbddb2745c00df66da0a54965b17aa6e71128
Author: John Goerzen <jgoerzen at complete.org>
Date:   Sat Dec 4 05:15:14 2004 +0100

    Working prototype
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--0.7--patch-21)

diff --git a/ChangeLog b/ChangeLog
index 2e953ea..1d11a85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,25 @@
 # arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
 #
 
+2004-12-03 22:15:14 GMT	John Goerzen <jgoerzen at complete.org>	patch-21
+
+    Summary:
+      Working prototype
+    Revision:
+      missingh--head--0.7--patch-21
+
+
+    new files:
+     testsrc/GZiptest.hs testsrc/gzfiles/.arch-ids/=id
+     testsrc/gzfiles/.arch-ids/t1.gz.id testsrc/gzfiles/t1.gz
+
+    modified files:
+     ChangeLog libsrc/MissingH/FileArchive/GZip.hs testsrc/Tests.hs
+
+    new directories:
+     testsrc/gzfiles testsrc/gzfiles/.arch-ids
+
+
 2004-12-03 22:03:40 GMT	John Goerzen <jgoerzen at complete.org>	patch-20
 
     Summary:
diff --git a/libsrc/MissingH/FileArchive/GZip.hs b/libsrc/MissingH/FileArchive/GZip.hs
index a4257b4..bd49def 100644
--- a/libsrc/MissingH/FileArchive/GZip.hs
+++ b/libsrc/MissingH/FileArchive/GZip.hs
@@ -19,6 +19,7 @@ The GZip format is described in RFC1952
 -}
 
 module MissingH.FileArchive.GZip (
+                                  decompress
                                  )
 where
 
@@ -35,11 +36,11 @@ type GZipError = String
 magic = "\x1f\x8b"
 
 -- | Flags
-fFTEXT = 1
-fFHCRC = 2
-fFEXTRA = 4
-fFNAME = 8
-fFCOMMENT = 16
+fFTEXT = 1::Int
+fFHCRC = 2::Int
+fFEXTRA = 4::Int
+fFNAME = 8::Int
+fFCOMMENT = 16::Int
 
 split1 :: String -> (Char, String)
 split1 s = (head s, tail s)
@@ -62,36 +63,36 @@ read_header s =
        if mag /= magic
           then throwError "Not a GZip file"
           else ok
-       let (method, rem) = split1 rem
+       let (method, rem2) = split1 rem
        if (ord(method) /= 8)
           then throwError "Unknown compression method"
           else ok
-       let (flag_S, rem) = split1 rem
+       let (flag_S, rem3) = split1 rem2
        let flag = ord flag_S
        -- skip modtime (4), extraflag (1), and os (1)
-       let rem = drop 6 rem
+       let rem4 = drop 6 rem3
        
-       rem <- if (flag .&. fFEXTRA /= 0)
+       rem5 <- if (flag .&. fFEXTRA /= 0)
                   -- Skip past the extra field if we have it.
-                  then do let (xlen_S, rem2) = split1 rem
-                          let (xlen2_S, rem2) = split1 rem2
+                  then do let (xlen_S, rem4a) = split1 rem4
+                          let (xlen2_S, rem4a) = split1 rem4
                           let xlen = (ord xlen_S) + 256 * (ord xlen2_S)
-                          return $ drop xlen rem2
-                  else return rem
+                          return $ drop xlen rem4a
+                  else return rem4
        
-       rem <- if (flag .&. fFNAME /= 0)
+       rem6 <- if (flag .&. fFNAME /= 0)
                   -- Skip past the null-terminated filename
-                  then return $ tail $ dropWhile (/= '\x00') rem
-                  else return rem
+                  then return $ tail $ dropWhile (/= '\x00') rem5
+                  else return rem5
 
-       rem <- if (flag .&. fFCOMMENT /= 0)
+       rem7 <- if (flag .&. fFCOMMENT /= 0)
                   -- Skip past the null-terminated comment
-                  then return $ tail $ dropWhile (/= '\x00') rem
-                  else return rem
+                  then return $ tail $ dropWhile (/= '\x00') rem6
+                  else return rem6
        
-       rem <- if (flag .&. fFHCRC /= 0)
+       rem8 <- if (flag .&. fFHCRC /= 0)
                   -- Skip past the header CRC
-                  then return $ drop 2 rem
-                  else return rem
+                  then return $ drop 2 rem7
+                  else return rem7
                   
-       return ("foo", rem)
+       return ("foo", rem8)
diff --git a/testsrc/CRC32test.hs b/testsrc/GZiptest.hs
similarity index 62%
copy from testsrc/CRC32test.hs
copy to testsrc/GZiptest.hs
index 1a3f729..a8c3d2c 100644
--- a/testsrc/CRC32test.hs
+++ b/testsrc/GZiptest.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Tests for CRC-32 module
+{- arch-tag: Tests for GZip module
 Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
 
 This program is free software; you can redistribute it and/or modify
@@ -16,21 +16,23 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 -}
 
-module CRC32test(tests) where
+module GZiptest(tests) where
 import HUnit
-import MissingH.Checksum.CRC32
-
-test_crc32 =
-    let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (crc32 inp) in
+import MissingH.FileArchive.GZip
+import System.IO
+
+test_gunzip =
+    let f fn exp = TestLabel fn $ TestCase $ 
+                   do
+                   fd <- openFile ("testsrc/gzfiles/" ++ fn) ReadMode
+                   c <- hGetContents fd
+                   assertEqual "" (Right exp) (decompress c)
+        in
         [
-         f "Empty" "" 4294967295,
-         f "1" "1" 433426081,
-         f "some numbers" "153141341309874102987412" 2083856642,
-         f "Some text" "This is a test of the crc32 thing\n" 2449124888
-
+         f "t1.gz" "Test 1"
         ]
 
-tests = TestList [TestLabel "crc32" (TestList test_crc32)
+tests = TestList [TestLabel "gunzip" (TestList test_gunzip)
 
                  ]
 
diff --git a/testsrc/Tests.hs b/testsrc/Tests.hs
index 20c7db5..85b3891 100644
--- a/testsrc/Tests.hs
+++ b/testsrc/Tests.hs
@@ -31,6 +31,7 @@ import qualified Eithertest
 import qualified ConfigParser.Parsertest
 import qualified ConfigParser.Maintest
 import qualified CRC32test
+import qualified GZiptest
 
 test1 = TestCase ("x" @=? "x")
 
@@ -46,6 +47,7 @@ tests = TestList [TestLabel "test1" test1,
                  TestLabel "Eithertest" Eithertest.tests,
                  TestLabel "ConfigParser.RunParser" ConfigParser.Parsertest.tests,
                  TestLabel "ConfigParser.Main" ConfigParser.Maintest.tests,
-                 TestLabel "CRC32test" CRC32test.tests]
+                 TestLabel "CRC32test" CRC32test.tests,
+                 TestLabel "GZiptest" GZiptest.tests]
 
 
diff --git a/testsrc/gzfiles/t1.gz b/testsrc/gzfiles/t1.gz
new file mode 100644
index 0000000..a89fb00
Binary files /dev/null and b/testsrc/gzfiles/t1.gz differ

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list