Move hash001 to base/tests
authorIan Lynagh <igloo@earth.li>
Sat, 19 Nov 2011 23:13:30 +0000 (23:13 +0000)
committerIan Lynagh <igloo@earth.li>
Sat, 19 Nov 2011 23:13:30 +0000 (23:13 +0000)
tests/all.T
tests/hash001.hs [new file with mode: 0644]

index fdc34f7..e46fdb2 100644 (file)
@@ -18,4 +18,5 @@ test('unicode002',
      [''])
 test('data-fixed-show-read', normal, compile_and_run, [''])
 test('showDouble', normal, compile_and_run, [''])
+test('hash001', normal, compile_and_run, [''])
 
diff --git a/tests/hash001.hs b/tests/hash001.hs
new file mode 100644 (file)
index 0000000..727f488
--- /dev/null
@@ -0,0 +1,14 @@
+import Data.HashTable
+import qualified Data.HashTable as HT
+
+test :: Int -> IO ()
+test n = do ht <- new (==) hashInt
+            sequence_ [ insert ht key 0 | key <- [0..n]]
+            sequence_ [ insert ht key 1 | key <- [0..n]]
+          
+            let check key = do (Just val) <- HT.lookup ht key
+                               if val==1 then return () else putStrLn $ show key 
+          
+            sequence_ [ check key | key <- [0..n]]
+
+main = test 2048