Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/tests/conformance98/BinArray/test2/Main.hs.unused

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


import NHC.Binary
import NHC.BinArray

main = do
  let ws = words "This is a simple test."

  putStrLn (head ws)

  ba <- newBinArray 42 "unused"

  indices <- mapM (intoBinArray ba) ws
  check "BinArray 1 " (indices == [0 .. length ws - 1])
  mapM_ (\i-> do x <- fromBinArray ba i; putStrLn x) indices


  putBinArray "test2.dat" ba
  ba2 <- getBinArray "test2.dat"
  ws2 <- mapM (fromBinArray ba2) (reverse [0 .. length ws - 1])

  putStrLn (head (reverse ws2))
  mapM_ (\i-> do x <- fromBinArray ba2 i; putStrLn x) indices

  check "BinArray 2 " (reverse ws2 == ws)

 where
  check m b = putStrLn (m ++ if b then "ok" else "broken")

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].