On 2023-Mar-08, Andrew Dunstan wrote:
> I don't think you need a stringy eval here, and they are something to be
> avoided in general. If you use `require` instead of `use` it should be
> unnecessary, and you can avoid all the perltidy ugliness.
>
> something like this should do the trick:
>
>
> eval { require Test::Differences; Test::Differences->import;
> unified_diff; 1; };
>
> *eq_or_diff = \&is if $@;
Hmm, I just grabbed the code from the Test::Differences manual, but I
agree that avoiding the stringy eval is better. Let me try it out.
> I wonder if it's worth centralizing this.
I had a look around to see what might benefit from this. At first I
thought the ugly pg_dump test would, but it doesn't because it uses
like/unlike, not 'is'. Same with PostgreSQL::Test::Utils' command_like
and such: AFAICS they are all matching stdout on regexps.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"El que vive para el futuro es un iluso, y el que vive para el pasado,
un imbécil" (Luis Adler, "Los tripulantes de la noche")