Skip to content
Browse files

Added suport for 2 part versions like 10.3 and added a couple more te…

…sts to increase the code coverage slightly
  • Loading branch information...
1 parent 3427cea commit 587d0db79e9444526198ee2e1eaad3995ee2d24f Colin committed Jul 6, 2010
Showing with 10 additions and 5 deletions.
  1. +3 −3 lib/Devel/Platform/Info/Mac.pm
  2. +7 −2 t/51mac_mock.t
View
6 lib/Devel/Platform/Info/Mac.pm
@@ -28,12 +28,12 @@ sub get_info {
$self->{info}{oslabel} = 'OS X';
my $productversion = $self->_command('sw_vers -productVersion');
- if ($productversion =~ /(\d+)\.(\d+)\.(\d+)/) {
- my ($major, $minor, $release) = ($1, $2, $3);
+ if ($productversion =~ /((\d+)\.(\d+)(\.(\d+))?)/) {
+ my ($version, $major, $minor) = ($1, $2, $3);
my $versions = _macos_versions();
if (my $codename = $versions->{"$major.$minor"}) {
$self->{info}{codename} = $codename;
- $self->{info}{osvers} = "$major.$minor.$release";
+ $self->{info}{osvers} = $version;
}
}
}
View
9 t/51mac_mock.t
@@ -7,12 +7,17 @@ use Devel::Platform::Info::Mac;
eval "use Test::MockObject::Extends";
plan skip_all => "Test::MockObject::Extends required for these tests" if $@;
-plan tests => 9*3;
+plan tests => 29;
my $macInfo = Devel::Platform::Info::Mac->new();
my $mock = Test::MockObject::Extends->new($macInfo);
-$mock->set_series('_command', 'Darwin', '10.3', 'PPC', 'Darwin 1', 'uname -a');
+$mock->set_series('_command', '', '', '', '', '');
my $info = $macInfo->get_info();
+is($info->{osname}, 'Mac');
+is($info->{osflag}, $^O);
+
+$mock->set_series('_command', 'Darwin', '10.3', 'PPC', 'Darwin 1', 'uname -a');
+$info = $macInfo->get_info();
is($info->{osname}, 'Mac');
is($info->{osflag}, $^O);

0 comments on commit 587d0db

Please sign in to comment.
Something went wrong with that request. Please try again.