Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | open Array2 |
2 | ||
3 | val x = ref 0 | |
4 | ||
5 | val i2s = Int.toString | |
6 | ||
7 | fun test trv = | |
8 | let | |
9 | val a = | |
10 | tabulate trv | |
11 | (3, 4, fn (r, c) => | |
12 | (x := !x + 1 | |
13 | ; concat["(", i2s r, ", ", i2s c, ", ", i2s(!x), ")"])) | |
14 | val _ = app trv (fn s => (print s; print "\n")) a | |
15 | in () | |
16 | end | |
17 | ||
18 | val _ = (test RowMajor; test ColMajor) | |
19 | ||
20 | (* Check that Size is correctly raised when constructing large arrays. *) | |
21 | val m = valOf Int.maxInt | |
22 | ||
23 | val _ = | |
24 | (array (m, 2, 13) | |
25 | ; print "FAIL") | |
26 | handle Size => print "OK" | |
27 | ||
28 | val _ = | |
29 | (tabulate RowMajor (m, 2, fn _ => 13) | |
30 | ; print "FAIL") | |
31 | handle Size => print "OK\n" |