1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
package My::Module::Mock_Tokenizer;
use 5.006;
use strict;
use warnings;
use Carp;
our $VERSION = '0.091';
use constant ARRAY_REF => ref [];
sub new {
my ( $class, %arg ) = @_;
return bless \%arg, ref $class || $class;
}
sub capture {
my ( $self ) = @_;
ARRAY_REF eq ref $self->{capture}
or return;
return @{ $self->{capture} };
}
sub cookie {
my ( $self, $cookie ) = @_;
return $self->{cookie}{$cookie};
}
sub modifier_modify {}
sub __recognize_postderef {
my ( $self ) = @_;
return $self->{postderef};
}
1;
__END__
=head1 NAME
My::Module::Mock_Tokenizer - Mock tokenizer for t/*.t
=head1 SYNOPSIS
use lib qw{ inc };
use My::Module::Mock_Tokenizer;
my $tokenizer = My::Module::Mock_Tokenizer->new();
=head1 DESCRIPTION
This Perl class is private to the C<PPIx-Regexp> package, and may be
modified or retracted without notice. Documentation is for the benefit
of the author.
It represents a mock tokenizer to be used in testing. It implements
those methods that the author finds useful.
=head1 METHODS
This class supports the following public methods:
=head2 new
my $tokenizer = My::Module::Mock_Tokenizer->new();
This static method instantiates the tokenizer. In addition to the
invocant it takes arbitrary name/value pairs of arguments. These
arguments are made into a hash, and a blessed reference to this hash is
returned. The arguments are not validated, but may be used in methods as
documented below.
=head2 capture
say "Capture: '$_'" for $tokenizer->capture();
If C<< $tokenizer->{capture} >> is an array reference, the contents of
the array are returned. Otherwise nothing is returned.
=head2 cookie
my $cookie = $tokenizer->cookie( $name );
This method returns C<< $tokenizer->{cookie}{$name} >>. If you want to
specify a value for this, recall that cookies are code references.
=head2 modifier_modify
$tokenizer->modifier_modify( i => 1 );
This method does nothing and returns nothing.
=head2 __recognize_postderef
$tokenizer->__recognize_postderef()
and say 'We recognize postfix dereferences';
This method returns the value of C<< $tokenizer->{postderef} >>.
=head1 SEE ALSO
L<PPIx::Regexp::Tokenizer|PPIx::Regexp::Tokenizer>
=head1 SUPPORT
This module is private to the C<PPIx-Regexp> package. It is unsupported in
the sense that the author reserves the right to modify or retract it
without prior notice. Bug reports against this module will be accepted
provided they document a problem with this module that results in
spurious test results.
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
L<https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in
electronic mail to the author.
=head1 AUTHOR
Tom Wyant (wyant at cpan dot org)
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2015-2023, 2025 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
# ex: set textwidth=72 :
|