6 # Before `make install' is performed this script should be runnable with
7 # `make test'. After `make install' it should work as `perl test.pl'
9 ######################### We start with some black magic to print on failure.
11 # Change 1..1 below to 1..last_test_to_print .
12 # (It may become useful if the test is moved to ./t subdirectory.)
14 BEGIN { $| = 1; print "1..45\n"; }
15 END {print "not ok 1\n" unless $loaded;}
16 use Text::Balanced qw ( extract_delimited );
20 use vars qw( $DEBUG );
21 sub debug { print "\t>>>",@_ if $DEBUG }
23 ######################### End of black magic.
28 while (defined($str = <DATA>))
31 if ($str =~ s/\A# USING://) { $neg = 0; $cmd = $str; next; }
32 elsif ($str =~ /\A# TH[EI]SE? SHOULD FAIL/) { $neg = 1; next; }
33 elsif (!$str || $str =~ /\A#/) { $neg = 0; next }
35 debug "\tUsing: $cmd\n";
36 debug "\t on: [$str]\n";
38 $var = eval "() = $cmd";
39 debug "\t list got: [$var]\n";
40 debug "\t list left: [$str]\n";
41 print "not " if (substr($str,pos($str)||0,1) eq ';')==$neg;
42 print "ok ", $count++;
43 print " ($@)" if $@ && $DEBUG;
48 $var = "<undef>" unless defined $var;
49 debug "\t scalar got: [$var]\n";
50 debug "\t scalar left: [$str]\n";
51 print "not " if ($str =~ '\A;')==$neg;
52 print "ok ", $count++;
53 print " ($@)" if $@ && $DEBUG;
58 # USING: extract_delimited($str,'/#$',undef,'/#$');
66 # TEST EXTRACTION OF DELIMITED TEXT WITH ESCAPES
67 # USING: extract_delimited($str,'/#$',undef,'\\');
75 # TEST EXTRACTION OF DELIMITED TEXT
76 # USING: extract_delimited($str);
88 # TEST EXTRACTION OF DELIMITED TEXT
89 # USING: extract_delimited($str,'/#$','-->');