Subject: | [TEST ATTACHED] Confusing order-specific error messages |
This confused me, the error message was totally erroneous when it
occurred in a specific place. Both of these documents should return
similar errors.
Subject: | confusing_error_messages.t |
##
## This test shows order-sensative lexer error messages
## Evan Carroll <me@evancarroll.com>
##
use Test::More tests => 3;
use YAML;
my $error_at_first = << "END";
## This document has an error in second element
---
foo:
bar: bar
foo:foo,foo
END
my $error_at_second = << "END";
## This document has an error in first element
---
foo:
foo:foo,foo
bar: bar
END
eval { YAML::Load( $error_at_first ); };
my $err1 = join '', grep /CODE/i, split $/, $@;
unlike ( $@, qr/Expected separator '---'/, "confusing error token not found" );
eval { YAML::Load( $error_at_second ); };
my $err2 = join '', grep /CODE/i, split $/, $@;
unlike ( $@, qr/Expected separator '---'/, "confusing error token not found" );
is( $err1, $err2, "Same error returned for the same typo" );