Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

A little bit of tidying up.

  • Loading branch information...
commit 7d6696e02ca2ea90904b5465ec8bde89c0ccc8a6 1 parent 9b498dc
Dave Cross authored July 25, 2013
8  lib/Number/Fraction.pm
@@ -221,7 +221,8 @@ around BUILDARGS => sub {
221 221
   my $class = shift;
222 222
 
223 223
   if (@_ >= 2) {
224  
-    die "numinator and denominator both need to be integers" unless $_[0] =~ /^-?[0-9]+\z/ and $_[1] =~ /^-?[0-9]+\z/;
  224
+    die "numerator and denominator both need to be integers"
  225
+      unless $_[0] =~ /^-?[0-9]+\z/ and $_[1] =~ /^-?[0-9]+\z/;
225 226
 
226 227
     return $class->$orig({ num => $_[0], den => $_[1] });
227 228
   } elsif (@_ == 1) {
@@ -232,7 +233,8 @@ around BUILDARGS => sub {
232 233
         die "Can't make a $class from a ", ref $_[0];
233 234
       }
234 235
     } else {
235  
-      die "numinator and denominator both need to be integers" unless $_[0] =~ m|^(-?[0-9]+)(?:/(-?[0-9]+))?\z|;
  236
+      die "numerator and denominator both need to be integers"
  237
+        unless $_[0] =~ m|^(-?[0-9]+)(?:/(-?[0-9]+))?\z|;
236 238
 
237 239
       return $class->$orig({ num => $1, den => ( defined $2 ? $2 : 1) });
238 240
     }
@@ -250,7 +252,7 @@ normalised format.
250 252
 
251 253
 sub BUILD {
252 254
   my $self = shift;
253  
-  die "Denominator can\'t be equal to \'zero\'" if $self->{den} == 0;
  255
+  die "Denominator can't be equal to zero" if $self->{den} == 0;
254 256
   $self->_normalise;
255 257
 }
256 258
 
2  t/15_zeroes.t
@@ -8,7 +8,7 @@ $f = eval { Number::Fraction->new(1 , 0 ) };
8 8
 ok($@, "Denominator of zero should not allowed in two ints" );
9 9
 
10 10
 my $zero = Number::Fraction->new (0);
11  
-cmp_ok($zero, '==', 0, "created a \'zero\' fraction");
  11
+cmp_ok($zero, '==', 0, "created a 'zero' fraction");
12 12
 
13 13
 my $qrtr = Number::Fraction->new('1/4');
14 14
 cmp_ok($qrtr, '==', 0.25, "Created 1/4");
7  t/16_decimals.t
@@ -7,7 +7,8 @@ $fract = eval { Number::Fraction->new(3.0 , 4) };
7 7
 cmp_ok($fract, 'eq' , '3/4', "fraction from round decimal numinator as number"); 
8 8
 
9 9
 $fract = eval {Number::Fraction->new(3 , 4.0) };
10  
-cmp_ok($fract, 'eq' , '3/4', "fraction from round decimal denominator as number");
  10
+cmp_ok($fract, 'eq' , '3/4',
  11
+       "fraction from round decimal denominator as number");
11 12
 
12 13
 $fract = eval {Number::Fraction->new('3', '4' ) };
13 14
 ok($@, "fraction from two healty strings not supported, use numbers instead");
@@ -19,8 +20,8 @@ $fract = eval {Number::Fraction->new('3' , '4.0') };
19 20
 ok($@, "fraction from round decimal denominator as string not supported");
20 21
 
21 22
 $fract = eval {Number::Fraction->new(3.5, 4 ) };
22  
-ok($@, "Numinator can\'t be a decimal");
  23
+ok($@, "Numerator can't be a decimal");
23 24
 
24 25
 $fract = eval {Number::Fraction->new(3 , 4.5) };
25  
-ok($@, "Denominator can\'t be a decimal");
  26
+ok($@, "Denominator can't be a decimal");
26 27
 

0 notes on commit 7d6696e

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