Skip to content

Commit

Permalink
Add multiline diff support
Browse files Browse the repository at this point in the history
Use one of:

    Diff = 1
    --- DIFF
  • Loading branch information
ingydotnet committed Apr 27, 2014
1 parent 4b462fe commit b3e1185
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/TestML/Compiler/Pegex/AST.pm
Expand Up @@ -94,6 +94,9 @@ sub got_point_object {

sub got_assertion_call {
my ($self, $call) = @_;
# XXX $call strangley becomes an array when $PERL_PEGEX_DEBUG is on.
# Workaround for now, until I figure it out.
$call = $call->[0] if ref $call eq 'ARRAY';
my ($name, $expr);
for (qw( eq has ok )) {
if ($expr = $call->{"assertion_$_"}) {
Expand Down
22 changes: 20 additions & 2 deletions lib/TestML/Runtime/TAP.pm
Expand Up @@ -59,9 +59,27 @@ sub plan_end {
# TODO Use Test::Diff here.
sub assert_EQ {
my ($self, $got, $want) = @_;
$got = $got->str->value;
$want = $want->str->value;
if ($got ne $want and $want =~ /\n/) {
my $block = $self->function->getvar('Block');
my $diff = $self->function->getvar('Diff');
if ($diff or exists $block->points->{DIFF}) {
require Text::Diff;
$self->tap_object->ok(0, $self->get_label);
my $diff = Text::Diff::diff(
\$want, \$got, {
FILENAME_A => "want",
FILENAME_B => "got",
},
);
$self->tap_object->diag($diff);
return;
}
}
$self->tap_object->is_eq(
$got->str->value,
$want->str->value,
$got,
$want,
$self->get_label,
);
}
Expand Down

0 comments on commit b3e1185

Please sign in to comment.