2 # Copyright (C) 2008-2010, Parrot Foundation.
7 t/oo/attributes.t - Test OO attributes
11 % prove t/oo/attributes.t
15 Tests OO features related to adding and removing attributes.
20 .include 'test_more.pir'
28 .local pmc class, object, init_hash
29 .local pmc exception, message
31 init_hash = new 'Hash'
34 init_hash['data'] = $P1
36 # First pass, adding an attribute.
37 class = newclass "Foo"
38 addattribute class, 'data'
39 object = new class, init_hash
40 $P2 = getattribute object, 'data'
41 is($P2, 'data for Foo', 'class attribute retrieved via the instance')
43 # Second pass, removing the attribute after adding it.
44 class = newclass "Bar"
45 addattribute class, 'data'
46 removeattribute class, 'data'
47 push_eh catch_bad_attr_init
48 object = new class, init_hash
54 push_eh catch_bad_attr_access
55 $P2 = getattribute object, 'data'
62 .get_results (exception)
64 is(message, "No such attribute 'data'", 'class attribute deleted')
68 catch_bad_attr_access:
69 .get_results (exception)
71 is(message, "No such attribute 'data'", 'class attribute deleted')
79 # vim: expandtab shiftwidth=4 ft=pir: