1
- # !/usr/bin/env perl -W
1
+ # !/usr/bin/env perl
2
2
# Tests of :include, :macro Include, :immediate ProcessFile
3
3
use rlib ' ./lib' ;
4
4
use PerlPPTest;
5
- use constant CMD => ($ENV {PERLPP_CMD } || ' perl -Iblib/lib blib/script/perlpp' );
6
5
7
6
(my $whereami = __FILE__ ) =~ s / 04-include\. t$// ;
8
7
my $incfn = ' "' . $whereami . ' included.txt"' ;
@@ -11,31 +10,37 @@ diag "Including from $incfn\n";
11
10
my ($in , $out , $err );
12
11
13
12
my @testcases =(
14
- # [$in (the script), $out (expected output), $err (stderr output, if any)]
15
- [' <?:include ' . $incfn . ' ?>' ," a4b\n " ],
13
+ # [$lineno, $in (the script), $out (expected output),
14
+ # $err (stderr output, if any)]
15
+ [__LINE__ , ' <?:include ' . $incfn . ' ?>' ," a4b\n " ],
16
16
# The newline comes from included.txt, which ends with a newline
17
- [' Hello, <?:include ' . $incfn . ' ?>!' ," Hello, a4b\n !" ],
18
- [' <?:macro Include ' . $incfn . ' ?>' ," a4b\n " ],
19
- [' Hello, <?:macro Include ' . $incfn . ' ?>!' ," Hello, a4b\n !" ],
20
- [' <?:immediate ProcessFile ' . $incfn . ' ?>' ," a4b\n " ],
21
- [' Hello, <?:immediate ProcessFile ' . $incfn . ' ?>!' ," Hello, a4b\n !" ],
22
- [' <?:immediate for my $fn (qw(a b c)) { ' .
23
- ' ProcessFile "' . $whereami . ' " . $fn . ".txt"; } ?>' , " a\n b\n c\n " ],
24
- [' <?:macro for my $fn (qw(a b c)) { ' .
25
- ' Include "' . $whereami . ' " . $fn . ".txt"; } ?>' , " a\n b\n c\n " ],
17
+ [__LINE__ , ' Hello, <?:include ' . $incfn . ' ?>!' ," Hello, a4b\n !" ],
18
+ [__LINE__ , ' <?:macro $PSelf->Include(' . $incfn . ' ) ?>' ," a4b\n " ],
19
+ [__LINE__ , ' Hello, <?:macro $PSelf->Include(' . $incfn . ' ) ?>!' ,
20
+ " Hello, a4b\n !" ],
21
+ [__LINE__ , ' <?:immediate $PSelf->ProcessFile(' . $incfn . ' ) ?>' ," a4b\n " ],
22
+ [__LINE__ , ' Hello, <?:immediate $PSelf->ProcessFile(' . $incfn . ' ) ?>!' ,
23
+ " Hello, a4b\n !" ],
24
+ [__LINE__ , ' <?:immediate for my $fn (qw(a b c)) { ' .
25
+ " \$ PSelf->ProcessFile(\" ${whereami} \$ {fn}.txt\" ); } ?>" ,
26
+ " a\n b\n c\n " ],
27
+ [__LINE__ , ' <?:macro for my $fn (qw(a b c)) { ' .
28
+ " \$ PSelf->Include(\" ${whereami} \$ {fn}.txt\" ); } ?>" ,
29
+ " a\n b\n c\n " ],
26
30
); # @testcases
27
31
28
- plan tests => scalar @testcases ;
29
- # thanks to http://edumaven.com/test-automation-using-perl/test-calculated-plan
32
+ plan tests => count_tests(\@testcases , 2, 3);
30
33
31
34
for my $lrTest (@testcases ) {
32
- my ($testin , $refout , $referr ) = @$lrTest ;
33
- run3 CMD, \$testin , \$out , \$err ;
35
+ my ($lineno , $testin , $refout , $referr ) = @$lrTest ;
36
+ diag " <<<@{[Text::PerlPP::_QuoteString $testin ]}" ;
37
+ run_perlpp [], \$testin , \$out , \$err ;
38
+
34
39
if (defined $refout ) {
35
- is($out , $refout );
40
+ is($out , $refout , " stdout $lineno " );
36
41
}
37
42
if (defined $referr ) {
38
- is($err , $referr );
43
+ is($err , $referr , " stderr $lineno " );
39
44
}
40
45
41
46
} # foreach test
0 commit comments