From ef7cff759fe1859169315bb17eb4275ec2dafeb4 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 30 May 2017 22:17:56 -0400 Subject: [PATCH] add more boilerplate tests --- README.mkdn | 4 ++-- cpanfile | 29 +++++++++++++++++++++++++---- dist.ini | 32 ++++++++++++++++++++++++++++---- lib/PDLx/DetachedObject.pm | 14 ++++++++++++-- t/classes.t | 14 +++++++------- 5 files changed, 74 insertions(+), 19 deletions(-) diff --git a/README.mkdn b/README.mkdn index 6635f9d..bc59d69 100644 --- a/README.mkdn +++ b/README.mkdn @@ -104,7 +104,7 @@ inheritance scheme will be called by **MyPDL**'s constructor: $mypdl = MyPDL->new( required_attr => 2 ); -It's also called when **PDL** needs to create an object to recieve +It's also called when **PDL** needs to create an object to receive the results of a **PDL** operation on a **MyPDL** object: $newpdl = $mypdl + 1; @@ -113,7 +113,7 @@ There's one wrinkle, however. **PDL** _must_ create an object without any extra attributes (it cannot know which values to give them) so **initialize()** is called with a _single_ argument, the class name. This means that `$newpdl` will be an _incomplete_ **MyPDL** object, -i.e. `required_attr` is uninitiailzed. This can _really_ confuse +i.e. `required_attr` is uninitialized. This can _really_ confuse polymorphic code which operates differently when handed a **PDL** or **MyPDL** object. diff --git a/cpanfile b/cpanfile index 0246b08..7f4c4cb 100644 --- a/cpanfile +++ b/cpanfile @@ -36,7 +36,9 @@ on 'develop' => sub { requires "Dist::Zilla::Plugin::BumpVersionAfterRelease" => "0"; requires "Dist::Zilla::Plugin::CPANFile" => "0"; requires "Dist::Zilla::Plugin::CheckMetaResources" => "0"; - requires "Dist::Zilla::Plugin::CopyFilesFromBuild" => "0"; + requires "Dist::Zilla::Plugin::CopyFilesFromRelease" => "0"; + requires "Dist::Zilla::Plugin::EnsureChangesHasContent" => "0"; + requires "Dist::Zilla::Plugin::EnsurePrereqsInstalled" => "0"; requires "Dist::Zilla::Plugin::GatherDir" => "0"; requires "Dist::Zilla::Plugin::InsertCopyright" => "0"; requires "Dist::Zilla::Plugin::InsertExample" => "0"; @@ -54,18 +56,37 @@ on 'develop' => sub { requires "Dist::Zilla::Plugin::Regenerate" => "0"; requires "Dist::Zilla::Plugin::RewriteVersion" => "0"; requires "Dist::Zilla::Plugin::RunExtraTests" => "0"; + requires "Dist::Zilla::Plugin::Test::CPAN::Changes" => "0"; + requires "Dist::Zilla::Plugin::Test::CPAN::Meta::JSON" => "0"; + requires "Dist::Zilla::Plugin::Test::CheckManifest" => "0"; requires "Dist::Zilla::Plugin::Test::Compile" => "0"; + requires "Dist::Zilla::Plugin::Test::Fixme" => "0"; + requires "Dist::Zilla::Plugin::Test::NoBreakpoints" => "0"; + requires "Dist::Zilla::Plugin::Test::NoTabs" => "0"; + requires "Dist::Zilla::Plugin::Test::Perl::Critic" => "0"; + requires "Dist::Zilla::Plugin::Test::PodSpelling" => "0"; requires "Dist::Zilla::Plugin::Test::ReportPrereqs" => "0"; + requires "Dist::Zilla::Plugin::Test::TrailingSpace" => "0"; + requires "Dist::Zilla::Plugin::Test::UnusedVars" => "0"; + requires "Dist::Zilla::Plugin::Test::Version" => "0"; requires "Dist::Zilla::PluginBundle::Basic" => "0"; requires "Dist::Zilla::PluginBundle::Filter" => "0"; + requires "English" => "0"; requires "Pod::Coverage::TrustPod" => "0"; + requires "Pod::Wordlist" => "0"; requires "Software::License::GPL_3" => "0"; - requires "Test::CPAN::Changes" => "0"; + requires "Test::CPAN::Changes" => "0.19"; requires "Test::CPAN::Meta" => "0"; + requires "Test::CPAN::Meta::JSON" => "0.16"; requires "Test::Fixme" => "0"; - requires "Test::More" => "0"; - requires "Test::NoBreakpoints" => "0"; + requires "Test::More" => "0.96"; + requires "Test::NoBreakpoints" => "0.15"; + requires "Test::NoTabs" => "0"; requires "Test::Perl::Critic" => "0"; requires "Test::Pod" => "1.41"; requires "Test::Pod::Coverage" => "1.08"; + requires "Test::Spelling" => "0.12"; + requires "Test::TrailingSpace" => "0.0203"; + requires "Test::Vars" => "0"; + requires "Test::Version" => "1"; }; diff --git a/dist.ini b/dist.ini index 295957d..abd32e0 100644 --- a/dist.ini +++ b/dist.ini @@ -45,12 +45,13 @@ remove_boiler = 1 [InsertCopyright] -[CopyFilesFromBuild] +[CopyFilesFromRelease] ; Copy generated content to the repository root so users without ; Dist::Zilla can use it -copy = cpanfile -copy = LICENSE -copy = Makefile.PL +filename = cpanfile +filename = LICENSE +filename = Makefile.PL +filename = README [AutoMetaResources] bugtracker.rt = 1 @@ -75,12 +76,35 @@ filenames = Makefile.PL [Test::ReportPrereqs] [Test::Compile] +[Test::NoTabs] +[Test::Fixme] +[Test::Version] +[Test::NoBreakpoints] + +[Test::TrailingSpace] + +[Test::CheckManifest] +[Test::UnusedVars] +[Test::CPAN::Changes] +[Test::CPAN::Meta::JSON] +[Test::Perl::Critic] + +; PDL::Lite exports +; barf, null, pdl, piddle +; [Test::CleanNamespaces] + +[Test::PodSpelling] +stopword = PDL +stopword = MyPDL [PodSyntaxTests] [PodCoverageTests] [RunExtraTests] [Prereqs::AuthorDeps] +[EnsurePrereqsInstalled] + +[EnsureChangesHasContent] ; --- Project-specific directives diff --git a/lib/PDLx/DetachedObject.pm b/lib/PDLx/DetachedObject.pm index 6522c82..58c2525 100644 --- a/lib/PDLx/DetachedObject.pm +++ b/lib/PDLx/DetachedObject.pm @@ -9,6 +9,16 @@ our $VERSION = '0.02'; our @ISA = qw( PDL ); use PDL::Lite; +=begin pod_coverage + +=head3 initialize + +=head3 new + +=end pod_coverage + +=cut + sub initialize { return PDL->null } sub new { @@ -126,7 +136,7 @@ inheritance scheme will be called by B's constructor: $mypdl = MyPDL->new( required_attr => 2 ); -It's also called when B needs to create an object to recieve +It's also called when B needs to create an object to receive the results of a B operation on a B object: $newpdl = $mypdl + 1; @@ -135,7 +145,7 @@ There's one wrinkle, however. B I create an object without any extra attributes (it cannot know which values to give them) so B is called with a I argument, the class name. This means that C<$newpdl> will be an I B object, -i.e. C is uninitiailzed. This can I confuse +i.e. C is uninitialized. This can I confuse polymorphic code which operates differently when handed a B or B object. diff --git a/t/classes.t b/t/classes.t index 98e09bc..f8c5690 100644 --- a/t/classes.t +++ b/t/classes.t @@ -74,7 +74,7 @@ for my $Class ( qw[ subtest $Class => sub { - my @args = ( PDL => pdl( 0, 1 ) ); + my @args = ( PDL => pdl( 0, 1 ) ); my $mpdl = $Class->new( $Class->requires_hash ? { @args } : @args ); @@ -112,12 +112,12 @@ for my $Class ( qw[ cmp_deeply( $mpdl->unpdl, [ 0, 2 ], 'mpdl * 2' ); } - { - my $pdl = $mpdl->sequence(10); - isa_ok( $pdl, 'PDL' ); - ok ( ! $pdl->isa( $Class ),"new pdl is not a $Class" ); - cmp_deeply( $pdl->unpdl, [0..9], "result of sequence call" ); - } + { + my $pdl = $mpdl->sequence(10); + isa_ok( $pdl, 'PDL' ); + ok ( ! $pdl->isa( $Class ),"new pdl is not a $Class" ); + cmp_deeply( $pdl->unpdl, [0..9], "result of sequence call" ); + } };