summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-05-11 17:48:45 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-05-11 17:48:45 +0200
commitb0eb2aa49c97188d4fd25b609f360d5da8c09bca (patch)
treee7a298f66c14c11b83a50b393a1be7d4101f5879 /bin
parentd2f853a93688c51c3dc0d563b95b5de6fe879a0e (diff)
Add some actual parser tests
Diffstat (limited to 'bin')
-rwxr-xr-xbin/efa32
1 files changed, 23 insertions, 9 deletions
diff --git a/bin/efa b/bin/efa
index edd67d2..01b66d3 100755
--- a/bin/efa
+++ b/bin/efa
@@ -33,6 +33,7 @@ my $walk_speed;
my $with_bike;
my $debug = 0;
my $ignore_info = 'Fahrradmitnahme';
+my ($test_dump, $test_parse);
sub check_ambiguous {
my $html = shift;
@@ -217,6 +218,8 @@ GetOptions(
'P|prefer=s' => \$prefer,
'p|proximity' => \$proximity,
'i|include=s' => \$include,
+ 'test-dump' => \$test_dump,
+ 'test-parse' => \$test_parse,
't|time=s' => \$time,
'to=s{2}' => \@to,
'to-type=s' => \$to_type,
@@ -288,7 +291,7 @@ if ($time) {
@post{'itdTimeHour', 'itdTimeMinute'} = split(/:/, $time);
}
if ($date) {
- if ($date !~ /^ [0-3]? \d \. [01]? \d (?: \. \d{4} )? $/x) {
+ if ($date !~ /^ [0-3]? \d \. [01]? \d \. (?: \d{4} )? $/x) {
die("Invalid argument: Usage: --date DD.MM[.YYYY]\n");
}
@post{'itdDateDay', 'itdDateMonth', 'itdDateYear'} = split(/\./, $date);
@@ -361,15 +364,26 @@ if ($with_bike) {
$post{bikeTakeAlong} = 1;
}
-$www->get($firsturl);
-$www->submit_form(
- form_name => 'jp',
- fields => \%post,
-);
+if ($test_parse) {
+ local $/;
+ $content = <STDIN>;
+}
+else {
+ $www->get($firsturl);
+ $www->submit_form(
+ form_name => 'jp',
+ fields => \%post,
+ );
+
+ $content = $www->content;
+ $content =~ s/\xa0/ /gs;
+ $content = decode('iso-8859-1', $content);
+}
-$content = $www->content;
-$content =~ s/\xa0/ /gs;
-$content = decode('iso-8859-1', $content);
+if ($test_dump) {
+ print $content;
+ exit 0
+}
if (check_ambiguous($content)) {
exit 1;