r8397 - in /branches/upstream/libparent-perl: ./ current/ current/lib/ current/t/ current/t/lib/ current/t/lib/Dummy/

hanska-guest at users.alioth.debian.org hanska-guest at users.alioth.debian.org
Sat Oct 20 17:51:13 UTC 2007


Author: hanska-guest
Date: Sat Oct 20 17:51:13 2007
New Revision: 8397

URL: http://svn.debian.org/wsvn/?sc=1&rev=8397
Log:
[svn-inject] Installing original source of libparent-perl

Added:
    branches/upstream/libparent-perl/
    branches/upstream/libparent-perl/current/
    branches/upstream/libparent-perl/current/.cvsignore
    branches/upstream/libparent-perl/current/Changes   (with props)
    branches/upstream/libparent-perl/current/MANIFEST
    branches/upstream/libparent-perl/current/META.yml
    branches/upstream/libparent-perl/current/Makefile.PL   (with props)
    branches/upstream/libparent-perl/current/lib/
    branches/upstream/libparent-perl/current/lib/parent.pm   (with props)
    branches/upstream/libparent-perl/current/t/
    branches/upstream/libparent-perl/current/t/compile-time-file.t   (with props)
    branches/upstream/libparent-perl/current/t/compile-time.t   (with props)
    branches/upstream/libparent-perl/current/t/lib/
    branches/upstream/libparent-perl/current/t/lib/Dummy/
    branches/upstream/libparent-perl/current/t/lib/Dummy.pm   (with props)
    branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm   (with props)
    branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin   (with props)
    branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc   (with props)
    branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm   (with props)
    branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t   (with props)
    branches/upstream/libparent-perl/current/t/parent-classfromfile.t   (with props)
    branches/upstream/libparent-perl/current/t/parent-pmc.t   (with props)
    branches/upstream/libparent-perl/current/t/parent-returns-false.t   (with props)
    branches/upstream/libparent-perl/current/t/parent.t   (with props)

Added: branches/upstream/libparent-perl/current/.cvsignore
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/.cvsignore?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/.cvsignore (added)
+++ branches/upstream/libparent-perl/current/.cvsignore Sat Oct 20 17:51:13 2007
@@ -1,0 +1,11 @@
+blib
+Makefile
+parent-*
+*.old
+*.tar.gz
+pm_to_blib
+pm_to_blib.ts
+.lwpcookies
+.releaserc
+META.yml
+blibdirs.ts

Added: branches/upstream/libparent-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/Changes?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/Changes (added)
+++ branches/upstream/libparent-perl/current/Changes Sat Oct 20 17:51:13 2007
@@ -1,0 +1,34 @@
+0.219  20071020
+    . No functional changes, no need to upgrade
+    + Added LICENSE section to clarify the license of this code
+
+0.218  20070819
+    . No functional changes
+    + Code cleanup as suggested by A. Pagaltzis
+
+0.217  20070815
+    + Fixed test failure reported by David Cantrell
+    + Ripped out most of the logic. All you can do
+      is now specify that the base classes should not
+      be loaded from a file via C<-norequire>.
+    + 5.004 compatibility restored by Sébastien Aperghis-Tramoni
+      (mostly it's the test suite that breaks ...)
+
+0.216 20070805
+    Add a test for (transparently) loading a .pmc
+    Loading from an arbitrary file is now possible
+    Class names may not contain a forward slash anymore
+
+0.215 20070802
+    Changed version to a 0.x version to indicate beta status
+    5.004 compatibility patch by Sébastien Aperghis-Tramoni
+    Added a test for a module that returns a false value on load
+    5.9.x performance improvement change - modify @ISA by assignment
+
+2.14 20070802
+    Commented out "use strict" and "use vars qw()" and "no strict()"
+    Changed @ISA modification to better suit the MRO
+
+2.13 20070801
+    Forked from base.pm
+

Propchange: branches/upstream/libparent-perl/current/Changes
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/MANIFEST?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/MANIFEST (added)
+++ branches/upstream/libparent-perl/current/MANIFEST Sat Oct 20 17:51:13 2007
@@ -1,0 +1,18 @@
+.cvsignore
+Changes
+lib/parent.pm
+Makefile.PL
+MANIFEST			This list of files
+t/compile-time-file.t
+t/compile-time.t
+t/lib/Dummy.pm
+t/lib/Dummy/Outside.pm
+t/lib/FileThatOnlyExistsAsPMC.pmc
+t/lib/ReturnsFalse.pm
+t/lib/Dummy2.plugin
+t/parent-classfromclassfile.t
+t/parent-classfromfile.t
+t/parent-pmc.t
+t/parent-returns-false.t
+t/parent.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libparent-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/META.yml?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/META.yml (added)
+++ branches/upstream/libparent-perl/current/META.yml Sat Oct 20 17:51:13 2007
@@ -1,0 +1,12 @@
+--- #YAML:1.0
+name:                parent
+version:             0.219
+abstract:            ~
+license:             ~
+generated_by:        ExtUtils::MakeMaker version 6.36_01
+distribution_type:   module
+requires:     
+    Test::More:                    0.4
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
+    version: 1.2

Added: branches/upstream/libparent-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/Makefile.PL?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/Makefile.PL (added)
+++ branches/upstream/libparent-perl/current/Makefile.PL Sat Oct 20 17:51:13 2007
@@ -1,0 +1,41 @@
+# A template for Makefile.PL.
+# - Set the $PACKAGE variable to the name of your module.
+# - Set $LAST_API_CHANGE to reflect the last version you changed the API
+#   of your module.
+# - Fill in your dependencies in PREREQ_PM
+# Alternatively, you can say the hell with this and use h2xs.
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME            => 'parent',
+    VERSION_FROM    => "lib/parent.pm", # finds $VERSION
+    PREREQ_PM       => { Test::More => 0.40 },
+    #INSTALLDIRS     => 'perl', # well, that would be nice
+);
+
+# Leftover voodoo for testing various Perl distributions
+{
+    package MY;
+
+    sub test_via_harness {
+        my($self, $orig_perl, $tests) = @_;
+
+        my @perls = ($orig_perl);
+        push @perls, qw(bleadperl
+                        perl5.6.1
+                        perl5.6.0
+                        perl5.005_03
+                        perl5.004_05
+                        perl5.004_04
+                        perl5.004)
+          if $ENV{PERL_TEST_ALL};
+
+        my $out;
+        foreach my $perl (@perls) {
+            $out .= $self->SUPER::test_via_harness($perl, $tests);
+        }
+
+        return $out;
+    }
+}

Propchange: branches/upstream/libparent-perl/current/Makefile.PL
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/lib/parent.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/lib/parent.pm?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/lib/parent.pm (added)
+++ branches/upstream/libparent-perl/current/lib/parent.pm Sat Oct 20 17:51:13 2007
@@ -1,0 +1,144 @@
+package parent;
+use strict;
+use vars qw($VERSION);
+$VERSION = '0.219';
+
+sub import {
+    my $class = shift;
+
+    my $inheritor = caller(0);
+
+    if ( @_ and $_[0] eq '-norequire' ) {
+        shift @_;
+    } else {
+        for ( my @filename = @_ ) {
+            if ( $_ eq $inheritor ) {
+                warn "Class '$inheritor' tried to inherit from itself\n";
+            };
+
+            s{::|'}{/}g;
+            require "$_.pm"; # dies if the file is not found
+        }
+    }
+
+    {
+        no strict 'refs';
+        # This is more efficient than push for the new MRO
+        # at least until the new MRO is fixed
+        @{"$inheritor\::ISA"} = (@{"$inheritor\::ISA"} , @_);
+    };
+};
+
+"All your base are belong to us"
+
+__END__
+
+=head1 NAME
+
+parent - Establish an ISA relationship with base classes at compile time
+
+=head1 WARNING
+
+This is a B<beta release>. While I consider the interface
+now fixed, this is not entirely sure - minor changes to C<-norequire>
+may still happen.
+
+=head1 SYNOPSIS
+
+    package Baz;
+    use parent qw(Foo Bar);
+
+=head1 DESCRIPTION
+
+Allows you to both load one or more modules, while setting up inheritance from
+those modules at the same time.  Mostly similar in effect to
+
+    package Baz;
+    BEGIN {
+        require Foo;
+        require Bar;
+        push @ISA, qw(Foo Bar);
+    }
+
+By default, every base class needs to live in a file of its own.
+If you want to have a subclass and its parent class in the same file, you
+can tell C<parent> not to load any modules by using the C<-norequire> switch:
+
+  package Foo;
+  sub exclaim { "I CAN HAS PERL" }
+
+  package DoesNotLoadFooBar;
+  use parent -norequire, 'Foo', 'Bar';
+  # will not go looking for Foo.pm or Bar.pm
+
+This is equivalent to the following code:
+
+  package Foo;
+  sub exclaim { "I CAN HAS PERL" }
+
+  package DoesNotLoadFooBar;
+  push @DoesNotLoadFooBar::ISA, 'Foo';
+
+This is also helpful for the case where a package lives within
+a differently named file:
+
+  package MyHash;
+  use Tie::Hash;
+  use parent -norequire, 'Tie::StdHash';
+
+This is equivalent to the following code:
+
+  package MyHash;
+  require Tie::Hash;
+  push @ISA, 'Tie::StdHash';
+
+If you want to load a subclass from a file that C<require> would
+not consider an eligible filename (that is, it does not end in
+either C<.pm> or C<.pmc>), use the following code:
+
+  package MySecondPlugin;
+  require './plugins/custom.plugin'; # contains Plugin::Custom
+  use parent -norequire, 'Plugin::Custom';
+
+=head1 DIAGNOSTICS
+
+=over 4
+
+=item Class 'Foo' tried to inherit from itself
+
+Attempting to inherit from yourself generates a warning.
+
+    use Foo;
+    use parent 'Foo';
+
+=back
+
+=head1 HISTORY
+
+This module was forked from L<base> to remove the cruft
+that had accumulated in it.
+
+=head1 CAVEATS
+
+=head1 SEE ALSO
+
+L<base>
+
+=head1 AUTHORS AND CONTRIBUTORS
+
+Rafaël Garcia-Suarez, Bart Lateur, Max Maischein, Anno Siegel, Michael Schwern
+
+=head1 MAINTAINER
+
+Max Maischein C< corion at cpan.org >
+
+=head1 AUTHOR
+
+Copyright (c) 2007 Max Maischein C<< <corion at cpan.org> >>
+Based on the idea of C<base.pm>, which was introduced with Perl 5.004_04.
+
+=head1 LICENSE
+
+This module is released under the same terms as Perl itself.
+
+=cut

Propchange: branches/upstream/libparent-perl/current/lib/parent.pm
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/compile-time-file.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/compile-time-file.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/compile-time-file.t (added)
+++ branches/upstream/libparent-perl/current/t/compile-time-file.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,46 @@
+#!/usr/bin/perl -w
+BEGIN {
+   if( $ENV{PERL_CORE} ) {
+        chdir 't' if -d 't';
+        @INC = qw(../lib lib);
+    }
+}
+
+use strict;
+use Test::More tests => 9;
+use lib 't/lib';
+
+{
+    package Child;
+    use parent 'Dummy';
+}
+
+{
+    package Child2;
+    require Dummy;
+    use parent -norequire, 'Dummy::InlineChild';
+}
+
+{
+    package Child3;
+    use parent "Dummy'Outside";
+}
+
+my $obj = {};
+bless $obj, 'Child';
+isa_ok $obj, 'Dummy';
+can_ok $obj, 'exclaim';
+is $obj->exclaim, "I CAN FROM Dummy", 'Inheritance is set up correctly';
+
+$obj = {};
+bless $obj, 'Child2';
+isa_ok $obj, 'Dummy::InlineChild';
+can_ok $obj, 'exclaim';
+is $obj->exclaim, "I CAN FROM Dummy::InlineChild", 'Inheritance is set up correctly for inlined classes';
+
+$obj = {};
+bless $obj, 'Child3';
+isa_ok $obj, 'Dummy::Outside';
+can_ok $obj, 'exclaim';
+is $obj->exclaim, "I CAN FROM Dummy::Outside", "Inheritance is set up correctly for classes inherited from via '";
+

Propchange: branches/upstream/libparent-perl/current/t/compile-time-file.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/compile-time.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/compile-time.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/compile-time.t (added)
+++ branches/upstream/libparent-perl/current/t/compile-time.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,21 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More tests => 3;
+
+{
+    package MyParent;
+    sub exclaim { "I CAN HAS PERL?" }
+}
+
+{
+    package Child;
+    use parent -norequire, 'MyParent';
+}
+
+my $obj = {};
+bless $obj, 'Child';
+isa_ok $obj, 'MyParent', 'Inheritance';
+can_ok $obj, 'exclaim';
+is $obj->exclaim, "I CAN HAS PERL?", 'Inheritance is set up correctly';
+

Propchange: branches/upstream/libparent-perl/current/t/compile-time.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/lib/Dummy.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/lib/Dummy.pm?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/lib/Dummy.pm (added)
+++ branches/upstream/libparent-perl/current/t/lib/Dummy.pm Sat Oct 20 17:51:13 2007
@@ -1,0 +1,12 @@
+package Dummy;
+
+# Attempt to emulate a bug with finding the version in Exporter.
+$VERSION = '5.562';
+
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+package Dummy::InlineChild;
+
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+1;

Propchange: branches/upstream/libparent-perl/current/t/lib/Dummy.pm
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm (added)
+++ branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm Sat Oct 20 17:51:13 2007
@@ -1,0 +1,6 @@
+package Dummy::Outside;
+
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+1;
+

Propchange: branches/upstream/libparent-perl/current/t/lib/Dummy/Outside.pm
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin (added)
+++ branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin Sat Oct 20 17:51:13 2007
@@ -1,0 +1,7 @@
+package Dummy2;
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+package Dummy2::InlineChild;
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+1;

Propchange: branches/upstream/libparent-perl/current/t/lib/Dummy2.plugin
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc (added)
+++ branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc Sat Oct 20 17:51:13 2007
@@ -1,0 +1,5 @@
+package FileThatOnlyExistsAsPMC;
+
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+1;

Propchange: branches/upstream/libparent-perl/current/t/lib/FileThatOnlyExistsAsPMC.pmc
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm (added)
+++ branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm Sat Oct 20 17:51:13 2007
@@ -1,0 +1,5 @@
+package ReturnsFalse;
+
+sub exclaim { "I CAN FROM " . __PACKAGE__ }
+
+0;

Propchange: branches/upstream/libparent-perl/current/t/lib/ReturnsFalse.pm
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t (added)
+++ branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,21 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+   if( $ENV{PERL_CORE} ) {
+        chdir 't' if -d 't';
+        @INC = qw(../lib lib);
+    } else {
+        push @INC, 't/lib';
+    };
+}
+
+use strict;
+use Test::More tests => 3;
+
+use_ok('parent');
+
+# Tests that a bare (non-double-colon) class still loads
+# and does not get treated as a file:
+eval q{package Test1; require Dummy; use parent -norequire, 'Dummy::InlineChild'; };
+is $@, '', "Loading an unadorned class works";
+isn't $INC{"Dummy.pm"}, undef, 'We loaded Dummy.pm';

