1use 5.10.0;
2use strict;
3use warnings;
4use Time::Piece;
5use Test::More tests => 8;
6
7my $v             = -1;
8my $v_pod         = -1;
9my $v_linux       = -1;
10my $v_win32       = -1;
11my $v_const       = -1;
12my $v_cwdefault   = -1;
13my $v_cwwide      = -1;
14my $v_changes     = -1;
15my $release_date  = -1;
16
17open my $fh, '<', 'lib/Term/Choose.pm' or die $!;
18while ( my $line = <$fh> ) {
19    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
20        $v = $1;
21    }
22    if ( $line =~ /^=pod/ .. $line =~ /^=cut/ ) {
23        if ( $line =~ /^\s*Version\s+(\S+)/ ) {
24            $v_pod = $1;
25        }
26    }
27}
28close $fh;
29
30open $fh, '<', 'lib/Term/Choose/Linux.pm' or die $!;
31while ( my $line = <$fh> ) {
32    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
33        $v_linux = $1;
34    }
35}
36close $fh;
37
38open $fh, '<', 'lib/Term/Choose/Win32.pm' or die $!;
39while ( my $line = <$fh> ) {
40    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
41        $v_win32 = $1;
42    }
43}
44close $fh;
45
46open $fh, '<', 'lib/Term/Choose/Constants.pm' or die $!;
47while ( my $line = <$fh> ) {
48    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
49        $v_const = $1;
50    }
51}
52close $fh;
53
54open $fh, '<', 'lib/Term/Choose/LineFold/CharWidthDefault.pm' or die $!;
55while ( my $line = <$fh> ) {
56    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
57        $v_cwdefault = $1;
58    }
59}
60close $fh;
61
62open $fh, '<', 'lib/Term/Choose/LineFold/CharWidthAmbiguousWide.pm' or die $!;
63while ( my $line = <$fh> ) {
64    if ( $line =~ /^our\s\$VERSION\s=\s'(\d\.\d\d\d(?:_\d\d)?)';/ ) {
65        $v_cwwide = $1;
66    }
67}
68close $fh;
69
70open my $fh_ch, '<', 'Changes' or die $!;
71while ( my $line = <$fh_ch> ) {
72    if ( $line =~ /^\s*(\d+\.\d\d\d(?:_\d\d)?)\s+(\d\d\d\d-\d\d-\d\d)\s*\z/ ) {
73        $v_changes = $1;
74        $release_date = $2;
75        last;
76    }
77}
78close $fh_ch;
79
80my $t = localtime;
81my $today = $t->ymd;
82
83is( $v,            $v_pod,         'Version in POD Term::Choose OK' );
84is( $v,            $v_linux,       'Version in Term::Choose::Linux OK' );
85is( $v,            $v_win32,       'Version in Term::Choose::Win32 OK' );
86is( $v,            $v_const,       'Version in Term::Choose::Constants OK' );
87is( $v,            $v_cwdefault,   'Version in Term::Choose::LineFold::CharWidthDefault OK' );
88is( $v,            $v_cwwide,      'Version in Term::Choose::LineFold::CharWidthAmbiguousWide OK' );
89is( $v,            $v_changes,     'Version in "Changes" OK' );
90is( $release_date, $today,         'Release date in Changes is date from today' );
91