~dexter/parrot-pkg/maverick

« back to all changes in this revision

Viewing changes to t/pmc/eventhandler.t

  • Committer: Piotr Roszatycki
  • Date: 2011-01-11 14:34:28 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: piotr.roszatycki@gmail.com-20110111143428-s7pa7qz38m61o4tw
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!./parrot
2
2
# Copyright (C) 2007-2010, Parrot Foundation.
3
 
# $Id: eventhandler.t 46007 2010-04-25 11:44:15Z fperrad $
4
3
 
5
4
=head1 NAME
6
5
 
19
18
.sub main :main
20
19
    .include 'test_more.pir'
21
20
 
22
 
    plan(4)
 
21
    plan(5)
23
22
 
24
23
    create_an_event_and_set_attributes()
 
24
    # Invoke broken, see below.
 
25
    #invoke_eventhandler()
25
26
.end
26
27
 
27
28
.sub create_an_event_and_set_attributes
47
48
    code         = get_global 'my_handler'
48
49
    init['code'] = code
49
50
 
 
51
    sweep 1
 
52
 
50
53
    eh  = new ['EventHandler'], init
51
54
    $S0 = typeof eh
52
55
    is( $S0, 'EventHandler', 'Created EventHandler with args' )
54
57
    $S1 = eh
55
58
    is( $S1, 'cool event', 'Event type confirmed' )
56
59
 
 
60
    # Test set_integer_native, but no way to confirm.
 
61
    eh = 5
 
62
 
57
63
    push_eh bad_args
58
64
        eh = new ['EventHandler'], code
59
65
    pop_eh
60
66
 
61
67
    ok( 1, 'No exception from initializer' )
 
68
 
 
69
    push_eh bad_args
 
70
        eh = new ['EventHandler'], type
 
71
    pop_eh
 
72
 
62
73
    .return()
63
74
 
64
75
  bad_args:
65
 
    ok( 0, 'Exception with bad initializer' )
 
76
    ok( 1, 'Exception with bad initializer' )
66
77
 
67
78
.end
68
79
 
 
80
#.sub invoke_eventhandler
 
81
#    .local pmc eh
 
82
#    .local pmc code
 
83
#
 
84
#    code = get_global 'test_handler'
 
85
#    eh   = new ['EventHandler'], code
 
86
#
 
87
#    print "Invoking eh\n"
 
88
#    # Unsure of the arguments that should be passed, but seems to crash regardless
 
89
#    # EventHandler's VTABLE_invoke() broken?
 
90
#    # See ticket http://trac.parrot.org/parrot/ticket/1894
 
91
#    eh()
 
92
#.end
 
93
 
69
94
.sub my_handler
70
95
.end
71
96
 
 
97
#.sub test_handler
 
98
#    ok ( 1, 'Invoked Exception handler.' )
 
99
#.end
72
100
 
73
101
# Local Variables:
74
102
#   mode: pir