1use strict; 2use warnings; 3 4package Test::Deep::RegexpRef; 5 6use Test::Deep::Ref; 7use Test::Deep::RegexpVersion; 8 9sub init 10{ 11 my $self = shift; 12 13 my $val = shift; 14 15 $self->{val} = $val; 16} 17 18sub descend 19{ 20 my $self = shift; 21 22 my $got = shift; 23 24 my $exp = $self->{val}; 25 26 if ($Test::Deep::RegexpVersion::OldStyle) { 27 return 0 unless $self->test_class($got, "Regexp"); 28 return 0 unless $self->test_reftype($got, "SCALAR"); 29 } else { 30 return 0 unless $self->test_reftype($got, "REGEXP"); 31 } 32 33 return Test::Deep::descend($got, Test::Deep::regexprefonly($exp)); 34} 35 36sub renderGot 37{ 38 my $self = shift; 39 40 return shift().""; 41} 42 431; 44