tagged release 0.6.4
[parrot.git] / t / pmc / task.t
blobbbcd413399c183aae74d427e26043f107ad0685f
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More;
9 use Parrot::Test tests => 3;
11 =head1 NAME
13 t/pmc/task.t - Concurrent Task
15 =head1 SYNOPSIS
17     % prove t/pmc/task.t
19 =head1 DESCRIPTION
21 Tests the task PMC used by the concurrency scheduler.
23 =cut
25 pir_output_is( <<'CODE', <<'OUT', "create a task and set attributes" );
26   .sub main :main
27     $P0 = new "Task"
28     $P1 = getattribute $P0, 'status'
29     print $P1
30     print "\n"
32     $P2 = new "String"
33     $P2 = "inprocess"
34     setattribute $P0, 'status', $P2
36     $P3 = getattribute $P0, 'status'
37     print $P3
38     print "\n"
40     $P2 = new "String"
41     $P2 = "event"
42     setattribute $P0, 'type', $P2
44     $P3 = getattribute $P0, 'type'
45     print $P3
46     print "\n"
48     $P2 = new "Integer"
49     $P2 = 10
50     setattribute $P0, 'priority', $P2
52     $P3 = getattribute $P0, 'priority'
53     print $P3
54     print "\n"
56     $P2 = new "Integer"
57     $P2 = 7405
58     setattribute $P0, 'id', $P2
60     $P3 = getattribute $P0, 'id'
61     print $P3
62     print "\n"
64     $P2 = new "Float"
65     $P2 = 1.1
66     setattribute $P0, 'birthtime', $P2
68     $P3 = getattribute $P0, 'birthtime'
69     print $P3
70     print "\n"
71     end
72   .end
73 CODE
74 created
75 inprocess
76 event
78 7405
79 1.1
80 OUT
82 pir_output_is( <<'CODE', <<'OUT', 'create a task and set attributes in init' );
83   .sub main :main
84     .local pmc data
85     data = new 'Hash'
87     $P2 = new 'String'
88     $P2 = 'inprocess'
89     data['status'] = $P2
91     $P2 = new 'String'
92     $P2 = 'event'
93     data['type'] = $P2
95     $P2 = new 'Integer'
96     $P2 = 10
97     data['priority'] = $P2
99     $P2 = new 'Integer'
100     $P2 = 7405
101     data['id'] = $P2
103     $P2 = new 'Float'
104     $P2 = 1.1
105     data['birthtime'] = $P2
107     $P0 = new 'Task', data
109     $P3 = getattribute $P0, 'status'
110     say $P3
112     $P3 = getattribute $P0, 'type'
113     say $P3
115     $P3 = getattribute $P0, 'priority'
116     say $P3
118     $P3 = getattribute $P0, 'id'
119     say $P3
121     $P3 = getattribute $P0, 'birthtime'
122     say $P3
123     end
124   .end
125 CODE
126 inprocess
127 event
129 7405
133 pir_output_is( <<'CODE', <<'OUT', "freeze and thaw a task" );
134   .sub main :main
135     $P0 = new "Task"
137     $P2 = new "String"
138     $P2 = "inprocess"
139     setattribute $P0, 'status', $P2
141     $P2 = new "String"
142     $P2 = "event"
143     setattribute $P0, 'type', $P2
145     $P2 = new "Integer"
146     $P2 = 10
147     setattribute $P0, 'priority', $P2
149     $P2 = new "Integer"
150     $P2 = 7405
151     setattribute $P0, 'id', $P2
153     $P2 = new "Float"
154     $P2 = 1.1
155     setattribute $P0, 'birthtime', $P2
157     $S0  = freeze $P0
158     $P10 = thaw $S0 
160     $P3 = getattribute $P10, 'status'
161     print $P3
162     print "\n"
164     $P3 = getattribute $P10, 'type'
165     print $P3
166     print "\n"
168     $P3 = getattribute $P10, 'priority'
169     print $P3
170     print "\n"
172     $P3 = getattribute $P10, 'id'
173     print $P3
174     print "\n"
176     $P3 = getattribute $P10, 'birthtime'
177     print $P3
178     print "\n"
179     end
180   .end
181 CODE
182 inprocess
183 event
185 7405
189 # Local Variables:
190 #   mode: cperl
191 #   cperl-indent-level: 4
192 #   fill-column: 100
193 # End:
194 # vim: expandtab shiftwidth=4: