Skip to content

Use of uninitialized value $got in pattern match (m//) at Test/Deep/Regexp.pm line 57. #39

Description

@szabgab

The above warning is generated by the following code:

use Test::More;
use Test::Deep;

plan tests => 1;

my @data = (
    {
        name => 'Foo',
    },
    {
        name => undef,
    },
);

cmp_deeply \@data, array_each({
    name => re('^.*$')
});

If undef is ineed an acceptable value then the test should be written
name => any(undef, re('^.*$')

but when the data we are checking is a lot more complex it is quite hard to find the problematic field and regex.
Would it be possible to make this a test failure? Maybe, in order to keep backward compatibility, depending on some parameter?

e.g. adding return 0 if not defined $got; on line 31 of Text/Deep/Regexp would have helped me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions