I would suggest something along the lines of:

        &like_html(actual_value, expected_regex, max_chars_to_output,
string_description);

You could probably "steal" most of the code for this from Test::More's like
function and add in the functionality for outputting less than or equal to
max_chars_to_output if the actual_value does not match the expected_regex.
That's just my 2 cents.

Toodles,
~~Andrew

-----Original Message-----
From: Rafael Garcia-Suarez [mailto:[EMAIL PROTECTED] 
Sent: Sunday, November 16, 2003 6:43 AM
To: [EMAIL PROTECTED]
Subject: Re: thinking about variable context for like()

Mark Stosberg wrote in perl.qa :
> I'm frequently using 'like' to test $agent->content against a regular
> expression.
>   
> When I have a lot of these in a new test script and they are all
> failing, I get a boatload of HTML source floating by, which
> makes it tedious at times to find out what actually went wrong.
>   
> I would like a way to tune the amount context that "like" presents
> upon failure. For example, the first 1000 characters of the HTML source
> would do most of the time. I'm not sure what the best way to do this might
be.
> For now, I'll stop at merely suggesting something like this might be
useful. :)

Write your own test module on top of Test::Builder / Test::More.

I faced a similar problem with is() for very long strings and/or strings
that may contain non printable characters :

http://search.cpan.org/~RGARCIA/Test-LongString-0.02/lib/Test/LongString.pm

Now, it seems like your proposed long-string friendly like() is
something that could go in Test::LongString. Patches welcome, of course,
but I may look at implementing this myself. Other suggestions ?

Reply via email to