/
time.t
104 lines (84 loc) · 1.65 KB
/
time.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
# $Id$
=head1 NAME
t/op/time.t - Time and Sleep
=head1 SYNOPSIS
% perl -Ilib t/op/time.t
=head1 DESCRIPTION
Tests the C<time> and C<sleep> operations.
=cut
use Parrot::Test tests => 5;
output_is(<<'CODE', <<'OUTPUT', "time_i");
time I0
time I1
ge I0, 0, OK1
branch FAIL
OK1: print "ok, (!= 1970) Grateful Dead not\n"
ge I1, I0, OK2
branch FAIL
OK2: print "ok, (now>before) timelords need not apply\n"
branch OK_ALL
FAIL: print "failure\n"
print "I0 was: "
print I0
print "\nI1 was: "
print I0
print "\n"
OK_ALL:
end
CODE
ok, (!= 1970) Grateful Dead not
ok, (now>before) timelords need not apply
OUTPUT
output_is(<<'CODE', <<'OUTPUT', "time_n");
time N0
time N1
ge N0, 0.0, OK1
branch FAIL
OK1: print "ok, (!= 1970) Grateful Dead not\n"
ge N1, N0, OK2
branch FAIL
OK2: print "ok, (now>before) timelords need not apply\n"
branch OK_ALL
FAIL: print "failure\n"
OK_ALL:
end
CODE
ok, (!= 1970) Grateful Dead not
ok, (now>before) timelords need not apply
OUTPUT
output_is(<<CODE, <<OUTPUT, "sleep");
print "start\\n"
time I1
sleep 1
set I0, 1
sleep I0
time I0
gt I0, I1, ALLOK
print "no, sleeping made time go the wrong way "
ALLOK:
print "done\\n"
end
CODE
start
done
OUTPUT
output_like(<<CODE, <<OUT , "sleep");
sleep -1
end
CODE
/Cannot go back in time/
OUT
my $year;
(undef, undef, undef, undef, undef, $year) = gmtime(time);
$year += 1900;
# don't run this test 1 tick before the year changes #'
output_is(<<'CODE', $year, "decodelocaltime");
time I0
decodelocaltime P0, I0
.include "tm.pasm"
set I0, P0[.TM_YEAR]
print I0
end
CODE