Class-MethodMaker-2.24/ 0000755 0001750 0001750 00000000000 12506541335 012716 5 ustar ss5 ss5 Class-MethodMaker-2.24/t/ 0000755 0001750 0001750 00000000000 12506541335 013161 5 ustar ss5 ss5 Class-MethodMaker-2.24/t/redefine-warnings.t 0000644 0001750 0001750 00000003135 11735360552 016762 0 ustar ss5 ss5 # (X)Emacs mode: -*- cperl -*-
use strict;
=head1 Unit Test Package for Class::MethodMaker
This package tests the basic utility of Class::MethodMaker
=cut
use FindBin 1.42 qw( $Bin );
use Test 1.13 qw( ok plan skip );
use lib $Bin;
use test qw( DATA_DIR
evcheck save_output restore_output );
BEGIN {
# 1 for compilation test,
plan tests => 2,
todo => [],
}
# ----------------------------------------------------------------------------
=head2 Test 1: compilation
This test confirms that the test script and the modules it calls compiled
successfully.
=cut
ok 1, 1, 'compilation';
# -------------------------------------
=head2 Test 2: no warnings generated
This tests for a bug in 2.00 where warnings are generated complaining of
'prototype mismatch' and 'INTEGER redefined' when using Class::MethodMaker
with certain other modules. Currently IPC::Run is tested, which is
unfortunate, since it is non-core. If someone can suggest a core module that
displays this issue with 2.00, that wouldd be great.
=cut
my $if_MSWin = $^O =~ m/MSWin/ ? 'Skip if under MSWin' : '';
if ($if_MSWin) {
skip($if_MSWin, 1, 1, "No warnings generated" );
}
else
{
save_output('stderr', *STDERR{IO});
eval {
require IPC::Run;
};
my $run_failed = $@;
defined $run_failed && $run_failed =~ s/\(.*$//
unless defined $ENV{TEST_DEBUG} and $ENV{TEST_DEBUG} > 1;
eval {
require Class::MethodMaker;
};
my $err = restore_output('stderr');
skip $run_failed, $err, '', "No warnings generated\n";
}
# ----------------------------------------------------------------------------
Class-MethodMaker-2.24/t/basic.t 0000644 0001750 0001750 00000002224 11735360552 014432 0 ustar ss5 ss5 # (X)Emacs mode: -*- cperl -*-
use strict;
=head1 Unit Test Package for Class::MethodMaker
This package tests the basic compilation and working of Class::MethodMaker
=cut
use Data::Dumper qw( );
use FindBin 1.42 qw( $Bin );
use Test 1.13 qw( ok plan );
use lib $Bin;
use test qw( DATA_DIR
evcheck );
BEGIN {
# 1 for compilation test,
plan tests => 2,
todo => [],
}
# ----------------------------------------------------------------------------
=head2 Test 1: compilation
This test confirms that the test script and the modules it calls compiled
successfully.
=cut
use Class::MethodMaker;
ok 1, 1, 'compilation';
# -------------------------------------
=head2 Test 2: scalar
=cut
package bob;
use Class::MethodMaker
[ scalar =>[qw/ foo /] ];
package main;
my $bob = bless {}, 'bob';
print Data::Dumper->Dump([ $bob ], [qw( bob )])
if $ENV{TEST_DEBUG};
$bob->foo("x");
print Data::Dumper->Dump([ $bob ], [qw( bob )])
if $ENV{TEST_DEBUG};
ok $bob->foo, "x", 'scalar ( 1)';
# ----------------------------------------------------------------------------
Class-MethodMaker-2.24/t/warnings.t 0000644 0001750 0001750 00000002663 11735360552 015210 0 ustar ss5 ss5 #!perl -w
# (X)Emacs mode: -*- cperl -*-
use strict;
use warnings;
=head1 Unit Test Package for Class::MethodMaker
This package tests the basic compilation and working of Class::MethodMaker
similar to basic but with warnings explicitely on to check for 5.13.2-related
new warnings.
=cut
use Data::Dumper qw( );
use FindBin 1.42 qw( $Bin );
use Test 1.13 qw( ok plan );
use lib $Bin;
use test qw( DATA_DIR
evcheck );
use vars qw(@MYWARNINGS);
BEGIN { $SIG{__WARN__} = sub { push @MYWARNINGS, $_[0] }; }
BEGIN {
# 1 for compilation test,
plan tests => 3,
todo => [],
}
# ----------------------------------------------------------------------------
=head2 Test 1: compilation
This test confirms that the test script and the modules it calls compiled
successfully.
=cut
use Class::MethodMaker;
ok 1, 1, 'compilation';
# -------------------------------------
=head2 Test 2: scalar
=cut
package bob;
local $^W = 1;
use Class::MethodMaker
[ scalar =>[qw/ foo /] ];
package main;
local $^W = 1;
my $bob = bless {}, 'bob';
print Data::Dumper->Dump([ $bob ], [qw( bob )])
if $ENV{TEST_DEBUG};
$bob->foo("x");
print Data::Dumper->Dump([ $bob ], [qw( bob )])
if $ENV{TEST_DEBUG};
ok $bob->foo, "x", 'scalar ( 1)';
# ----------------------------------------------------------------------------
ok scalar(@MYWARNINGS), 0, 'no warnings occurred';
Class-MethodMaker-2.24/t/diffclass.t 0000644 0001750 0001750 00000007555 11735360552 015323 0 ustar ss5 ss5 # (X)Emacs mode: -*- cperl -*-
use strict;
=head1 Unit Test Package for Class::MethodMaker
This package tests the ability of Class::MethodMaker to insert methods into a
class other than the "Calling" class.
=cut
use Data::Dumper qw( Dumper );
use Fatal 1.02 qw( sysopen close );
use Fcntl 1.03 qw( :DEFAULT );
use File::stat qw( stat );
use FindBin 1.42 qw( $Bin $Script );
use IO::File 1.08 qw( );
use POSIX 1.03 qw( S_ISREG );
use Test 1.13 qw( ok plan );
use lib $Bin;
use test qw( DATA_DIR
evcheck restore_output save_output );
BEGIN {
# 1 for compilation test,
plan tests => 22,
todo => [],
}
# ----------------------------------------------------------------------------
=head2 Test 1: compilation
This test confirms that the test script and the modules it calls compiled
successfully.
=cut
use Class::MethodMaker
[ -target_class => 'X',
scalar => [qw/ a /],
-target_class => 'Y',
scalar => [qw/ b /],
];
ok 1, 1, 'compilation';
# -------------------------------------
=head2 Test 2: bless
=cut
my ($x, $y);
ok evcheck(sub { $x = bless {}, 'X'; $y = bless {}, 'Y'; },
'bless ( 1)'), 1, 'bless ( 1)';
goto "TEST_$ENV{START_TEST}"
if $ENV{START_TEST};
# -------------------------------------
=head2 Tests 3--22: simple non-static
=cut
{
my $n;
ok(evcheck(sub { $n = $x->a_isset; }, 'simple non-static ( 1)'), 1,
'simple non-static ( 1)');
ok ! $n; # simple non-static ( 2)
ok(evcheck(sub { $n = $x->b_isset; }, 'simple non-static ( 3)'), 0,
'simple non-static ( 3)');
ok(evcheck(sub { $n = $y->b_isset; }, 'simple non-static ( 4)'), 1,
'simple non-static ( 4)');
ok(evcheck(sub { $x->a(4); }, 'simple non-static ( 5)'),
1, 'simple non-static ( 5)');
ok(evcheck(sub { $n = $x->a; }, 'simple non-static ( 6)'), 1,
'simple non-static ( 6)');
ok $n, 4, 'simple non-static ( 7)';
ok(evcheck(sub { $n = $x->a(7); }, 'simple non-static ( 8)'), 1,
'simple non-static ( 8)');
ok $n, 7, 'simple non-static ( 9)';
ok(evcheck(sub { $n = $x->a_isset; }, 'simple non-static (10)'), 1,
'simple non-static (10)');
ok $n; # simple non-static (11)
ok(evcheck(sub { $n = $y->b_isset; }, 'simple non-static (12)'), 1,
'simple non-static (12)');
ok ! $n; # simple non-static (13)
ok(evcheck(sub { $n = $x->a_reset; }, 'simple non-static (14)'), 1,
'simple non-static (14)');
ok(evcheck(sub { $n = $x->a_isset; }, 'simple non-static (15)'), 1,
'simple non-static (15)');
ok ! $n; # simple non-static (16)
ok(evcheck(sub { $n = $x->a; }, 'simple non-static (17)'), 1,
'simple non-static (17)');
ok $n, undef, 'simple non-static (18)';
ok(evcheck(sub { $n = $x->a_isset; }, 'simple non-static (19)'), 1,
'simple non-static (19)');
ok ! $n; # simple non-static (20)
}
# -------------------------------------
Class-MethodMaker-2.24/t/test.pm 0000644 0001750 0001750 00000057642 12474272244 014520 0 ustar ss5 ss5 # (X)Emacs mode: -*- cperl -*-
package test;
use strict;
use warnings;
=head1 NAME
test - tools for helping in test suites (not including running externalprograms).
=head1 SYNOPSIS
use FindBin 1.42 qw( $Bin );
use Test 1.13 qw( ok plan );
BEGIN { unshift @INC, $Bin };
use test qw( DATA_DIR
evcheck runcheck );
BEGIN {
plan tests => 3,
todo => [],
;
}
ok evcheck(sub {
open my $fh, '>', 'foo';
print $fh "$_\n"
for 'Bulgaria', 'Cholet';
close $fh;
}, 'write foo'), 1, 'write foo';
save_output('stderr', *STDERR{IO});
warn 'Hello, Mum!';
print restore_output('stderr');
=head1 DESCRIPTION
This package provides some variables, and sets up an environment, for test
scripts, such as those used in F.
This package does not including running external programs; that is provided by
C. This is so that suites not needing that can include only
test.pm, and so not require the presence of C.
Setting up the environment includes:
=over 4
=item Prepending F onto the path
=item Pushing the module F dir onto the @PERL5LIB var
For executed scripts.
=item Pushing the module F dir onto the @INC var
For internal C