Propchange: branches/upstream/libparent-perl/current/t/parent-classfromclassfile.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/parent-classfromfile.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/parent-classfromfile.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/parent-classfromfile.t (added)
+++ branches/upstream/libparent-perl/current/t/parent-classfromfile.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,26 @@
+#!/usr/bin/perl -w
+
+my $base;
+BEGIN {
+   if( $ENV{PERL_CORE} ) {
+        chdir 't' if -d 't';
+        @INC = qw(../lib lib);
+	$base = '.';
+    } else {
+        push @INC, 't/lib';
+	$base = './t';
+    };
+}
+
+use strict;
+use Test::More tests => 4;
+
+use_ok('parent');
+
+# Tests that a bare (non-double-colon) class still loads
+# and does not get treated as a file:
+eval sprintf q{package Test2; require '%s/lib/Dummy2.plugin'; use parent -norequire, 'Dummy2::InlineChild' }, $base;
+is $@, '', "Loading a class from a file works";
+isn't $INC{"$base/lib/Dummy2.plugin"}, undef, "We loaded the plugin file";
+my $o = bless {}, 'Test2';
+isa_ok $o, 'Dummy2::InlineChild';

Propchange: branches/upstream/libparent-perl/current/t/parent-classfromfile.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/parent-pmc.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/parent-pmc.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/parent-pmc.t (added)
+++ branches/upstream/libparent-perl/current/t/parent-pmc.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,24 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More;
+use lib 't/lib';
+
+plan skip_all => ".pmc are only available with 5.6 and later" if $] < 5.006;
+plan tests => 3;
+
+use vars qw($got_here);
+
+my $res = eval q{
+    package MyTest;
+
+    use parent 'FileThatOnlyExistsAsPMC';
+
+    1
+};
+my $error = $@;
+
+is $res, 1, "Block ran until the end";
+is $error, '', "No error";
+
+my $obj = bless {}, 'FileThatOnlyExistsAsPMC';
+can_ok $obj, 'exclaim';

