Skip to content

Commit

Permalink
add more boilerplate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djerius committed May 31, 2017
1 parent 3a5f703 commit ef7cff7
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.

Expand Down
29 changes: 25 additions & 4 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
};
32 changes: 28 additions & 4 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 12 additions & 2 deletions lib/PDLx/DetachedObject.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -126,7 +136,7 @@ inheritance scheme will be called by B<MyPDL>'s constructor:
$mypdl = MyPDL->new( required_attr => 2 );
It's also called when B<PDL> needs to create an object to recieve
It's also called when B<PDL> needs to create an object to receive
the results of a B<PDL> operation on a B<MyPDL> object:
$newpdl = $mypdl + 1;
Expand All @@ -135,7 +145,7 @@ There's one wrinkle, however. B<PDL> I<must> create an object without
any extra attributes (it cannot know which values to give them) so
B<initialize()> is called with a I<single> argument, the class name.
This means that C<$newpdl> will be an I<incomplete> B<MyPDL> object,
i.e. C<required_attr> is uninitiailzed. This can I<really> confuse
i.e. C<required_attr> is uninitialized. This can I<really> confuse
polymorphic code which operates differently when handed a B<PDL> or
B<MyPDL> object.
Expand Down
14 changes: 7 additions & 7 deletions t/classes.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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" );
}

};

Expand Down

0 comments on commit ef7cff7

Please sign in to comment.