The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Mimic::Recorder - Perl extension for recording the behavior of perl packages. Typically used in conjunction with Test::Mimic.

SYNOPSIS

  # Record the Foo::Bar package
  use Test::Mimic::Recorder {
      'save'      => '.test_mimic_recorder_data',
      'string'    => sub {}, # The sub {} construction simply represents a subroutine reference.
      'destring'  => sub {}, # See below for appropriate contracts.

      'key'           => sub {},
      'monitor_args'  => sub {},

      'packages'  => {
          'Foo::Bar'  => {
              'scalars'   => [ qw< x y z > ],

              'key'           => sub {},
              'monitor_args'  => sub {},

              'subs' => {
                  'foo' => {
                      'key'           => sub {},
                      'monitor_args'  => sub {},
                  },
              },
          },
      },
  }; 

DESCRIPTION

Test::Mimic::Recorder allows a user to monitor the behavior of a set of packages well enough to recreate that behavior at a later date with reasonable fidelity. Each subroutine, package array and package hash (excepting symbol tables) is monitored. Package scalars will be monitored if specified or if the package inherits from Exporter and they appear in the @EXPORT or @EXPORT_OK arrays.

For each quadruple of package, subroutine, argument and context a history of results will be stored. These results can consist of either return values or exceptions. Package variables have their history stored in a slightly different fashion. Every time a variable is read the resulting value will be stored. Reading a variable can take on different forms depending on the variable's type. For instance, a scalar can merely be read, but a hash can have a particular one of its elements read, one of its keys read, the existence of one of its elements read and so forth. Writes are not recorded.

SUBROUTINES

Test::Mimic::Recorder->import($preferences)

The $preferences hash reference passed to import is fairly simply and the majority of its structure can be deduced from the synopsis above. For more information see the documentation for Test::Mimic.

In addition to this $preferences may contain the key 'test_mimic' at the top level. If its value is defined Test::Mimic::Recorder will assume that it is being used by Test::Mimic. The effect of this is to prevent Test::Mimic::Recorder from reloading key generators and the like. Only the package names and the scalar lists will be used from $preferences. This should generally not be used by users directly. In short, ignore the above paragraph unless you randomly decided to put 'test_mimic' into your hash.

finish()

Writes all information recorded so far to disk. If called nothing will be written at the end of execution automatically. You can, however, call finish again.

EXPORT

None by default.

SEE ALSO

Test::Mimic Test::Mimic::Library Test::Mimic::Generator

AUTHOR

Concept by Tye McQueen.

Development by Brendan Roof, <brendanroof@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by Brendan Roof.

Made possible by WhitePages Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.