[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / interpreter / test / runtime / r007.hs
1 --!!! Testing Immutable Arrays (part 1)
2
3 import Array
4
5 a1 :: Array Int Int
6 a1 = array (1,10) [ (i,i*i) | i <- [1..10] ]
7
8
9 test1 = bounds a1
10 test2 = assocs a1
11 test3 = indices a1
12 test4 = elems a1
13
14 test5 = a1 // [(3,3),(4,4)]
15
16 -- note duplicate value and absent value
17 a1' :: Array Int Char
18 a1' = array (1,3) [(1,'a'), (1,'b'), (3,'c')]
19
20 test6 = a1' ! 1 -- duplicate array index
21 test7 = a1' ! 2 -- undefined array element
22 test8 = a1' ! 3 -- 'c'
23
24 test10 = a1 ! 0   -- should fail
25 test11 = a1 ! 11  -- should fail
26 test12 = [ a1 ! i | i <- [1..10] ]
27