8 # Before `make install' is performed this script should be runnable with
9 # `make test'. After `make install' it should work as `perl test.pl'
11 ######################### We start with some black magic to print on failure.
13 # Change 1..1 below to 1..last_test_to_print .
14 # (It may become useful if the test is moved to ./t subdirectory.)
16 BEGIN { $| = 1; print "1..45\n"; }
17 END {print "not ok 1\n" unless $loaded;}
18 use Text::Balanced qw ( extract_delimited );
22 use vars qw( $DEBUG );
23 sub debug { print "\t>>>",@_ if $DEBUG }
25 ######################### End of black magic.
30 while (defined($str = <DATA>))
33 if ($str =~ s/\A# USING://) { $neg = 0; $cmd = $str; next; }
34 elsif ($str =~ /\A# TH[EI]SE? SHOULD FAIL/) { $neg = 1; next; }
35 elsif (!$str || $str =~ /\A#/) { $neg = 0; next }
37 debug "\tUsing: $cmd\n";
38 debug "\t on: [$str]\n";
40 $var = eval "() = $cmd";
41 debug "\t list got: [$var]\n";
42 debug "\t list left: [$str]\n";
43 print "not " if (substr($str,pos($str)||0,1) eq ';')==$neg;
44 print "ok ", $count++;
45 print " ($@)" if $@ && $DEBUG;
50 $var = "<undef>" unless defined $var;
51 debug "\t scalar got: [$var]\n";
52 debug "\t scalar left: [$str]\n";
53 print "not " if ($str =~ '\A;')==$neg;
54 print "ok ", $count++;
55 print " ($@)" if $@ && $DEBUG;
60 # USING: extract_delimited($str,'/#$',undef,'/#$');
68 # TEST EXTRACTION OF DELIMITED TEXT WITH ESCAPES
69 # USING: extract_delimited($str,'/#$',undef,'\\');
77 # TEST EXTRACTION OF DELIMITED TEXT
78 # USING: extract_delimited($str);
90 # TEST EXTRACTION OF DELIMITED TEXT
91 # USING: extract_delimited($str,'/#$','-->');