-
Notifications
You must be signed in to change notification settings - Fork 138
/
eventhandler.t
77 lines (53 loc) · 1.37 KB
/
eventhandler.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
#! parrot
# Copyright (C) 2007-2008, Parrot Foundation.
# $Id $
=head1 NAME
t/pmc/eventhandler.t - Parrot Event Handling
=head1 SYNOPSIS
% prove t/pmc/eventhandler.t
=head1 DESCRIPTION
Tests the EventHandler PMC used by the event system.
=cut
.sub main :main
.include 'test_more.pir'
plan(4)
create_an_event_and_set_attributes()
.end
.sub create_an_event_and_set_attributes
.local pmc eh
eh = new ['EventHandler']
$S0 = typeof eh
is( $S0, 'EventHandler', 'Created EventHandler' )
.local pmc init
init = new ['Hash']
.local pmc type
type = new ['String']
type = 'cool event'
init['type'] = type
.local pmc priority
priority = new ['Integer']
priority = 10
init['priority'] = priority
.local pmc code
code = get_global 'my_handler'
init['code'] = code
eh = new ['EventHandler'], init
$S0 = typeof eh
is( $S0, 'EventHandler', 'Created EventHandler with args' )
$S1 = eh
is( $S1, 'cool event', 'Event type confirmed' )
push_eh bad_args
eh = new ['EventHandler'], code
pop_eh
ok( 1, 'No exception from initializer' )
.return()
bad_args:
ok( 0, 'Exception with bad initializer' )
.end
.sub my_handler
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: