2 # Copyright (C) 2007, Parrot Foundation.
9 use Test::More tests => 14;
13 use File::Temp qw| tempdir |;
14 use lib qw( lib t/configure/testlib );
15 use Parrot::BuildUtil;
16 use Make_VERSION_File qw| make_VERSION_file |;
20 my $tdir = tempdir( CLEANUP => 1 );
21 ok( chdir $tdir, "Changed to temporary directory for testing" );
22 ok( ( mkdir "lib" ), "Able to make directory lib" );
23 ok( ( mkdir "lib/Parrot" ), "Able to make directory lib/Parrot" );
25 # Case 5: Valid version number
26 make_VERSION_file(q{0.4.11});
28 @pv = Parrot::BuildUtil::parrot_version();
29 is_deeply( \@pv, [ 0, 4, 11 ],
30 "Correct version number returned in list context" );
32 $pv = Parrot::BuildUtil::parrot_version();
34 "Correct version number returned in scalar context" );
37 or croak "Unable to delete file from tempdir after testing";
38 ok( chdir $cwd, "Able to change back to directory after testing" );
42 my $tdir = tempdir( CLEANUP => 1 );
43 ok( chdir $tdir, "Changed to temporary directory for testing" );
44 my $rv = set_bc_version(q{3.07});
45 my ($bc_major, $bc_minor) = Parrot::BuildUtil::get_bc_version();
46 is( $bc_major, 3, "Got expected bytecode major version" );
47 is( $bc_minor, 7, "Got expected bytecode minor version" );
49 ok( chdir $cwd, "Able to change back to directory after testing" );
53 my $tdir = tempdir( CLEANUP => 1 );
54 ok( chdir $tdir, "Changed to temporary directory for testing" );
55 my $rv = set_bc_version(q{3.tomboy});
57 my ($bc_major, $bc_minor) = Parrot::BuildUtil::get_bc_version();
59 like( $@, qr/No bytecode version found/,
60 "Got expected error message on failure to find bytecode version" );
62 ok( chdir $cwd, "Able to change back to directory after testing" );
65 pass("Completed all tests in $0");
68 my $version_str = shift;
69 my $compat_file = 'PBC_COMPAT';
70 my ( $bc_major, $bc_minor );
71 open my $OUT, '>', $compat_file or die "Can't write $compat_file";
72 print $OUT "$version_str\n";
77 ################### DOCUMENTATION ###################
81 023-version.t - test C<Parrot::BuildUtil::parrot_version()>
85 % prove t/configure/023-version.t
89 The files in this directory test functionality used by F<Configure.pl>.
91 The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
99 Parrot::BuildUtil, F<Configure.pl>.
105 # cperl-indent-level: 4
108 # vim: expandtab shiftwidth=4: