Skip to content

Commit

Permalink
Added tests with data from real runs from CPAN testers
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin committed Jul 6, 2010
1 parent 7f3d689 commit 3427cea
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Devel/Platform/Info/Mac.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sub new {
sub get_info { sub get_info {
my $self = shift; my $self = shift;
$self->{info}{osname} = 'Mac'; $self->{info}{osname} = 'Mac';
$self->{info}{osflag} = $^O;


my $uname_s = $self->_command('uname -s'); my $uname_s = $self->_command('uname -s');
if ($uname_s =~ /Darwin/i) { if ($uname_s =~ /Darwin/i) {
Expand Down Expand Up @@ -160,4 +161,4 @@ RT Queue: http://rt.cpan.org/Public/Dist/Display.html?Name=Devel-Platform-Info
This module is free software; you can redistribute it and/or This module is free software; you can redistribute it and/or
modify it under the Artistic License 2.0. modify it under the Artistic License 2.0.
=cut =cut
28 changes: 27 additions & 1 deletion t/51mac_mock.t
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Devel::Platform::Info::Mac;
eval "use Test::MockObject::Extends"; eval "use Test::MockObject::Extends";
plan skip_all => "Test::MockObject::Extends required for these tests" if $@; plan skip_all => "Test::MockObject::Extends required for these tests" if $@;


plan tests => 9; plan tests => 9*3;


my $macInfo = Devel::Platform::Info::Mac->new(); my $macInfo = Devel::Platform::Info::Mac->new();
my $mock = Test::MockObject::Extends->new($macInfo); my $mock = Test::MockObject::Extends->new($macInfo);
Expand All @@ -24,5 +24,31 @@ is($info->{is32bit}, 1);
is($info->{is64bit}, 0); is($info->{is64bit}, 0);
is($info->{kernel}, 'Darwin 1'); is($info->{kernel}, 'Darwin 1');


$mock->set_series('_command', 'Darwin', '10.4.11', 'powerpc', 'Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC', 'Darwin somewhere.co.uk 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc');
$info = $macInfo->get_info();

is($info->{osname}, 'Mac');
is($info->{osflag}, $^O);
is($info->{oslabel}, 'OS X');
is($info->{codename}, 'Tiger');
is($info->{osvers}, '10.4.11');
is($info->{archname}, 'powerpc');
is($info->{is32bit}, 1);
is($info->{is64bit}, 0);
is($info->{kernel}, 'Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC');

$mock->set_series('_command', 'Darwin', '10.4.11', 'i386', 'Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386', 'Darwin somehost 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386');
$info = $macInfo->get_info();

is($info->{osname}, 'Mac');
is($info->{osflag}, $^O);
is($info->{oslabel}, 'OS X');
is($info->{codename}, 'Tiger');
is($info->{osvers}, '10.4.11');
is($info->{archname}, 'i386');
is($info->{is32bit}, 1);
is($info->{is64bit}, 0);
is($info->{kernel}, 'Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386');

# use Data::Dumper; # use Data::Dumper;
# print Dumper($info); # print Dumper($info);

0 comments on commit 3427cea

Please sign in to comment.