From eff48d1eecb48dd2340d82ebbc3546529e0e7f1d Mon Sep 17 00:00:00 2001 From: "Michael G. Schwern" Date: Tue, 19 Jun 2012 12:08:28 -0700 Subject: [PATCH] Fix tests for Carp 1.25 Before 1.25 it would not put a period at the end of the error. For #321 --- t/History/History.t | 7 ++++--- t/History/consume.t | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/t/History/History.t b/t/History/History.t index 90bf8c246..429d0f1f5 100644 --- a/t/History/History.t +++ b/t/History/History.t @@ -9,7 +9,8 @@ BEGIN { require 't/test.pl' } use MyEventCoordinator; use TB2::Result; - +my $FILE = __FILE__; +my $QFILE = quotemeta($FILE); my $CLASS = "TB2::History"; require_ok 'TB2::History'; @@ -71,10 +72,10 @@ note "Turn off event storage"; is $history->event_count, 3; ok !eval { $history->events; 1 }; - is $@, sprintf "Events are not stored at %s line %d.\n", __FILE__, __LINE__-1; + like $@, qr{^Events are not stored at $QFILE line @{[ __LINE__ - 1 ]}\.?\n}; ok !eval { $history->results; 1 }; - is $@, sprintf "Results are not stored at %s line %d.\n", __FILE__, __LINE__-1; + like $@, qr{^Results are not stored at $QFILE line @{[ __LINE__ - 1 ]}\.?\n}; ok !eval { $history->store_events(1) }, "can't turn on storage for an existing object"; } diff --git a/t/History/consume.t b/t/History/consume.t index eb5a8cc94..cd8ff7793 100644 --- a/t/History/consume.t +++ b/t/History/consume.t @@ -5,6 +5,9 @@ use warnings; BEGIN { require 't/test.pl' } +my $FILE = __FILE__; +my $QFILE = quotemeta($FILE); + my $CLASS = "TB2::History"; use_ok $CLASS; use TB2::Events; @@ -41,8 +44,8 @@ note "Try to consume with storage off"; { my $h2 = $CLASS->new; ok !eval { $h2->consume( $h1 ); 1 }; - is $@, sprintf "Cannot consume() a History object which has store_events() off at %s line %d.\n", - __FILE__, __LINE__-2; + my $line = __LINE__ - 1; + like $@, qr{^Cannot consume\(\) a History object which has store_events\(\) off at $QFILE line $line\.?\n}; } done_testing;