NAME
TestFuncs - routines used by several tests
SYNOPSIS
use Test::Structs qw(is_same is_numeric);
is_same($ref1, $ref2, 'test name');
is_same($ref1, $ref2, 'test name', 0.1);
is_numeric($scalar);
DESCRIPTION
Used in the same was as Test::Simple and Test::More, this adds my home rolled tests.
is_same( ref1, ref2 [, test_name [, accuracy]] )
ref1
and ref2
can be references to arrays or hashes. The structures are compared item by item, including any sub-arrays or sub-hashes. If accuracy
is specified, numbers may differ by this amount before the test fails.
TODO: Doesn't handle blessed references Reporting of deep errors not really tested
from_csv( filename )
Reads CSV file returning data as an array ref.
csv_to_sample( filename )
Reads data from the specified CSV file and returns a hash with the same structure as Finance::Shares::Sample data, i.e. open, high, low, close, volume and lx sub-hashes.
array_to_sample( arrayref )
Given an array structured like a CSV file, it returns a hash with the same structure as Finance::Shares::Sample data, i.e. open, high, low, close, volume and lx sub-hashes and dates array.
sample_to_csv( sample, file )
Writes out Finance::Shares::Sample data so that it can be read by from_csv.
show( [values...], [names...] )
Calls Data::Dumper on values passed. Returns a string which may be displayed with e.g. warn.
show_deep( var [, min [, sep]] )
Recursively dumps hash or array refs, returning a string which may be displayed with e.g. warn.
- var
-
The scalar variable to be printed.
- min
-
A limit to the depth printed out.
- sep
-
String used to seperate entries (between pairs, not within them).
check_filesize( filename, size )
This must be invoked from ../t as it uses a file 't/filesizes' to store the size each file should be.