1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
4 ######################### We start with some black magic to print on failure.
6 # Change 1..1 below to 1..last_test_to_print .
7 # (It may become useful if the test is moved to ./t subdirectory.)
9 BEGIN { $| = 1; print "1..45\n"; }
10 END {print "not ok 1\n" unless $loaded;}
11 use Text::Balanced qw ( extract_delimited );
15 use vars qw( $DEBUG );
16 sub debug { print "\t>>>",@_ if $DEBUG }
18 ######################### End of black magic.
23 while (defined($str = <DATA>))
26 if ($str =~ s/\A# USING://) { $neg = 0; $cmd = $str; next; }
27 elsif ($str =~ /\A# TH[EI]SE? SHOULD FAIL/) { $neg = 1; next; }
28 elsif (!$str || $str =~ /\A#/) { $neg = 0; next }
30 debug "\tUsing: $cmd\n";
31 debug "\t on: [$str]\n";
33 $var = eval "() = $cmd";
34 debug "\t list got: [$var]\n";
35 debug "\t list left: [$str]\n";
36 print "not " if (substr($str,pos($str)||0,1) eq ';')==$neg;
37 print "ok ", $count++;
38 print " ($@)" if $@ && $DEBUG;
43 $var = "<undef>" unless defined $var;
44 debug "\t scalar got: [$var]\n";
45 debug "\t scalar left: [$str]\n";
46 print "not " if ($str =~ '\A;')==$neg;
47 print "ok ", $count++;
48 print " ($@)" if $@ && $DEBUG;
53 # USING: extract_delimited($str,'/#$',undef,'/#$');
61 # TEST EXTRACTION OF DELIMITED TEXT WITH ESCAPES
62 # USING: extract_delimited($str,'/#$',undef,'\\');
70 # TEST EXTRACTION OF DELIMITED TEXT
71 # USING: extract_delimited($str);
83 # TEST EXTRACTION OF DELIMITED TEXT
84 # USING: extract_delimited($str,'/#$','-->');