Test-Data-1.248/0000755000076500000240000000000014777035210012302 5ustar brianstaffTest-Data-1.248/LICENSE0000644000076500000240000002173114777035207013321 0ustar brianstaffThe Test::Data module is licensed under the same terms as perl itself, under the Artistic License 2.0. Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ******** This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions *********** "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution ******************************************************** (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version ****************************************************** (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source ********************************************************** (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified ****************************************************************** Versions without the Source *************************** (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package ********************************** (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version ******************************************************** (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions ****************** (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Test-Data-1.248/Changes0000644000076500000240000000673514777035207013616 0ustar brianstaffRevision history for Perl module Test::Data 1.248 2025-04-13T22:28:23Z * require a newer version.pm for v5.10.1 tests 1.247 2025-01-13T13:26:17Z * refresh distro 1.246 2024-03-09T01:42:16Z * fix dualvar_ok so it actaully exports (#12) from jwrightecs 1.245 2024-01-29T18:56:07Z * refresh distro, update email address 1.244 2022-01-09T03:24:09Z * no code changes. Fix a link in README.pod. 1.243 2021-01-16T13:15:58Z * freshen distro, remove Travis CI, add Github Actions 1.242 2018-04-26T16:18:48Z * Clarify that it's Artistic License 2.0 1.241 2016-12-05T18:47:28Z * Catch up to the latest test and perl behavior 1.240_03 2016-11-23T21:21:30Z * Remove the prereqs test, but, specify all the prereqs, even the ones in core. 1.240_02 2016-11-16T00:45:07Z * Let's try harder to see why Dan Collins's testers setup doesn't like this distro. 1.240_02 2016-11-15T14:44:43Z * List all the prereqs, even the core ones. This is in anticipation of a new Test::Prereq that does not filter out core modules. 1.24_01 2016-05-30T00:12:28Z * Use Exporter appropriately (and not the bad habits in the Exporter docs). This shouldn't change anything for you. 1.24 - 2014-01-03 * Get rid of MYMETA 1.22 - 2012-07-18 * Rearrange the modules so I don't have to specify manpage locations (RT #46835) 1.21 - 2007-10-27 * distro cleanups after moving from CVS to SVN 1.20 - 2007-01-09 * updated copyright and license info * no code changes, so no need to upgrade 1.19 - 2006-05-17 * Updates for the distro and kwalitee. There's no need to upgrade. 1.18 - 2005-07-06 * fixed some error messages in t/array.t. No need to upgrade it you already have this module. 1.17 - 2005-03-08 * Added POD coverage tests: no need to upgrade 1.02 - 2004-09-02 * fixed a documentation grammar bug * cleaned up the distro a bit and added a README * you don't need to upgrade if you already have this module 1.01 - 2004-05-31 * fixed array_once_ok, thanks to Tom Heady * bumped the version past 1.01 0.96 - 2004-04-22 * functions in Test::Data::Scalar now return the result of ok() rather than something else. Thanks to Andy Lester for spotting the problem 0.95 - 2004-02-28 * added four functions to Test::Data::Array to check if an array is sorted (up or down, string or number) 0.94 - 2003-12-01 * No changes. Tests should run on Windows now. 0.93 - 2003-11-29 * Added new META.yml * pod.t uses new Test::Pod technology. * Removed TODO test on undef_ok() catching an empty list passed in. The prototype means that C<()> will get passed as a scalar, not an empty list. 0.92 - 2003-05-11 * Fixed hash_value_false_ok(), which was never defined. * Fixed incorrect $VERSION in each package. * Removed requirements on Test::Manifest and Test::Prereq. Test::Pod can get used on the install, but it's OK if not. 0.91 - 2002-12-20 * functions from Scalar::Util need full package specification since i do not import them. this fixes all of the functions based on Scalar::Util. * removed dualvar test. it does not work, and i need to figure out how to make it work * cleaned up the Pod which had some extra whitespace in places 0.9 - 2002-11-04 * fixed some calls to ok() that were missing name parameter * man pages install correctly 0.8 - 2002-10-23 * all functions can take optional name arguments * added not_exists_ok, hash_value_undef_ok, hash_value_false_ok 0.7 - 2002-09-30 * added number_bewteen_ok, string_between_ok * added array_empty_ok, array_length_ok Test-Data-1.248/MANIFEST0000644000076500000240000000101114777035210013424 0ustar brianstaffChanges examples/README INSTALL.SKIP lib/Test/Data.pm lib/Test/Data/Array.pm lib/Test/Data/Function.pm lib/Test/Data/Hash.pm lib/Test/Data/Scalar.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.pod SECURITY.md t/array.t t/function.t t/hash.t t/import.t t/load.t t/pod.t t/pod_coverage.t t/scalar.t t/test_manifest xt/changes.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Test-Data-1.248/t/0000755000076500000240000000000014777035207012553 5ustar brianstaffTest-Data-1.248/t/pod.t0000644000076500000240000000020114777035207013513 0ustar brianstaffuse Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Test-Data-1.248/t/load.t0000644000076500000240000000047514777035207013665 0ustar brianstaffuse Test::More; my @modules = qw( Test::Data Test::Data::Array Test::Data::Function Test::Data::Hash Test::Data::Function ); foreach $module ( @modules ) { use_ok( $module ); my $var = '$' . $module . '::VERSION'; my $ver = 0 + eval $var; no warnings qw(numeric); cmp_ok( $ver, '>', 0 ); } done_testing(); Test-Data-1.248/t/scalar.t0000644000076500000240000001236514777035207014214 0ustar brianstaffuse Test::Builder::Tester tests => 58; use Test::More; use_ok( 'Test::Data', 'Scalar' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # foreach my $value ( [], {} ) { my $object = bless $value; test_out('ok 1 - Scalar is blessed'); blessed_ok( $object ); test_test('blessed_ok'); } foreach my $value ( [], {}, "Hello", undef, '', 1, 0 ) { my $ref = ref $value; test_diag("Expected a blessed value, but didn't get it", qq|\tReference type is "$ref"|, " Failed test ($0 at line " . line_num(+4) . ")",); test_out('not ok 1 - Scalar is blessed'); blessed_ok( $value ); test_test('blessed_ok catches non-reference'); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # test_out('ok 1 - Scalar is defined'); defined_ok( "defined" ); test_test('defined_ok'); test_diag("Expected a defined value, got an undefined one", "Scalar is defined", " Failed test ($0 at line " . line_num(+4) . ")",); test_out('not ok 1 - Scalar is defined'); defined_ok( undef ); test_test('defined_ok catches undef'); { my $test; test_out( map { "ok $_ - Scalar is undefined" } 1 .. 2 ); undef_ok( undef ); undef_ok( $test ); test_test('undef_ok'); } foreach my $value ( 'foo', '', 0, '0' ) { my $test = 'foo'; test_diag("Expected an undefined value, got a defined one", " Failed test ($0 at line " . line_num(+3) . ")",); test_out( 'not ok 1 - Scalar is undefined' ); undef_ok( 'foo' ); test_test('undef_ok catches defined value'); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # foreach my $pair ( ( [2,1], [4,2], [0,-1], [-1,-2] ) ) { test_out('ok 1 - Scalar is greater than bound'); greater_than( $pair->[0], $pair->[1] ); test_test('greater_than'); test_diag("Number is greater than the bound.", "\tExpected a number less than [$$pair[1]]", "\tGot [$$pair[0]]", " Failed test ($0 at line " . line_num(+6) . ")", ); test_out('not ok 1 - Scalar is less than bound'); less_than( $pair->[0], $pair->[1] ); test_test('less than catches out-of-bonds'); test_out('ok 1 - Scalar is less than bound'); less_than( $pair->[1], $pair->[0] ); test_test('less_than'); test_diag("Number is less than the bound.", "\tExpected a number greater than [$$pair[0]]", "\tGot [$$pair[1]]", " Failed test ($0 at line " . line_num(+6) . ")", ); test_out('not ok 1 - Scalar is greater than bound'); greater_than( $pair->[1], $pair->[0] ); test_test('greater_than catches out-of-bonds'); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # foreach my $string ( ( '', '123', ' ', 'Roscoe' ) ) { my $length = length $string; test_out( "ok 1 - Scalar has right length", "ok 2 - Scalar length is less than bound", "ok 3 - Scalar length is less than bound", "ok 4 - Scalar length is greater than bound", "ok 5 - Scalar length is greater than bound", "ok 6 - Scalar length is greater than bound", ); length_ok( $string, $length ); maxlength_ok( $string, $length ); maxlength_ok( $string, $length + 1 ); minlength_ok( $string, $length ); minlength_ok( $string, $length - 1 ); minlength_ok( $string, 0 ); test_test('length_ok, maxlength_ok, minlength_ok'); foreach my $bad ( $length - 1, $length + 1, -1, 0 ) { next if $bad == $length; test_diag("Length of value not within bounds", "\tExpected length=[$bad]", "\tGot [$length]", " Failed test ($0 at line " . line_num(+6) . ")", ); test_out('not ok 1 - Scalar has right length'); length_ok( $string, $bad ); test_test('length_ok catches errors'); } } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # test_out( "ok 1 - Scalar is a reference", "ok 2 - Scalar is not a weak reference", "ok 3 - Scalar is a reference", "ok 4 - Scalar is not a weak reference", ); foreach my $value ( ( {}, [] ) ) { ref_ok( $value ); strong_ok( $value ); } test_test('ref_ok, strong_ok'); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # test_out( map { "ok $_ - Scalar is in numerical range" } 1 .. 4 ); number_between_ok( 5, 5, 6 ); number_between_ok( 6, 5, 6 ); number_between_ok( 5, 4, 6 ); number_between_ok( 5.5, 5, 6 ); test_test('number_between_ok'); test_diag("Number [4] was not within bounds", "\tExpected lower bound [5]", "\tExpected upper bound [6]", " Failed test ($0 at line " . line_num(+5) . ")",); test_out( "not ok 1 - Scalar is in numerical range" ); number_between_ok( 4, 5, 6 ); test_test('number_between_ok catches failures'); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # test_out( map { "ok $_ - Scalar is in string range" } 1 .. 5 ); string_between_ok( 5, 5, 6 ); string_between_ok( 6, 5, 6 ); string_between_ok( 5, 4, 6 ); string_between_ok( 'dino', 'barney', 'fred' ); string_between_ok( 11, 1, 2 ); test_test('string_between_ok'); test_diag("String [wilma] was not within bounds", "\tExpected lower bound [fred]", "\tExpected upper bound [pebbles]", " Failed test ($0 at line " . line_num(+5) . ")",); test_out( "not ok 1 - Scalar is in string range" ); string_between_ok( 'wilma', 'fred', 'pebbles' ); test_test('string_between_ok catches failures'); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # test_out( map { "ok $_ - Scalar is not tainted" } 1 .. 1 ); untainted_ok( 'Foo' ); test_test('untainted_ok'); Test-Data-1.248/t/array.t0000644000076500000240000000716014777035207014062 0ustar brianstaffuse Test::Builder::Tester tests => 3; use Test::More; use Test::Data qw(Array); #use Carp; #$SIG{__WARN__} = \&confess; my %line; TEST_ARRAY_FUNCS: { my @array = 4..6; my @empty = (); test_err(); array_any_ok( 5, @array ); test_out( "ok 1 - Array contains item" ); array_any_ok( 9, @array, "Array does not contain 9, go fish" ); $line{'9x0'} = __LINE__; test_out( "not ok 2 - Array does not contain 9, go fish" ); array_once_ok( 5, @array, "Array contains 5 once" ); test_out( "ok 3 - Array contains 5 once" ); { my @array = (5, 5); array_once_ok( 5, @array, "Array has 5 twice, not once" ); $line{'5x2'} = __LINE__; test_out( "not ok 4 - Array has 5 twice, not once" ); @array = (); array_once_ok( 5, @array, "Array has no items" ); $line{'5x0'} = __LINE__; test_out( "not ok 5 - Array has no items" ); @array = ( 6, 6 ); array_once_ok( 5, @array, "Array has no 5's, but two 6's" ); $line{'6x2'} = __LINE__; test_out( "not ok 6 - Array has no 5's, but two 6's" ); } array_none_ok( 7, @array ); array_sum_ok( 15, @array ); array_max_ok( 6, @array ); array_min_ok( 3, @array ); array_empty_ok( @empty ); array_length_ok( @array, 3 ); test_out( "ok 7 - Array does not contain item", "ok 8 - Array sum is correct", "ok 9 - Array maximum is okay", "ok 10 - Array minimum is okay", "ok 11 - Array is empty", "ok 12 - Array length is correct", ); test_err( "# Failed test ($0 at line $line{'9x0'})", "# Failed test ($0 at line $line{'5x2'})", "# Failed test ($0 at line $line{'5x0'})", "# Failed test ($0 at line $line{'6x2'})" ); test_test('Array functions work'); } TEST_STR_SORTS: { my @array = 'a' .. 'f'; my @reverse = reverse @array; test_err(); array_sortedstr_ascending_ok( @array ); array_sortedstr_descending_ok( @reverse ); test_out( "ok 1 - Array is in ascending order", "ok 2 - Array is in descending order", ); array_sortedstr_ascending_ok( @reverse ); $line{'up'} = __LINE__; array_sortedstr_descending_ok( @array ); $line{'down'} = __LINE__; test_out( 'not ok 3 - Array is in ascending order', 'not ok 4 - Array is in descending order', ); test_err( "# Failed test ($0 at line $line{up})", "# Failed test ($0 at line $line{down})", ); my @bad = ( 'a' .. 'f', 'b' ); my @bad_reverse = reverse @bad; array_sortedstr_ascending_ok( @bad ); $line{'up'} = __LINE__; array_sortedstr_descending_ok( @bad_reverse ); $line{'down'} = __LINE__; test_out( 'not ok 5 - Array is in ascending order', 'not ok 6 - Array is in descending order', ); test_err( "# Failed test ($0 at line $line{up})", "# Failed test ($0 at line $line{down})", ); test_test('Sort comparisons work'); } TEST_NUM_SORTS: { my @array = 1 .. 5; my @reverse = reverse @array; test_err(); array_sorted_ascending_ok( @array ); array_sorted_descending_ok( @reverse ); test_out( "ok 1 - Array is in ascending order", "ok 2 - Array is in descending order", ); array_sorted_ascending_ok( @reverse ); $line{up} = __LINE__; array_sorted_descending_ok( @array ); $line{down} = __LINE__; test_out( 'not ok 3 - Array is in ascending order', 'not ok 4 - Array is in descending order', ); test_err( "# Failed test ($0 at line $line{up})", "# Failed test ($0 at line $line{down})", ); my @bad = ( 1 .. 5, 3 ); my @bad_reverse = reverse @bad; array_sorted_ascending_ok( @bad ); $line{up} = __LINE__; array_sorted_descending_ok( @bad_reverse ); $line{down} = __LINE__; test_out( 'not ok 5 - Array is in ascending order', 'not ok 6 - Array is in descending order', ); test_err( "# Failed test ($0 at line $line{up})", "# Failed test ($0 at line $line{down})", ); test_test('Sort comparisons work'); } Test-Data-1.248/t/import.t0000644000076500000240000000337314777035207014260 0ustar brianstaffuse Test::More; require Test::Data; Test::Data->import( qw(Scalar Array Hash Function) ); my @scalar_functions = qw( blessed_ok defined_ok greater_than length_ok less_than maxlength_ok minlength_ok number_ok readonly_ok ref_ok ref_type_ok strong_ok tainted_ok untainted_ok weak_ok undef_ok number_between_ok string_between_ok ); my @hash_functions = qw(exists_ok not_exists_ok hash_value_defined_ok hash_value_undef_ok hash_value_true_ok hash_value_false_ok); my @array_functions = qw(array_any_ok array_none_ok array_once_ok array_multiple_ok array_max_ok array_min_ok array_maxstr_ok array_minstr_ok array_sum_ok array_length_ok array_empty_ok array_sortedstr_ascending_ok array_sortedstr_descending_ok array_sorted_ascending_ok array_sorted_descending_ok ); my @function_functions = qw(prototype_ok); plan tests => @scalar_functions + @hash_functions + @array_functions + @function_functions; # Scalar test_functions( "Scalar", @scalar_functions ); # Array test_functions( "Array", @array_functions ); # Hashes test_functions( "Hash", @hash_functions ); # Functions test_functions( "Function", @function_functions ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # sub test_functions { my( $package, @function_names ) = @_; foreach my $function ( @function_names ) { check_function( $function, $package ); } } sub check_function { my( $function, $package ) = @_; my $ok = sub_defined( $function ); unless( $ok ) { diag( "\tFunction [$function] not defined in main::" ); $a = sub_defined( "Test\::Data\::$package\::$function" ); diag( "\tFunction is defined in $package, though" ) if $a; } ok( $ok, "$package package exported $function" ); } sub sub_defined { my $function = shift; eval( "defined \&$function" ); } Test-Data-1.248/t/test_manifest0000644000076500000240000000012114777035207015335 0ustar brianstaffload.t pod.t pod_coverage.t prereq.t import.t scalar.t array.t hash.t function.t Test-Data-1.248/t/pod_coverage.t0000644000076500000240000000056414777035207015402 0ustar brianstaffuse Test::More; eval "use Test::Pod::Coverage"; if( $@ ) { plan skip_all => "Test::Pod::Coverage required for testing POD"; } else { my @modules = qw( Test::Data Test::Data::Array Test::Data::Function Test::Data::Hash Test::Data::Scalar ); plan tests => scalar @modules; pod_coverage_ok( $_, { trustme => [ qr/VERSION/ ] } ) foreach ( @modules ); } Test-Data-1.248/t/function.t0000644000076500000240000000024214777035207014563 0ustar brianstaffuse Test::More tests => 2; use Test::Data qw(Function); sub fooey($$) { 1 } prototype_ok( &fooey, '$$', 'Double scalar fooey' ); prototype_ok( &fooey, '$$' ); Test-Data-1.248/t/hash.t0000644000076500000240000000016514777035207013665 0ustar brianstaffuse Test::More tests => 1; use Test::Data qw(Hash); TODO: { local $TODO = "No tests for Hash yet"; ok( 0 ); } Test-Data-1.248/xt/0000755000076500000240000000000014777035207012743 5ustar brianstaffTest-Data-1.248/xt/changes.t0000644000076500000240000000020314777035207014533 0ustar brianstaffuse Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Test-Data-1.248/README.pod0000644000076500000240000001135214777035207013753 0ustar brianstaff=pod =encoding utf8 =for HTML =for HTML =for HTML =for HTML =for HTML Coverage Status =for HTML =for HTML =head1 The Test::Data module This is the I for the L Perl module. It provides convenience methods to test things about Perl data type instead of their values. You're probably looking at this because you don't know where else to find what you're looking for. Read this once and you might never have to read one again for any Perl module. =head2 Documentation To read about L, look at the embedded documentation in the module itself. Inside the distribution, you can format it with L: % perldoc lib/Test/Data.pm If you have already installed the module, you can specify the module name instead of the file location: % perldoc Test::Data You can read the documentation and inspect the meta data at L. The standard module documentation has example uses in the SYNOPSIS section, but you can also look in the I directory (if it's there), or look at the test files in I. =head2 Installation You can install this module with a CPAN client, which will resolve and install the dependencies: % cpan Test::Data % cpanm Test::Data You can also install directly from the distribution directory, which will also install the dependencies: % cpan . % cpanm . You could install just this module manually: % perl Makefile.PL % make % make test % make install You probably don't want to do that unless you're fiddling with the module and only want to run the tests without installing anything. =head2 Source location The meta data, such as the source repository and bug tracker, is in I or the I files it creates. You can find that on those CPAN web interfaces, but you can also look at files directly in the source repository: L If you find a problem, file a ticket in the L. There are also backup repositories hosted on other services. These reflect the state of the main repo and exist only for redundancy: =over 4 =item * L =item * L =item * L =back =head2 GitHub Attestations This distribution now uses L, which allow you to verify that the archive file you have was made from the official repo. You need a GitHub account and the L. # download the distro file from GitHub, MetaCPAN, or a CPAN mirror $ gh auth login ...follow instructions... $ gh attestation verify Test-Data-1.23.tar.gz --owner briandfoy =head2 Getting help Although I'm happy to hear from module users in private email, that's the best way for me to forget to do something. Besides the issue trackers, you can find help at L or L, both of which have many competent Perlers who can answer your question, almost in real time. They might not know the particulars of this module, but they can help you diagnose your problem. You might like to read L. =head2 Copyright and License You should have received a I file, but the license is also noted in the module files. About the only thing you can't do is pretend that you wrote code that you didn't. =head2 Good luck! Enjoy, brian d foy, briandfoy@pobox.com =cut Test-Data-1.248/MANIFEST.SKIP0000644000076500000240000000211714777035207014207 0ustar brianstaff #!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP \.?appveyor.yml \.releaserc \.lwpcookies Test-.* \bMANIFEST\s\d \bChanges\s\d \.icloud$ \A\.github\b \.gitattributes\b Test-Data-1.248/examples/0000755000076500000240000000000014777035207014126 5ustar brianstaffTest-Data-1.248/examples/README0000644000076500000240000000010514777035207015002 0ustar brianstaffSee the tests in the t/ directory for examples until I add some more.Test-Data-1.248/META.yml0000664000076500000240000000157414777035210013564 0ustar brianstaff--- abstract: 'test functions for particular variable types' author: - 'brian d foy ' build_requires: Test::Builder: '0' Test::Builder::Tester: '0' Test::More: '1' version: '0.86' configure_requires: ExtUtils::MakeMaker: '6.64' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-Data no_index: directory: - t - inc requires: Carp: '0' Exporter: '0' List::Util: '0' Scalar::Util: '0' perl: '5.008' strict: '0' resources: bugtracker: https://github.com/briandfoy/test-data/issues homepage: https://github.com/briandfoy/test-data repository: https://github.com/briandfoy/test-data version: '1.248' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Test-Data-1.248/lib/0000755000076500000240000000000014777035207013056 5ustar brianstaffTest-Data-1.248/lib/Test/0000755000076500000240000000000014777035207013775 5ustar brianstaffTest-Data-1.248/lib/Test/Data/0000755000076500000240000000000014777035207014646 5ustar brianstaffTest-Data-1.248/lib/Test/Data/Scalar.pm0000644000076500000240000002213214777035207016411 0ustar brianstaffuse 5.008; package Test::Data::Scalar; use strict; use Exporter qw(import); our @EXPORT = qw( blessed_ok defined_ok dualvar_ok greater_than length_ok less_than maxlength_ok minlength_ok number_ok readonly_ok ref_ok ref_type_ok strong_ok tainted_ok untainted_ok weak_ok undef_ok number_between_ok string_between_ok ); our $VERSION = '1.248'; use Scalar::Util; use Test::Builder; my $Test = Test::Builder->new(); =encoding utf8 =head1 NAME Test::Data::Scalar -- test functions for scalar variables =head1 SYNOPSIS use Test::Data qw(Scalar); =head1 DESCRIPTION This modules provides a collection of test utilities for scalar variables. Load the module through Test::Data. =head2 Functions =over 4 =item blessed_ok( SCALAR ) Ok if the SCALAR is a blessed reference. =cut sub blessed_ok ($;$) { my $ref = ref $_[0]; my $ok = Scalar::Util::blessed($_[0]); my $name = $_[1] || 'Scalar is blessed'; $Test->diag("Expected a blessed value, but didn't get it\n\t" . qq|Reference type is "$ref"\n| ) unless $ok; $Test->ok( $ok, $name ); } =item defined_ok( SCALAR ) Ok if the SCALAR is defined. =cut sub defined_ok ($;$) { my $ok = defined $_[0]; my $name = $_[1] || 'Scalar is defined'; $Test->diag("Expected a defined value, got an undefined one\n", $name ) unless $ok; $Test->ok( $ok, $name ); } =item undef_ok( SCALAR ) Ok if the SCALAR is undefined. =cut sub undef_ok ($;$) { my $name = $_[1] || 'Scalar is undefined'; if( @_ > 0 ) { my $ok = not defined $_[0]; $Test->diag("Expected an undefined value, got a defined one\n") unless $ok; $Test->ok( $ok, $name ); } else { $Test->diag("Expected an undefined value, but got no arguments\n"); $Test->ok( 0, $name ); } } =item dualvar_ok( SCALAR ) Ok if the scalar is a dualvar. How do I test this? =cut sub dualvar_ok ($;$) { my $ok = Scalar::Util::isdual( $_[0] ); my $name = $_[1] || 'Scalar is a dualvar'; $Test->ok( $ok, $name ); $Test->diag("Expected a dualvar, didn't get it\n") unless $ok; } =item greater_than( SCALAR, BOUND ) Ok if the SCALAR is numerically greater than BOUND. =cut sub greater_than ($$;$) { my $value = shift; my $bound = shift; my $name = shift || 'Scalar is greater than bound'; my $ok = $value > $bound; $Test->diag("Number is less than the bound.\n\t" . "Expected a number greater than [$bound]\n\t" . "Got [$value]\n") unless $ok; $Test->ok( $ok, $name ); } =item length_ok( SCALAR, LENGTH ) Ok if the length of SCALAR is LENGTH. =cut sub length_ok ($$;$) { my $string = shift; my $length = shift; my $name = shift || 'Scalar has right length'; my $actual = length $string; my $ok = $length == $actual; $Test->diag("Length of value not within bounds\n\t" . "Expected length=[$length]\n\t" . "Got [$actual]\n") unless $ok; $Test->ok( $ok, $name ); } =item less_than( SCALAR, BOUND ) Ok if the SCALAR is numerically less than BOUND. =cut sub less_than ($$;$) { my $value = shift; my $bound = shift; my $name = shift || 'Scalar is less than bound'; my $ok = $value < $bound; $Test->diag("Number is greater than the bound.\n\t" . "Expected a number less than [$bound]\n\t" . "Got [$value]\n") unless $ok; $Test->ok( $ok, $name ); } =item maxlength_ok( SCALAR, LENGTH ) Ok is the length of SCALAR is less than or equal to LENGTH. =cut sub maxlength_ok($$;$) { my $string = shift; my $length = shift; my $name = shift || 'Scalar length is less than bound'; my $actual = length $string; my $ok = $actual <= $length; $Test->diag("Length of value longer than expected\n\t" . "Expected max=[$length]\n\tGot [$actual]\n") unless $ok; $Test->ok( $ok, $name ); } =item minlength_ok( SCALAR, LENGTH ) Ok is the length of SCALAR is greater than or equal to LENGTH. =cut sub minlength_ok($$;$) { my $string = shift; my $length = shift; my $name = shift || 'Scalar length is greater than bound'; my $actual = length $string; my $ok = $actual >= $length; $Test->diag("Length of value shorter than expected\n\t" . "Expected min=[$length]\n\tGot [$actual]\n") unless $ok; $Test->ok( $ok, $name ); } =item number_ok( SCALAR ) Ok if the SCALAR is a number ( or a string that represents a number ). At the moment, a number is just a string of digits. This needs work. =cut sub number_ok($;$) { my $number = shift; my $name = shift || 'Scalar is a number'; $number =~ /\D/ ? $Test->ok( 0, $name ) : $Test->ok( 1, $name ); } =item number_between_ok( SCALAR, LOWER, UPPER ) Ok if the number in SCALAR sorts between the number in LOWER and the number in UPPER, numerically. If you put something that isn't a number into UPPER or LOWER, Perl will try to make it into a number and you may get unexpected results. =cut sub number_between_ok($$$;$) { my $number = shift; my $lower = shift; my $upper = shift; my $name = shift || 'Scalar is in numerical range'; unless( defined $lower and defined $upper ) { $Test->diag("You need to define LOWER and UPPER bounds " . "to use number_between_ok" ); $Test->ok( 0, $name ); } elsif( $upper < $lower ) { $Test->diag( "Upper bound [$upper] is lower than lower bound [$lower]" ); $Test->ok( 0, $name ); } elsif( $number >= $lower and $number <= $upper ) { $Test->ok( 1, $name ); } else { $Test->diag( "Number [$number] was not within bounds\n", "\tExpected lower bound [$lower]\n", "\tExpected upper bound [$upper]\n" ); $Test->ok( 0, $name ); } } =item string_between_ok( SCALAR, LOWER, UPPER ) Ok if the string in SCALAR sorts between the string in LOWER and the string in UPPER, ASCII-betically. =cut sub string_between_ok($$$;$) { my $string = shift; my $lower = shift; my $upper = shift; my $name = shift || 'Scalar is in string range'; unless( defined $lower and defined $upper ) { $Test->diag("You need to define LOWER and UPPER bounds " . "to use string_between_ok" ); $Test->ok( 0, $name ); } elsif( $upper lt $lower ) { $Test->diag( "Upper bound [$upper] is lower than lower bound [$lower]" ); $Test->ok( 0, $name ); } elsif( $string ge $lower and $string le $upper ) { $Test->ok( 1, $name ); } else { $Test->diag( "String [$string] was not within bounds\n", "\tExpected lower bound [$lower]\n", "\tExpected upper bound [$upper]\n" ); $Test->ok( 0, $name ); } } =item readonly_ok( SCALAR ) Ok is the SCALAR is read-only. =cut sub readonly_ok($;$) { my $ok = not Scalar::Util::readonly( $_[0] ); my $name = $_[1] || 'Scalar is read-only'; $Test->diag("Expected readonly reference, got writeable one\n") unless $ok; $Test->ok( $ok, $name ); } =item ref_ok( SCALAR ) Ok if the SCALAR is a reference. =cut sub ref_ok($;$) { my $ok = ref $_[0]; my $name = $_[1] || 'Scalar is a reference'; $Test->diag("Expected reference, didn't get it\n") unless $ok; $Test->ok( $ok, $name ); } =item ref_type_ok( REF1, REF2 ) Ok if REF1 is the same reference type as REF2. =cut sub ref_type_ok($$;$) { my $ref1 = ref $_[0]; my $ref2 = ref $_[1]; my $ok = $ref1 eq $ref2; my $name = $_[2] || 'Scalar is right reference type'; $Test->diag("Expected references to match\n\tGot $ref1\n\t" . "Expected $ref2\n") unless $ok; ref $_[0] eq ref $_[1] ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item strong_ok( SCALAR ) Ok is the SCALAR is not a weak reference. =cut sub strong_ok($;$) { my $ok = not Scalar::Util::isweak( $_[0] ); my $name = $_[1] || 'Scalar is not a weak reference'; $Test->diag("Expected strong reference, got weak one\n") unless $ok; $Test->ok( $ok, $name ); } =item tainted_ok( SCALAR ) Ok is the SCALAR is tainted. (Tainted values may seem like a not-Ok thing, but remember, when you use taint checking, you want Perl to taint data, so you should have a test to make sure it happens.) =cut sub tainted_ok($;$) { my $ok = Scalar::Util::tainted( $_[0] ); my $name = $_[1] || 'Scalar is tainted'; $Test->diag("Expected tainted data, got untainted data\n") unless $ok; $Test->ok( $ok, $name ); } =item untainted_ok( SCALAR ) Ok if the SCALAR is not tainted. =cut sub untainted_ok($;$) { my $ok = not Scalar::Util::tainted( $_[0] ); my $name = $_[1] || 'Scalar is not tainted'; $Test->diag("Expected untainted data, got tainted data\n") unless $ok; $Test->ok( $ok, $name ); } =item weak_ok( SCALAR ) Ok if the SCALAR is a weak reference. =cut sub weak_ok($;$) { my $ok = Scalar::Util::isweak( $_[0] ); my $name = $_[1] || 'Scalar is a weak reference'; $Test->diag("Expected weak reference, got stronge one\n") unless $ok; $Test->ok( $ok, $name ); } =back =head1 TO DO * add is_a_filehandle test * add is_vstring test =head1 SEE ALSO L, L, L, L, L, L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/test-data =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2002-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =cut "The quick brown fox jumped over the lazy dog"; Test-Data-1.248/lib/Test/Data/Hash.pm0000644000076500000240000000567714777035207016106 0ustar brianstaffuse 5.008; package Test::Data::Hash; use strict; use Exporter qw(import); our @EXPORT = qw(exists_ok not_exists_ok hash_value_defined_ok hash_value_undef_ok hash_value_true_ok hash_value_false_ok); our $VERSION = '1.248'; use Test::Builder; my $Test = Test::Builder->new(); =encoding utf8 =head1 NAME Test::Data::Hash -- test functions for hash variables =head1 SYNOPSIS use Test::Data qw(Hash); =head1 DESCRIPTION This modules provides a collection of test utilities for hash variables. Load the module through Test::Data. =head2 Functions =over 4 =item exists_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH exists. The function does not create KEY in HASH. =cut sub exists_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash key [$key] exists"; $Test->ok( exists $hash->{$key}, $name ); } =item not_exists_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH does not exist. The function does not create KEY in HASH. =cut sub not_exists_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash key [$key] does not exist"; $Test->ok( exists $hash->{$key} ? 0 : 1, $name ); } =item hash_value_defined_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is defined. The function does not create KEY in HASH. =cut sub hash_value_defined_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash value for key [$key] is defined"; $Test->ok( defined $hash->{$key}, $name ); } =item hash_value_undef_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is undefined. The function does not create KEY in HASH. =cut sub hash_value_undef_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash value for key [$key] is undef"; $Test->ok( defined $hash->{$key} ? 0 : 1, $name ); } =item hash_value_true_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is true. The function does not create KEY in HASH. =cut sub hash_value_true_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash value for key [$key] is true"; $Test->ok( $hash->{$key}, $name ); } =item hash_value_false_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is false. The function does not create KEY in HASH. =cut sub hash_value_false_ok($\%;$) { my $key = shift; my $hash = shift; my $name = shift || "Hash value for key [$key] is false"; $Test->ok( $hash->{$key} ? 0 : 1, $name ); } =back =head1 SEE ALSO L, L, L, L, L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/test-data =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2002-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =cut "red leather yellow leather"; Test-Data-1.248/lib/Test/Data/Array.pm0000644000076500000240000001557514777035207016277 0ustar brianstaffuse 5.008; package Test::Data::Array; use strict; use Exporter qw(import); our $VERSION = '1.248'; our @EXPORT = qw( array_any_ok array_none_ok array_once_ok array_multiple_ok array_max_ok array_min_ok array_maxstr_ok array_minstr_ok array_sum_ok array_length_ok array_empty_ok array_sortedstr_ascending_ok array_sortedstr_descending_ok array_sorted_ascending_ok array_sorted_descending_ok ); use List::Util qw(sum min max minstr maxstr); use Test::Builder; my $Test = Test::Builder->new(); =encoding utf8 =head1 NAME Test::Data::Array -- test functions for array variables =head1 SYNOPSIS use Test::Data qw(Array); =head1 DESCRIPTION =head2 Functions =over 4 =item array_any_ok( ITEM, ARRAY [, NAME] ) Ok if any element of ARRAY is ITEM. =cut sub array_any_ok($\@;$) { my $element = shift; my $array = shift; my $name = shift || 'Array contains item'; foreach my $try ( @$array ) { next unless $try eq $element; $Test->ok( 1, $name ); return; } $Test->ok( 0, $name ); } =item array_none_ok( ITEM, ARRAY [, NAME] ) Ok if no element of ARRAY is ITEM. =cut sub array_none_ok($\@;$) { my $element = shift; my $array = shift; my $name = shift || 'Array does not contain item'; foreach my $try ( @$array ) { next unless $try eq $element; $Test->ok( 0, $name ); return; } $Test->ok( 1, $name ); } =item array_once_ok( ITEM, ARRAY [, NAME] ) Ok if only one element of ARRAY is ITEM. =cut sub array_once_ok($\@;$) { my $element = shift; my $array = shift; my $name = shift || 'Array contains item only once'; my %seen = (); my $ok = 0; foreach my $item ( @$array ) { ++$seen{$item} } $ok = 1 if( defined $seen{$element} and $seen{$element} == 1 ); $Test->ok( $ok, $name ); } =item array_multiple_ok( ITEM, ARRAY [, NAME] ) Ok if more than one element of ARRAY is ITEM. =cut sub array_multiple_ok($\@;$) { my $element = shift; my $array = shift; my $name = shift || 'Array contains item at least once'; my %seen = (); foreach my $item ( @$array ) { $seen{$item}++; } $seen{$element} > 1 ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_max_ok( NUMBER, ARRAY [, NAME] ) Ok if all elements of ARRAY are numerically less than or equal to NUMBER. =cut sub array_max_ok($\@;$) { my $item = shift; my $array = shift; my $name = shift || 'Array maximum is okay'; my $actual = max( @$array ); $actual <= $item ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_min_ok( NUMBER, ARRAY [, NAME] ) Ok if all elements of ARRAY are numerically greater than or equal to NUMBER. =cut sub array_min_ok($\@;$) { my $item = shift; my $array = shift; my $name = shift || 'Array minimum is okay'; my $actual = min( @$array ); $actual >= $item ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_maxstr_ok( ITEM, ARRAY [, NAME] ) Ok if all elements of ARRAY are asciibetically less than or equal to MAX. =cut sub array_maxstr_ok($\@;$) { my $item = shift; my $array = shift; my $name = shift || 'Array maximum string is okay'; my $actual = maxstr( @$array ); $actual ge $item ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_minstr_ok( ITEM, ARRAY [, NAME] ) Ok if all elements of ARRAY are asciibetically greater than or equal to MAX. =cut sub array_minstr_ok($\@;$) { my $item = shift; my $array = shift; my $name = shift || 'Array minimum string is okay'; my $actual = minstr( @$array ); $actual le $item ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_sum_ok( SUM, ARRAY [, NAME] ) Ok if the numerical sum of ARRAY is SUM. =cut sub array_sum_ok($\@;$) { my $sum = shift; my $array = shift; my $name = shift || 'Array sum is correct'; my $actual = sum( @$array ); $sum == $actual ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_empty_ok( ARRAY [, NAME] ) Ok if the array contains no elements. =cut sub array_empty_ok(\@;$) { my $array = shift; my $name = shift || 'Array is empty'; $#$array == -1 ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_length_ok( ARRAY, LENGTH [, NAME] ) Ok if the array contains LENGTH number of elements. =cut sub array_length_ok(\@$;$) { my $array = shift; my $length = shift; my $name = shift || 'Array length is correct'; $#$array == $length - 1 ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_sortedstr_ascending_ok( ARRAY, [, NAME] ) Ok if each succeeding element is asciibetically greater than or equal to the one before. =cut sub array_sortedstr_ascending_ok(\@;$) { my $array = shift; my $name = shift || 'Array is in ascending order'; my $last_seen = 0; ELEMENT: foreach my $index ( 1 .. $#$array ) { if( $array->[ $index ] ge $array->[ $index - 1 ] ) { $last_seen = $index; next; } last; } $last_seen == $#$array ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_sortedstr_descending_ok( ARRAY, [, NAME] ) Ok if each succeeding element is asciibetically less than or equal to the one before. =cut sub array_sortedstr_descending_ok(\@;$) { my $array = shift; my $name = shift || 'Array is in descending order'; my $last_seen = 0; ELEMENT: foreach my $index ( 1 .. $#$array ) { if( $array->[ $index ] le $array->[ $index - 1 ] ) { $last_seen = $index; next; } last; } $last_seen == $#$array ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_sorted_ascending_ok( ARRAY, [, NAME] ) Ok if each succeeding element is numerically greater than or equal to the one before. =cut sub array_sorted_ascending_ok(\@;$) { my $array = shift; my $name = shift || 'Array is in ascending order'; my $last_seen = 0; ELEMENT: foreach my $index ( 1 .. $#$array ) { if( $array->[ $index ] >= $array->[ $index - 1 ] ) { $last_seen = $index; next; } last; } $last_seen == $#$array ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =item array_sorted_descending_ok( ARRAY, [, NAME] ) Ok if each succeeding element is numerically less than or equal to the one before. =cut sub array_sorted_descending_ok(\@;$) { my $array = shift; my $name = shift || 'Array is in descending order'; my $last_seen = 0; ELEMENT: foreach my $index ( 1 .. $#$array ) { if( $array->[ $index ] <= $array->[ $index - 1 ] ) { $last_seen = $index; next; } last; } $last_seen == $#$array ? $Test->ok( 1, $name ) : $Test->ok( 0, $name ); } =back =head1 SEE ALSO L, L, L, L, L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/test-data =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2002-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =cut "bumble bee"; Test-Data-1.248/lib/Test/Data/Function.pm0000644000076500000240000000261514777035207016775 0ustar brianstaffuse 5.008; package Test::Data::Function; use strict; use Exporter qw(import); our @EXPORT = qw(prototype_ok); our $VERSION = '1.248'; use Test::Builder; my $Test = Test::Builder->new(); =encoding utf8 =head1 NAME Test::Data::Function -- test functions for functions =head1 SYNOPSIS use Test::Data qw(Function); =head1 DESCRIPTION This module provides test functions for subroutine sorts of things. =head2 Functions =over 4 =item prototype_ok( PROTOTYPE, SUB [, NAME ] ) =cut sub prototype_ok(\&$;$) { my $sub = shift; my $prototype = shift; my $name = shift || 'function prototype is correct'; my $actual = prototype( $sub ); my $test = $actual eq $prototype; unless( $test ) { $Test->diag( "Subroutine has prototype [$actual]; expected [$prototype]" ); $Test->ok(0, $name); } else { $Test->ok( $test, $name ); } } =back =head1 SEE ALSO L, L, L, L, L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/test-data =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2002-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =cut "red leather yellow leather"; Test-Data-1.248/lib/Test/Data.pm0000644000076500000240000000416014777035207015205 0ustar brianstaffuse 5.008; package Test::Data; use strict; our $VERSION = '1.248'; use Carp qw(carp); use Test::Builder; my $Test = Test::Builder->new(); =encoding utf8 =head1 NAME Test::Data -- test functions for particular variable types =head1 SYNOPSIS use Test::Data qw(Scalar Array Hash Function); =head1 DESCRIPTION Test::Data provides utility functions to check properties and values of data and variables. =cut $Exporter::Verbose = 0; sub import { my $self = shift; my $caller = caller; foreach my $package ( @_ ) { my $full_package = "Test::Data::$package"; eval{ eval "require $full_package" }; if( $@ ) { carp "Could not require Test::Data::$package: $@"; } $full_package->Exporter::export($caller); } } =head2 Functions Plug-in modules define functions for each data type. See the appropriate module. =head2 How it works The Test::Data module simply emports functions from Test::Data::* modules. Each module defines a self-contained function, and puts that function name into @EXPORT. Test::Data defines its own import function, but that does not matter to the plug-in modules. If you want to write a plug-in module, follow the example of one that already exists. Name the module Test::Data::Foo, where you replace Foo with the right name. Test::Data should automatically find it. =head1 BUGS I'm not a very good Windows Perler, so some things don't work as they should on Windows. I recently got a Windows box so I can test things, but if you run into problems, I can use all the patches or advice you care to send. =head1 SEE ALSO L, L, L, L, L =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/test-data =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2002-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =cut "Now is the time for all good men to come to the aid of their country"; Test-Data-1.248/Makefile.PL0000644000076500000240000000546214777035207014271 0ustar brianstaffpackage Test::Data; use strict; use warnings; =encoding utf8 =head1 The build file for Test::Data This build file is a modulino; it works as both a build script and a module. To build the distribution, run this file normally: % perl Makefile.PL But, it's more interesting than that. You can load it with C and call C to get the data structure it passes to C: my $package = require '/path/to/Makefile.PL'; my $arguments = $package->arguments; Note that C-ing a file makes an entry in C<%INC> for exactly that name. If you try to C another file with the same name, even from a different path, C thinks it has already loaded the file. As such, I recommend you always require the full path to the file. The return value of the C is a package name (in this case, the name of the main module. Use that to call the C method. Even if this distribution needs a higher version of Perl, this bit only needs v5.8. You can play with the data structure with a primitive Perl. =cut use File::Spec::Functions qw(catfile); my $module = __PACKAGE__; ( my $dist = $module ) =~ s/::/-/g; my $github = 'https://github.com/briandfoy/test-data'; my $main_file = catfile( 'lib', split /::/, "$module.pm" ); my %WriteMakefile = ( 'MIN_PERL_VERSION' => '5.008', 'NAME' => $module, 'ABSTRACT_FROM' => $main_file, 'VERSION_FROM' => $main_file, 'LICENSE' => 'artistic_2', 'AUTHOR' => 'brian d foy ', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.64', }, 'BUILD_REQUIRES' => { }, 'TEST_REQUIRES' => { 'Test::Builder' => '0', 'Test::Builder::Tester' => '0', 'Test::More' => '1', 'version' => '0.86', }, 'PREREQ_PM' => { 'Carp' => '0', 'Exporter' => '0', 'List::Util' => '0', 'Scalar::Util' => '0', 'strict' => '0', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => $github, web => $github, }, bugtracker => { web => "$github/issues", }, homepage => $github, }, }, clean => { FILES => "$dist-*" }, ); sub arguments { \%WriteMakefile } do_it() unless caller; sub do_it { require File::Spec; my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21" if -e File::Spec->catfile( qw(t test_manifest) ); my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@; WriteMakefile( %$arguments ); } no warnings; __PACKAGE__; Test-Data-1.248/INSTALL.SKIP0000644000076500000240000000015614777035207014110 0ustar brianstaffREADME\.pod README.* # things that might be in local directories after fooling # around with them \.DS_Store Test-Data-1.248/SECURITY.md0000644000076500000240000000222214777035207014077 0ustar brianstaff# Security Policy for Test::Data ## Reporting security issues **Do not report security problems on public forums or in repository issues.** Privately report vulnerabilities to the maintainers listed at the end of this document. Include as many details as possible to reproduce the issue, including code samples or test cases. Check that your report does not expose any of your sensitive data, such as passwords, tokens, or other secrets. You do not need to have a solution or fix. Depending on the issue, CPANSec may be notified. You can also privately report issues to the CPAN Security Group (CPANSec) . This is especially important if you think a vulnerability is being actively exploited. CPANSec may report the issue to the relevant authorities. See [Report a Security Issue](https://security.metacpan.org/docs/report.html). ## Response to reports The maintainers aim to respond to all reports within one day, but this may be affected by life and other things that happen to people who maintain open source code. A new release will be provided as soon as possible. ## Maintainers * brian d foy, Test-Data-1.248/META.json0000664000076500000240000000311014777035210013720 0ustar brianstaff{ "abstract" : "test functions for particular variable types", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Test-Data", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "List::Util" : "0", "Scalar::Util" : "0", "perl" : "5.008", "strict" : "0" } }, "test" : { "requires" : { "Test::Builder" : "0", "Test::Builder::Tester" : "0", "Test::More" : "1", "version" : "0.86" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/briandfoy/test-data/issues" }, "homepage" : "https://github.com/briandfoy/test-data", "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/test-data", "web" : "https://github.com/briandfoy/test-data" } }, "version" : "1.248", "x_serialization_backend" : "JSON::PP version 4.16" }