Proc-Command
view release on metacpan or search on metacpan
tlib/Test/Tech.pm view on Meta::CPAN
$FILE = __FILE__;
use vars qw(@ISA @EXPORT_OK);
require Exporter;
@ISA=('Exporter');
@EXPORT_OK = qw(&tech_config &plan &ok &skip &skip_tests &stringify &demo);
#######
#
# Keep all data hidden in a local hash
#
# Too bad "Test" and "Data::Dumper" are not objectified
#
# Senseless to objectify "Test::Tech" if unless "Test" and "Data::Dumper"
# are objectified
#
my %tech = ();
my $tech_p = \%tech; # quasi objectify by using $tech_p instead of %tech
########
# Tend to Data::Dumper variables
#
$tech_p->{Dumper} = {};
$tech_p->{Dumper}->{Terse} = \$Data::Dumper::Terse;
$tech_p->{Dumper}->{Indent} = \$Data::Indent;
$tech_p->{Dumper}->{Purity} = \$Data::Purity;
$tech_p->{Dumper}->{Pad} = \$Data::Pad;
$tech_p->{Dumper}->{Varname} = \$Data::Varname;
$tech_p->{Dumper}->{Useqq} = \$Data::Useqq;
$tech_p->{Dumper}->{Freezer} = \$Data::Freezer;
$tech_p->{Dumper}->{Toaster} = \$Data::Toaster;
$tech_p->{Dumper}->{Deepcopy} = \$Data::Deepcopy;
$tech_p->{Dumper}->{Quotekeys} = \$Data::Quotekeys;
$tech_p->{Dumper}->{Maxdepth} = \$Data::Maxdepth;
######
# Tend to Test variables
#
$tech_p->{Test}->{ntest} = \$Test::ntest;
$tech_p->{Test}->{TESTOUT} = \$Test::TESTOUT;
$tech_p->{Test}->{TestLevel} = \$Test::TestLevel;
$tech_p->{Test}->{ONFAIL} = \$Test::ONFAIL;
$tech_p->{Test}->{todo} = \%Test::todo;
$tech_p->{Test}->{history} = \%Test::history;
$tech_p->{Test}->{planned} = \$Test::planned;
$tech_p->{Test}->{FAILDETAIL} = \@Test::FAILDETAIL;
$tech_p->{Test}->{Program_Lines} = \%Test::Program_Lines if defined %Test::Program_lines;
$tech_p->{Test}->{TESTERR} = \$Test::TESTERR if defined $Test::TESTERR;
$tech_p->{Skip_Tests} = 0;
#######
# Probe for internal storage
#
# The &Data::Dumper::Dumper subroutine stringifies the iternal Perl variable.
# Different Perls keep the have different internal formats for numbers. Some
# keep them as binary numbers, while others as strings. The ones that keep
# them as strings may be well spec. In any case they have been let loose in
# the wild so the test scripts that use Data::Dumper must deal with them.
#
# This is perl, v5.6.1 built for MSWin32-x86-multi-thread
# (with 1 registered patch, see perl -V for more detail)
#
# Copyright 1987-2001, Larry Wall
#
# Binary build 631 provided by ActiveState Tool Corp. http://www.ActiveState.com
# Built 17:16:22 Jan 2 2002
#
#
# Perl may be copied only under the terms of either the Artistic License or the
# GNU General Public License, which may be found in the Perl 5 source kit.
#
# Complete documentation for Perl, including FAQ lists, should be found on
# this system using `man perl' or `perldoc perl'. If you have access to the
# Internet, point your browser at http://www.perl.com/, the Perl Home Page.
#
# ~~~~~~~
#
# Wall, Christiansen and Orwant on Perl internal storage
#
# Page 351 of Programming Perl, Third Addition, Overloadable Operators
# quote:
#
# Conversion operators: ``'', 0+, bool
#
# These three keys let you provide behaviors for Perl's automatic conversions
# to strings, numbers, and Boolean values, respectively.
#
# ~~~~~~~
#
# Internal Storage of Perls that are in the wild
#
# string - Perl v5.6.1 MSWin32-x86-multi-thread, ActiveState build 631, binary
# number - Perl version 5.008 for solaris
#
# Perls in the wild with internal storage of string may be mutants that need to
# be hunted down killed.
#
my $probe = 3;
my $actual = Dumper([0+$probe]);
if( $actual eq Dumper([3]) ) {
$tech_p->{Internal_Number} = 'number';
}
elsif ( $actual eq Dumper(['3']) ) {
$tech_p->{Internal_Number} = 'string';
}
else {
$tech_p->{Internal_Number} = 'undetermine';
}
#####
# Stringify the variable and compare the string.
#
# This is the code that adds the big new capability of testing complex data
# structures to the "Test" module
#
sub stringify
{
my ($var_p) = @_;
( run in 2.059 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )