#!/usr/bin/perl use warnings; use strict; use Test::More qw(no_plan); use Shebangml::FromXML; sub mk_expect { my $data = shift; open(my $fh, '<', \$data); my @outs; my $test; my $current = ''; my $store = sub { my ($where) = @_; $current =~ s/^\s+//; $current =~ s/\s+$//; $test->{$where} = $current; $current = '' }; while(my $line = <$fh>) { if($line =~ m/^\s+=== */) { if($test) { $store->('want'); } $test = {}; push(@outs, $test); } elsif($line eq " ---\n") { $store->('input'); } else { $current .= $line; } } $store->('want'); return(@outs); } my @expect = mk_expect(<<'EXPECT'); ===
foo
--- p{foo} ===bar
bar
bar
bar\
bar\
bar