/
schedulermessage.t
104 lines (75 loc) · 1.87 KB
/
schedulermessage.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
#!./parrot
# Copyright (C) 2008-2010, Parrot Foundation.
=head1 NAME
t/pmc/schedulermessage - test the SchedulerMessage PMC
=head1 SYNOPSIS
% prove t/pmc/schedulermessage.t
=head1 DESCRIPTION
Tests the SchedulerMessage PMC.
=cut
.include 'except_types.pasm'
.sub main :main
.include 'test_more.pir'
plan(8)
init_check()
type_and_id_tests()
freeze_thaw_tests()
hash_tests()
.end
.sub init_check
new $P0, ['SchedulerMessage']
ok(1, 'Instantiated SchedulerMessage PMC')
.local pmc eh
eh = new ['ExceptionHandler']
eh.'handle_types'(.EXCEPTION_INVALID_OPERATION)
set_label eh, catch
push_eh eh
$I0 = 1
$P1 = new ['Integer']
$P0 = new ['SchedulerMessage'], $P1
$I0 = 0
goto check
catch:
finalize eh
check:
pop_eh
ok($I0, 'initializing with invalid type throws')
.end
.sub type_and_id_tests
$P0 = new ['SchedulerMessage']
$P0 = 2345
$P0 = "some kinda message"
$S0 = $P0
is($S0 , "some kinda message", "scheduler message type stored/retrieved successfully")
$I0 = $P0
is($I0, 2345, "scheduler id type stored/retrieved successfully")
.end
.sub freeze_thaw_tests
$P0 = new ['SchedulerMessage']
$P0 = 86
$P0 = "Smart message"
$S0 = freeze $P0
$P1 = thaw $S0
$S0 = $P1
is($S0, "Smart message", "frozen message has correct type")
$I0 = $P1
is($I0, 86, "frozen message has correct id")
.end
.sub hash_tests
$P0 = new ['Hash']
$P0['id'] = 9
$P0['type'] = 'nine'
$P1 = new ['SchedulerMessage'], $P0
# Make sure the mark vtable function is exercised.
null $P0
sweep 1
$S0 = $P1
is($S0, "nine", "hash-initialized message has correct type")
$I0 = $P1
is($I0, 9, "hash-initialized message has correct id")
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: