2 # Copyright (C) 2006-2007, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use Parrot::Test tests => 8;
13 t/dynpmc/rotest.t -- tests read-only value support through the ROTest dynpmc
17 % prove t/dynpmc/rotest.t
21 Tests automatically generated read-only PMC support.
25 my $library = <<'CODE';
26 .include "except_types.pasm"
32 setprop arg, '_ro', one
40 setprop arg, '_ro', zero
46 # The ROTest dynpmc has opposite of normal logic for set/get integer
47 # and 'reader' and 'writer' NCI methods.
48 # The values are [should work with read-only, is todo test].
51 # these first two tests would test overriding of the default
52 # read-onlyness notion of vtables
53 q{value = 42} => [ 1, 0 ],
54 q{$I0 = value} => [ 0, 0 ],
56 # these make sure NCI methods check does-write flags
57 # 'writer' is marked as writing; 'reader' is not.
58 q{$I0 = value.'reader'()} => [ 1, 0 ],
59 q{$I0 = value.'writer'(42)} => [ 0, 0 ],
61 for my $test ( keys %tests ) {
62 my $code = $library . <<"CODE";
67 eh = new 'ExceptionHandler'
68 eh.'handle_types'(.EXCEPTION_WRITE_TO_CONSTCLASS, .EXCEPTION_METHOD_NOT_FOUND)
80 say "RO or method not found exception caught"
85 my ( $readonly, $todo ) = @{ $tests{$test} };
87 # first make sure it works without the make_readonly
88 pir_output_is( $code, "reached end\n", "ROTest (dry run) ($test)" );
90 $code =~ s/#READONLYTEST/make_readonly(value)/;
92 pir_output_is( $code, "reached end\n", "ROTest (read-only/okay) ($test)" );
95 pir_output_is( $code, "RO or method not found exception caught\n", "ROTest (read-only/fail) ($test)" );
103 # cperl-indent-level: 4
106 # vim: expandtab shiftwidth=4: