in reply to Re: Printing just the file name for all the cases
in thread Printing just the file name for all the cases
#!/usr/bin/perl -- use strict; use warnings; use Test::More qw' no_plan '; Main( @ARGV ); exit( 0 ); sub Main { Happy(\&pichi_nakodadaka, 'pichi_nakodadaka' ); Happy(\&pichi_nakodadaka2, 'pichi_nakodadaka2' ); } sub Happy { my( $ref, $name ) = @_; my @arg = ( [ '#include "string.h"', 'string.h' ], [ '#include <stdlib.h>', 'stdlib.h' ], [ '#include <sys/dispatch.h>', 'dispatch.h' ], ); for my $arg( @arg ){ my( $in, $expect ) = @$arg; my $got = $ref->($in); is($got, $expect , $name); } } sub pichi_nakodadaka { my( $in ) = @_; return $1 if $in =~ /#include [<"](\S+\.h)[>"]/ ; } sub pichi_nakodadaka2 { my( $in ) = @_; if( $in =~ /#include [<"](\S+\.h)[>"]/ ){ my $pichi_nakodadaka = $1; $pichi_nakodadaka =~ s!^.*?/!!g; return $pichi_nakodadaka; } } __END__ $ perl pm.894302.pl ok 1 - pichi_nakodadaka ok 2 - pichi_nakodadaka not ok 3 - pichi_nakodadaka # Failed test 'pichi_nakodadaka' # at pm.894302.pl line 33. # got: 'sys/dispatch.h' # expected: 'dispatch.h' ok 4 - pichi_nakodadaka2 ok 5 - pichi_nakodadaka2 ok 6 - pichi_nakodadaka2 1..6 # Looks like you failed 1 test of 6.
|
---|