/
rand.t
60 lines (46 loc) · 962 Bytes
/
rand.t
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
60
#!./parrot
# Copyright (C) 2009-2010, Parrot Foundation.
=head1 NAME
t/library/rand.t
=head1 DESCRIPTION
Test the Math::Rand PBC
=head1 SYNOPSIS
% prove t/library/rand.t
=cut
.sub main :main
load_bytecode 'Math/Rand.pbc'
.include 'test_more.pir'
plan(7)
test_rand_srand()
test_rand_max()
.end
.sub test_rand_srand
.local pmc rand
rand = get_global [ 'Math'; 'Rand' ], 'rand'
.local pmc srand
srand = get_global [ 'Math'; 'Rand' ], 'srand'
$I0 = rand()
is($I0,16838)
$I0 = rand()
is($I0,5758)
$I0 = rand()
is($I0,10113)
$I0 = rand()
is($I0,17515)
srand(1)
$I0 = rand()
is($I0,16838)
$I0 = rand()
is($I0,5758)
.end
.sub test_rand_max
.local pmc rand_max
rand_max = get_global [ 'Math'; 'Rand' ], 'RAND_MAX'
$I0 = rand_max()
is($I0,32767)
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: