1use strict;
2$^W++;
3use Class::Prototyped qw(:REFLECT);
4use Data::Dumper;
5use Test;
6use IO::File;
7
8BEGIN {
9	$|++;
10	plan tests => 18;
11}
12
13$Data::Dumper::Sortkeys = 1;
14$Data::Dumper::Sortkeys = 1;
15
16my $fileName = 't/xxxtest.pl';
17my $file = IO::File->new( ">$fileName" )
18	or die "Can't open $fileName: $!\n";
19$file->print($_) while <DATA>;
20close($file);
21
22package A;
23sub Aa { 'Aaa' }
24
25package main;
26
27my $p  = Class::Prototyped->new();
28my $pm = $p->reflect;
29
30ok( !defined( $p->can('b') ) );
31ok( !defined( $p->can('c') ) );
32ok( !defined( $p->can('d') ) );
33ok( !defined( $p->can('e') ) );
34ok( !defined( $p->can('thisObject') ) );
35ok( ! $p->isa( 'A' ) );
36ok( scalar( () = $pm->slotNames ), 0 );
37
38$pm->include( $fileName, 'thisObject' );
39
40ok( defined( $p->can('b') ) );
41ok( defined( $p->can('c') ) );
42ok( defined( $p->can('d') ) );
43ok( defined( $p->can('e') ) );
44ok( !defined( $p->can('thisObject') ) );
45ok( $p->b, 'xxx.b' );
46ok( $p->isa( 'A' ) );
47ok( $p->Aa, 'Aaa' );
48ok( scalar( ( ) = $pm->slotNames ) == 5 );
49ok( !defined( eval { $p->c }  ) );
50ok( $@ =~ /Undefined subroutine/ );
51
52unlink $fileName;
53
54# File to include below:
55__END__
56
57sub b { 'xxx.b' }
58
59sub c { return thisObject(); }
60
61thisObject()->reflect->addSlots(
62	'parent*' => 'A',
63	d => 'added.d',
64	e => sub { 'xxx.e' },
65);
66
671;
68