[commit: array] master: Move test array01 into the array package (c0fd46b)
Ian Lynagh
igloo at earth.li
Sun Feb 26 19:53:08 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/array
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c0fd46b6f71f830e4cf8b8e2259ba0097184a3ef
>---------------------------------------------------------------
commit c0fd46b6f71f830e4cf8b8e2259ba0097184a3ef
Author: Ian Lynagh <igloo at earth.li>
Date: Sun Feb 26 18:43:18 2012 +0000
Move test array01 into the array package
>---------------------------------------------------------------
tests/all.T | 1 +
tests/array001.hs | 34 ++++++++++++++++++++++++++++++++++
tests/array001.stdout | 2 ++
3 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/tests/all.T b/tests/all.T
index 2dd8f0b..73e3b66 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -1,4 +1,5 @@
test('T2120', normal, compile_and_run, [''])
test('largeArray', normal, compile_and_run, [''])
+test('array001', extra_clean(['array001.data']), compile_and_run, [''])
diff --git a/tests/array001.hs b/tests/array001.hs
new file mode 100644
index 0000000..b5839b9
--- /dev/null
+++ b/tests/array001.hs
@@ -0,0 +1,34 @@
+-- !!! Testing that #4827 is fixed (hPutArray/hGetArray use count argument)
+module Main(main) where
+
+import Control.Monad
+
+import Data.Array.MArray
+import Data.Array.IO
+
+import System.IO
+
+main :: IO ()
+main = do
+ the_array <- newListArray (0, 11) [1..12]
+
+ -- Write out almost all of the array
+ h_out <- openBinaryFile "array001.data" WriteMode
+ hPutArray h_out the_array 11
+ hClose h_out
+
+
+ the_array <- newListArray (0, 11) [0 | i <- [1..12]]
+
+ -- Read in almost all of the array
+ h_in <- openBinaryFile "array001.data" ReadMode
+ wrote_size <- hFileSize h_in
+ hGetArray h_in the_array 10
+ hClose h_in
+
+
+ read_elems <- getElems the_array
+
+
+ print wrote_size -- Bytes written, should == 11
+ print read_elems -- Bytes read, should match written array in first 10 bytes, be 0 afterwards
diff --git a/tests/array001.stdout b/tests/array001.stdout
new file mode 100644
index 0000000..7c9b768
--- /dev/null
+++ b/tests/array001.stdout
@@ -0,0 +1,2 @@
+11
+[1,2,3,4,5,6,7,8,9,10,0,0]
More information about the Cvs-libraries
mailing list