File: length.t

package info (click to toggle)
libclass-measure-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 441; makefile: 2
file content (24 lines) | stat: -rwxr-xr-x 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env perl
use 5.008001;
use strict;
use warnings;
use Test2::V0;

use Class::Measure::Length qw( length );

my @units = sort Class::Measure::Length->units;
my $first = shift(@units);
my $m = length( 10, $first );
foreach my $unit (@units){
    $m->set_unit($unit);
}
$m->set_unit($first);
ok( ( int($m->$first) == 10 ), 'run all conversions' );

my $foot = length( 12, 'inches' );
is( $foot->feet(), 1, '12 inches is 1 foot' );
my $yard = $foot * 3;
is( $yard->yards(), 1, '3 feet is 1 yard' );
is( $yard->inches(), 36, '1 yard is 36 inches' );

done_testing;