File: y.t

package info (click to toggle)
libdate-iso8601-perl 0.005-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 116 kB
  • sloc: perl: 216; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use warnings;
use strict;

use Test::More tests => 1 + 3*14;

BEGIN { use_ok "Date::ISO8601", qw(present_y); }

my $have_bigint = eval("use Math::BigInt; 1");
my $have_bigrat = eval("use Math::BigRat 0.02; 1");

my @prep = (
	sub { $_[0] },
	sub { $have_bigint ? Math::BigInt->new($_[0]) : undef },
	sub { $have_bigrat ? Math::BigRat->new($_[0]) : undef },
);

sub check($$) {
	my($y, $pres) = @_;
	foreach my $prep (@prep) { SKIP: {
		my $py = $prep->($y);
		skip "numeric type unavailable", 1 unless defined $py;
		is present_y($py), $pres;
	} }
}

check(-123456, "-123456");
check(-12345, "-12345");
check(-1234, "-1234");
check(-123, "-0123");
check(-12, "-0012");
check(-1, "-0001");
check(0, "0000");
check(1, "0001");
check(12, "0012");
check(123, "0123");
check(1234, "1234");
check(12345, "+12345");
check(123456, "+123456");
check("+00000123", "0123");

1;