Propchange: branches/upstream/libparent-perl/current/t/parent-pmc.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/parent-returns-false.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/parent-returns-false.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/parent-returns-false.t (added)
+++ branches/upstream/libparent-perl/current/t/parent-returns-false.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,18 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 2;
+use lib 't/lib';
+
+use vars qw($got_here);
+
+my $res = eval q{
+    package MyTest;
+
+    use parent 'ReturnsFalse';
+
+    $main::got_here++
+};
+my $error = $@;
+
+is $got_here, undef, "The block did not run to its end.";
+like $error, q{/^ReturnsFalse.pm did not return a true value at /}, "A module that returns a false value raises an error";

Propchange: branches/upstream/libparent-perl/current/t/parent-returns-false.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libparent-perl/current/t/parent.t
URL: http://svn.debian.org/wsvn/branches/upstream/libparent-perl/current/t/parent.t?rev=8397&op=file
==============================================================================
--- branches/upstream/libparent-perl/current/t/parent.t (added)
+++ branches/upstream/libparent-perl/current/t/parent.t Sat Oct 20 17:51:13 2007
@@ -1,0 +1,80 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+   if( $ENV{PERL_CORE} ) {
+        chdir 't' if -d 't';
+        @INC = qw(../lib);
+    }
+}
+
+use strict;
+use Test::More tests => 10;
+
+use_ok('parent');
+
+
+package No::Version;
+
+use vars qw($Foo);
+sub VERSION { 42 }
+
+package Test::Version;
+
+use parent -norequire, 'No::Version';
+::is( $No::Version::VERSION, undef,          '$VERSION gets left alone' );
+
+# Test Inverse: parent.pm should not clobber existing $VERSION
+package Has::Version;
+
+BEGIN { $Has::Version::VERSION = '42' };
+
+package Test::Version2;
+
+use parent -norequire, 'Has::Version';
+::is( $Has::Version::VERSION, 42 );
+
+package main;
+
+my $eval1 = q{
+  {
+    package Eval1;
+    {
+      package Eval2;
+      use parent -norequire, 'Eval1';
+      $Eval2::VERSION = "1.02";
+    }
+    $Eval1::VERSION = "1.01";
+  }
+};
+
+eval $eval1;
+is( $@, '' );
+
+# String comparisons, just to be safe from floating-point errors
+is( $Eval1::VERSION, '1.01' );
+
+is( $Eval2::VERSION, '1.02' );
+
+
+eval q{use parent 'reallyReAlLyNotexists'};
+like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(\@INC contains:/}, 'baseclass that does not exist');
+
+eval q{use parent 'reallyReAlLyNotexists'};
+like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(\@INC contains:/}, '  still failing on 2nd load');
+{
+    my $warning;
+    local $SIG{__WARN__} = sub { $warning = shift };
+    eval q{package HomoGenous; use parent 'HomoGenous';};
+    like($warning, q{/^Class 'HomoGenous' tried to inherit from itself/},
+                                          '  self-inheriting');
+}
+
+{
+    BEGIN { $Has::Version_0::VERSION = 0 }
+
+    package Test::Version3;
+
+    use parent -norequire, 'Has::Version_0';
+    ::is( $Has::Version_0::VERSION, 0, '$VERSION==0 preserved' );
+}
+

Propchange: branches/upstream/libparent-perl/current/t/parent.t
------------------------------------------------------------------------------
    svn:executable = 




More information about the Pkg-perl-cvs-commits mailing list