Codebase list libtest-inter-perl / 585b1b2
[svn-upgrade] new version libtest-inter-perl (1.02) Maximilian Gass 12 years ago
13 changed file(s) with 91 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
77 'IO::File' => '0',
88 );
99 my %build_mods = (
10 'Test::Pod' => '0',
11 'Test::Pod::Coverage' => '0',
1210 );
1311
1412
1513 my $build = Module::Build->new(
1614 license => 'perl',
17 dist_version => '1.01',
15 dist_version => '1.02',
1816 dist_author => 'Sullivan Beck <sbeck@cpan.org>',
1917 module_name => 'Test::Inter',
2018 dist_abstract => 'framework for more readable interactive test scripts',
2119 requires => \%requires,
22 build_requires => {},
23 build_recommends => \%build_mods,
20 build_requires => \%build_mods,
2421 sign => 1,
2522 );
2623
44 Version 1.01 2010-04-29
55 Use File::Basename and IO::File to get rid of two unix dependencies.
66
7 Version 1.02 2011-06-23
8 Added 'width' method.
9 Updated some tests which did not run correctly with perl 5.015. Renee Baecker
10
11 Version 1.03
1212 provides:
1313 Test::Inter:
1414 file: lib/Test/Inter.pm
15 version: 1.01
15 version: 1.02
1616 requires:
1717 File::Basename: 0
1818 IO::File: 0
1919 perl: 5.004
2020 resources:
2121 license: http://dev.perl.org/licenses/
22 version: 1.01
22 version: 1.02
55 my %requires = (
66 'File::Basename' => '0',
77 'IO::File' => '0',
8 'Test::Pod' => '0',
9 'Test::Pod::Coverage' => '0',
108 );
119
1210
1311 WriteMakefile(
1412 NAME => 'Test::Inter',
15 VERSION => '1.01',
13 VERSION => '1.02',
1614 ($] >= 5.004
1715 ? (ABSTRACT=>'framework for more readable interactive test scripts',
1816 AUTHOR =>'Sullivan Beck (sbeck@cpan.org)')
233233 quiet
234234 mode
235235 skip_all
236 width
236237
237238 version
238239 $o->version();
368369 When run in interactive mode, it prints out results in a more human
369370 readable format.
370371
372 width
373 $o = new Test::Inter 'width' => WIDTH;
374 $o->width(WIDTH);
375
376 The width option can be set using a ('width',WIDTH) option pair, or
377 by setting the TI_WIDTH environment variable, or the $::TI_WIDTH
378 global variable.
379
380 WIDTH is the width of the terminal (for printing out failed test
381 information). It defaults to 80, but it can be set to any width (and
382 lines longer then this are truncated). If WIDTH is set to 0, no
383 truncation is done.
384
371385 skip_all
372386 $o = new Test::Inter 'skip_all' => REASON;
373387 $o->skip_all(REASON);
457471
458472 If $mode is passed in, it must be either the string 'forbid' or
459473 'feature'.
474
475 If $mode is 'feature', a feature named $module is set if the module
476 was able to be loaded.
460477
461478 use_ok
462479 $o->use_ok(@args [,$mode]);
888905 tests => "(a b) c"
889906
890907 Although parens are optional, they may make things more readable, and
891 allow you to use something other than whitespsace as the delimiter.
908 allow you to use something other than whitespace as the delimiter.
892909
893910 If the character immediately following the opening paren, brace, or
894911 bracket is a punctuation mark, then it is used as the delimiter instead
974991
975992 I wrote a very basic version of my test framework which allowed me to
976993 write all of the tests as a string, it would parse the string, count the
977 tests, ad then run them.
994 tests, and then run them.
978995
979996 Over the years, the functionality I wanted grew, and periodically, I'd
980997 go back and reexamine other Test frameworks (primarily Test::More) to
1919 Test::Slow
2020 to see if there's anything I want to add.
2121
22 Look at using Data::PrettyPrintObjects to print out the results.
23
24 Add support for timing tests:
25
26 ok 1 (12 ms)
27 ok 2 (23 ms)
28
22 use strict;
33 use warnings;
44
5 use vars qw($o);
5 our($o);
66
77 BEGIN {
88 print "The first test will fail, all others will be skipped.\n\n";
1111 use File::Basename;
1212 use IO::File;
1313
14 use vars qw($VERSION);
15 $VERSION = '1.01';
14 our($VERSION);
15 $VERSION = '1.02';
1616
1717 ###############################################################################
1818 # BASE METHODS
4848 # (this should only be done when
4949 # running as an interactive script)
5050 'mode' => 'test', # mode to run script in
51 'width' => 80, # width of terminal
5152 'features' => {}, # a list of available features
5253
5354 'skipall' => '', # the reason for skipping all
6566
6667 # Handle options, environment variables, global variables
6768
68 my @opts = qw(start end testnum plan abort quiet mode skip_all);
69 my @opts = qw(start end testnum plan abort quiet mode width skip_all);
6970 my %o = map { $_,1 } @opts;
7071
7172 no strict 'refs';
208209 my($self,$val) = @_;
209210 $val = 'test' if (! $val);
210211 $$self{'mode'} = $val;
212 }
213
214 sub width {
215 my($self,$val) = @_;
216 $val = 0 if (! $val);
217 $$self{'width'} = $val;
211218 }
212219
213220 sub skip_all {
713720 sub _stringify {
714721 my($self,$s) = @_;
715722
716 my($str) = $self->__stringify($s);
717 $str = substr($str,0,60) if (length($str)>60);
723 my($str) = $self->__stringify($s);
724 my($width) = $$self{'width'};
725 if ($width) {
726 $width -= 21; # The leading string
727 $width = 10 if ($width < 10);
728 $str = substr($str,0,$width) if (length($str)>$width);
729 }
718730 return $str;
719731 }
732
720733 sub __stringify {
721734 my($self,$s) = @_;
722735
268268 quiet
269269 mode
270270 skip_all
271 width
271272
272273 =item B<version>
273274
411412 When run in interactive mode, it prints out results in a more
412413 human readable format.
413414
415 =item B<width>
416
417 $o = new Test::Inter 'width' => WIDTH;
418 $o->width(WIDTH);
419
420 The width option can be set using a ('width',WIDTH) option pair, or
421 by setting the TI_WIDTH environment variable, or the $::TI_WIDTH
422 global variable.
423
424 WIDTH is the width of the terminal (for printing out failed test
425 information). It defaults to 80, but it can be set to any width (and
426 lines longer then this are truncated). If WIDTH is set to 0, no
427 truncation is done.
428
414429 =item B<skip_all>
415430
416431 $o = new Test::Inter 'skip_all' => REASON;
517532
518533 If $mode is passed in, it must be either the string 'forbid' or
519534 'feature'.
535
536 If $mode is 'feature', a feature named $module is set if the module
537 was able to be loaded.
520538
521539 =item B<use_ok>
522540
690708
691709 =over 4
692710
693 =item name
711 =item B<name>
694712
695713 name => NAME
696714
697715 This sets the name of this set of tests. All tests will be given the
698716 same name.
699717
700 =item tests
701
702 =item func
703
704 =item expected
718 =item B<tests>
719
720 =item B<func>
721
722 =item B<expected>
705723
706724 In order to specify a series of tests, you have to specify either
707725 a function and a list of arguments, or a list of results.
725743
726744 The way to specify these are covered in the next section SPECIFYING THE TESTS.
727745
728 =item feature
729
730 =item disable
746 =item B<feature>
747
748 =item B<disable>
731749
732750 feature => [FEATURE1, FEATURE2, ...]
733751
745763 If the disable option is included, the tests will be run unless ANY of the features
746764 listed are available.
747765
748 =item skip
766 =item B<skip>
749767
750768 skip => REASON
751769
752770 Skip these tests for the reason given.
753771
754 =item todo
772 =item B<todo>
755773
756774 todo => 0/1
757775
974992 tests => "(a b) c"
975993
976994 Although parens are optional, they may make things more readable, and allow
977 you to use something other than whitespsace as the delimiter.
995 you to use something other than whitespace as the delimiter.
978996
979997 If the character immediately following the opening paren, brace, or
980998 bracket is a punctuation mark, then it is used as the delimiter
10611079
10621080 I wrote a very basic version of my test framework which allowed me to
10631081 write all of the tests as a string, it would parse the string, count
1064 the tests, ad then run them.
1082 the tests, and then run them.
10651083
10661084 Over the years, the functionality I wanted grew, and periodically, I'd
10671085 go back and reexamine other Test frameworks (primarily Test::More) to
66 my $o = new Test::Inter;
77
88 $o->require_ok('5.001');
9 $o->require_ok('5.015','forbid');
9 $o->require_ok('7.001','forbid');
1010 $o->require_ok('Config');
1111 $o->require_ok('Xxx::Yyy','forbid');
1212 $o->require_ok('Symbol','feature');
22 use strict;
33 use warnings;
44
5 use vars qw($o);
5 our($o);
66
77 BEGIN {
88 use Test::Inter;
22 use strict;
33 use warnings;
44
5 use vars qw($o);
5 our($o);
66
77 BEGIN {
88 use Test::Inter;
22 use strict;
33 use warnings;
44
5 use vars qw($o);
5 our($o);
66
77 BEGIN {
88 use Test::Inter;
99 $o = new Test::Inter;
1010 }
1111
12 BEGIN { $o->use_ok('5.015','forbid'); }
12 BEGIN { $o->use_ok('7.001','forbid'); }
1313 BEGIN { $o->use_ok('Config','xxxx','forbid'); }
1414 BEGIN { $o->use_ok('Storable',7.01,'dclone','forbid'); }
1515