summaryrefslogtreecommitdiff
path: root/tests/general/random.icn
blob: 2d37d1d7768fb981a645202212eab2cac48f4963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#SRC: JCON

#  test of random selection
#  (sets and tables are commented out because
#   v9 and jcon select different elements)

record r10(a,b,c,d,e,f,g,h,i,j)

procedure main()
   local r

   rtest()
   r := &random

   rtest()

   &random := 0
   rtest()

   &random := r
   rtest()

   &random := 11213
   rtest()
end

procedure rtest()
   local i
   static L, S, T, R
   initial {
      R := r10(1,2,3,4,5,6,7,8,9,10)
      L := []
      T := table()
      every i := 1 to 100 do {
         put(L, i)
	 T[i] := -i
      }
      S := set(L)
   }

   write()
   write(right(&random,10), "  i  ", ?9999)
   write(right(&random,10), "  i  ", ?9999)
   write(right(&random,10), "  r  ", integer(10000 * ?0))
   write(right(&random,10), "  r  ", integer(10000 * ?0))
   write(right(&random,10), "  s  ", ?"abcdefghijklmnopqrstuvwxyz")
   write(right(&random,10), "  s  ", ?"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
   write(right(&random,10), "  c  ", ?&lcase)
   write(right(&random,10), "  c  ", ?&ucase)
   write(right(&random,10), "  L  ", ?L)
   write(right(&random,10), "  L  ", ?L)
   write(right(&random,10), "  R  ", ?R)
   write(right(&random,10), "  R  ", ?R)
#   write(right(&random,10), "  S  ", ?S)
#   write(right(&random,10), "  S  ", ?S)
#   write(right(&random,10), "  T  ", ?T)
#   write(right(&random,10), "  T  ", ?T)
   return
end