-
Notifications
You must be signed in to change notification settings - Fork 138
/
045-generated_file_header.t
106 lines (76 loc) · 2.36 KB
/
045-generated_file_header.t
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#! perl
# Copyright (C) 2007, Parrot Foundation.
# $Id$
use strict;
use warnings;
use Test::More tests => 12;
use Carp;
use File::Temp qw| tempfile |;
use lib qw( lib );
use Parrot::BuildUtil;
{
my $header;
my ( $filename, $style ) = ( 'foobar', 'SPAF' );
eval { $header = Parrot::BuildUtil::generated_file_header( $filename, $style ); };
like(
$@,
qr/unknown style /,
'error when no arguments passed',
);
}
{
my $header;
my ( $filename, $style ) = ( 'foobar', 'perl' );
require File::Spec;
my $script = File::Spec->abs2rel($0);
$script =~ s/\\/\//g;
eval { $header = Parrot::BuildUtil::generated_file_header( $filename, $style ); };
is( $@, '', "no error when called with '$style' style" );
like( $header, qr/ft=perl:/, "filetype set to '$style'" );
like( $header, qr/from '$filename'/, 'filename set' );
like( $header, qr/by $script/, 'script set' );
my @header = split /\n/ => $header;
is(
@{[ grep( { /^# / } @header ) ]},
@header,
'each line starts with a comment marker',
);
}
{
my $header;
my ( $filename, $style ) = ( 'foobar', 'c' );
require File::Spec;
my $script = File::Spec->abs2rel($0);
$script =~ s/\\/\//g;
eval { $header = Parrot::BuildUtil::generated_file_header( $filename, $style ); };
is( $@, '', "no error when called with '$style' style" );
like( $header, qr/ft=c:/, "filetype set to '$style'" );
like( $header, qr/from '$filename'/, 'filename set' );
like( $header, qr/by $script/, 'script set' );
my @header = split /\n/ => $header;
is(
@{[ grep( { /^[ \/]\*[ \/]?/ } @header ) ]},
@header,
'each line starts with a comment marker',
);
}
pass("Completed all tests in $0");
################### DOCUMENTATION ###################
=head1 NAME
044-generated_file_header.t - test C<Parrot::BuildUtil::generated_file_header()>
=head1 SYNOPSIS
% prove t/configure/045-generated_file_header.t
=head1 DESCRIPTION
The files in this directory test functionality used by F<Configure.pl>.
The tests in this file test C<Parrot::BuildUtil::generated_file_header()>.
=head1 AUTHOR
James E Keenan
=head1 SEE ALSO
Parrot::BuildUtil, F<Configure.pl>.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: