Import Upstream version 20180207
[hcoop/debian/mlton.git] / regression / pack-word.sml
1 functor F (P: PACK_WORD) =
2 struct
3 val v = Word8Vector.tabulate (11, Word8.fromInt)
4
5 fun p i = print (concat [LargeWord.toString (P.subVec (v, i)), "\n"])
6
7 val _ = (p 0; p 1)
8
9 val _ =
10 List.app
11 (fn i => p i handle Subscript => print "OK\n")
12 [~1, 2, valOf Int.maxInt]
13 end
14
15 structure S = F (PackWord32Little)
16 structure S = F (PackWord32Big)
17
18 functor F (P: PACK_WORD) =
19 struct
20 val a = Word8Array.tabulate (11, Word8.fromInt)
21
22 val _ = P.update (a, 0, 0wxFFFEFDFC)
23
24 fun p i = print (concat [LargeWord.toString (P.subArr (a, i)), "\n"])
25
26 val _ = (p 0; p 1)
27
28 val _ =
29 List.app
30 (fn i => p i handle Subscript => print "OK\n")
31 [~1, 2, valOf Int.maxInt]
32 end
33
34 structure S = F (PackWord32Little)
35 structure S = F (PackWord32Big)