Math-NoCarry-1.113/000755 000765 000024 00000000000 13777510672 014240 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/LICENSE000644 000765 000024 00000017404 13777510670 015251 0ustar00brianstaff000000 000000 The Math::NoCarry 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.
http://www.perlfoundation.org/artistic_license_2_0
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
Math-NoCarry-1.113/Changes000644 000765 000024 00000002071 13777510670 015531 0ustar00brianstaff000000 000000 Revision history for Perl module Math::NoCarry
1.113 2021-01-13T06:22:25Z
* freshen distro, remove Travis CI, use Github Actions
1.112 2018-05-24T14:14:51Z
* Change to Artistic License 2.0
1.111 2016-01-27T20:21:05Z
* Freshen distro, remove prereq.t test
1.11 - 2007-12-09
* Now all the functions are exportable on demand.
* Distro requires 5.006, although it probably stills works on
earlier versions. I'm not actively supporting those though.
1.10 - 2007-01-09
* updated copyright and license info
* no code changes, so no need to upgrade
1.09 - 2006-05-18
* Updates to distro and kwalitee. No need to upgrade.
1.08 - 2005-03-11
* Updated docs for POD coverage tests
* No code changes, but the docs for subtract() are labelled
correctly now.
1.07 - 2004-11-17
* no changes
1.07 - 2004-10-08
* no feature changes: added strictures and removed unreachable statement
1.06 - 2004-09-08
* cleaned up the distro and the docs
* no code changes, no need to upgrade
0.01 - 2002-06-25
* original version; created by h2xs 1.21 with options
-AXn Math::NoCarry
Math-NoCarry-1.113/MANIFEST000644 000765 000024 00000000615 13777510672 015373 0ustar00brianstaff000000 000000 Changes
examples/README
INSTALL.SKIP
lib/Math/NoCarry.pm
LICENSE
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
README.pod
t/add.t
t/load.t
t/multiply.t
t/pod.t
t/pod_coverage.t
t/subtract.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)
Math-NoCarry-1.113/t/000755 000765 000024 00000000000 13777510671 014502 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/xt/000755 000765 000024 00000000000 13777510671 014672 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/README.pod000644 000765 000024 00000007404 13777510670 015704 0ustar00brianstaff000000 000000 =pod
=encoding utf8
=for HTML
=for HTML
=for HTML
=for HTML
=for HTML
=for HTML
=for HTML
=head1 The Math::NoCarry module
This is the I for the L Perl module. 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/Math/NoCarry.pm
If you have already installed the module, you can specify the module
name instead of the file location:
% perldoc Math::NoCarry
You can read the documentation and inspect the meta data on
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 Math::NoCarry
% cpanm Math::NoCarry
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:
=over 4
=item * L
=back
If you find a problem, file a ticket in the L:
=over 4
=item * L
=back
=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, bdfoy@cpan.org
=cut
Math-NoCarry-1.113/MANIFEST.SKIP000644 000765 000024 00000002330 13777510670 016132 0ustar00brianstaff000000 000000
#!start included /usr/local/perls/perl-5.22.0/lib/5.22.0/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
\b_eumm/ # 7.05_05 and above
# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$
# and Module::Build::Tiny generated files
\b_build_params$
# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
\..*\.sw.?$
# 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 prove files
\B\.prove$
# Avoid MYMETA files
^MYMETA\.
#!end included /usr/local/perls/perl-5.22.0/lib/5.22.0/ExtUtils/MANIFEST.SKIP
\.releaserc
\.lwpcookies
\.travis\.yml
\.appveyor\.yml
\bMANIFEST\s\d
\bChanges\s\d
.*.icloud
\A\.github\b
Math-NoCarry-1.113/examples/000755 000765 000024 00000000000 13777510671 016055 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/META.yml000664 000765 000024 00000001412 13777510671 015510 0ustar00brianstaff000000 000000 ---
abstract: 'Perl extension for no-carry arithmetic'
author:
- 'brian d foy '
build_requires:
Test::More: '1'
configure_requires:
ExtUtils::MakeMaker: '6.64'
File::Spec::Functions: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.34, 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: Math-NoCarry
no_index:
directory:
- t
- inc
requires:
perl: '5.008'
resources:
bugtracker: https://github.com/briandfoy/math-nocarry/issues
homepage: https://github.com/briandfoy/math-nocarry
repository: https://github.com/briandfoy/math-nocarry.git
version: '1.113'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Math-NoCarry-1.113/lib/000755 000765 000024 00000000000 13777510671 015005 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/Makefile.PL000644 000765 000024 00000005111 13777510670 016206 0ustar00brianstaff000000 000000 package Math::NoCarry;
use strict;
use warnings;
=encoding utf8
=head1 The build file for Math::NoCarry
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/math-nocarry';
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',
'File::Spec::Functions' => '0',
},
'BUILD_REQUIRES' => {
},
'TEST_REQUIRES' => {
'Test::More' => '1',
},
'PREREQ_PM' => {
},
'META_MERGE' => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => "$github.git",
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__;
Math-NoCarry-1.113/INSTALL.SKIP000644 000765 000024 00000000156 13777510670 016036 0ustar00brianstaff000000 000000 README\.pod
README.*
# things that might be in local directories after fooling
# around with them
\.DS_Store
Math-NoCarry-1.113/META.json000664 000765 000024 00000002567 13777510672 015675 0ustar00brianstaff000000 000000 {
"abstract" : "Perl extension for no-carry arithmetic",
"author" : [
"brian d foy "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"artistic_2"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Math-NoCarry",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "6.64",
"File::Spec::Functions" : "0"
}
},
"runtime" : {
"requires" : {
"perl" : "5.008"
}
},
"test" : {
"requires" : {
"Test::More" : "1"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/briandfoy/math-nocarry/issues"
},
"homepage" : "https://github.com/briandfoy/math-nocarry",
"repository" : {
"type" : "git",
"url" : "https://github.com/briandfoy/math-nocarry.git",
"web" : "https://github.com/briandfoy/math-nocarry"
}
},
"version" : "1.113",
"x_serialization_backend" : "JSON::PP version 4.02"
}
Math-NoCarry-1.113/lib/Math/000755 000765 000024 00000000000 13777510671 015676 5ustar00brianstaff000000 000000 Math-NoCarry-1.113/lib/Math/NoCarry.pm000644 000765 000024 00000010254 13777510670 017612 0ustar00brianstaff000000 000000 package Math::NoCarry;
use strict;
use warnings;
no warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(add subtract multiply);
our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
our $VERSION = '1.113';
=encoding utf8
=head1 NAME
Math::NoCarry - Perl extension for no-carry arithmetic
=head1 SYNOPSIS
use Math::NoCarry qw(:all);
my $sum = add( 123, 456 );
my $difference = subtract( 123, 456 );
my $product = multiply( 123, 456 );
=head1 DESCRIPTION
No-carry arithmetic doesn't allow you to carry digits to the
next column. For example, if you add 8 and 4, you normally
expect the answer to be 12, but that 1 digit is a carry.
In no-carry arithmetic you can't do that, so the sum of
8 and 4 is just 2. In effect, this is addition modulo 10
in each column. I discard all of the carry digits in
this example:
1234
+ 5678
------
6802
For multiplication, the result of pair-wise multiplication
of digits is the modulo 10 value of their normal, everyday
multiplication.
123
x 456
-----
8 6 x 3
2 6 x 2
6 6 x 1
5 5 x 3
0 5 x 2
5 5 x 1
2 4 x 3
8 4 x 2
+ 4 4 x 1
-------
43878
Since multiplication and subtraction are actually types of
additions, you can multiply and subtract like this as well.
No carry arithmetic is both associative and commutative.
=head2 Functions
As of version 1.11, all of these functions are exportable on
demand, or with the tag C<:all> to get them all at once.
=over 4
=item multiply( A, B )
Returns the no carry product of A and B.
Return A if it is the only argument ( A x 1 );
=cut
sub multiply {
return $_[0] if $#_ < 1;
@_ = map { $_ += 0 } @_;
my $sign = ($_[0] > 0 and $_[1] < 0 ) ||
($_[1] > 0 and $_[0] < 0 );
my @p0 = reverse split //, abs $_[0];
my @p1 = reverse split //, abs $_[1];
my @m;
foreach my $i ( 0 .. $#p0 ) {
foreach my $j ( 0 .. $#p1 ) {
push @m, ( ( $p1[$j] * $p0[$i] ) % 10 ) * ( 10**($i+$j) );
}
}
while( @m > 1 ) {
unshift @m, Math::NoCarry::add( shift @m, shift @m );
}
$m[0] *= -1 if $sign;
return $m[0];
}
=item add( A, B )
Returns the no carry sum of the positive numbers A and B.
Returns A if it is the only argument ( A + 0 )
Returns false if either number is negative.
=cut
sub add {
return $_[0] if $#_ < 1;
@_ = map { local $^W; $_ += 0 } @_;
return unless( $_[0] >= 0 and $_[1] >= 0 );
my @addends = map scalar reverse, @_;
my $string = '';
my $max = length $addends[0];
$max = length $addends[1] if length $addends[1] > $max;
for( my $i = 0; $i < $max ; $i++ ) {
my @digits = map { local $^W = 0; substr( $_, $i, 1) or 0 } @addends;
my $sum = ( $digits[0] + $digits[1] ) % 10;
$string .= $sum;
}
$string =~ s/0*$//;
$string = scalar reverse $string;
return $string;
}
=item subtract( A, B )
Returns the no carry difference of the positive numbers A and B.
Returns A if it is the only argument ( A - 0 )
Returns false if either number is negative.
=cut
sub subtract {
return $_[0] if $#_ < 1;
return unless( $_[0] >= 0 and $_[1] >= 0);
my @addends = map scalar reverse, @_;
my $string = '';
my $max = length $addends[0];
$max = length $addends[1] if length $addends[1] > $max;
for( my $i = 0; $i < $max ; $i++ ) {
my @digits = map { substr $_, $i, 1 } @addends;
$digits[0] += 10 if $digits[0] < $digits[1];
my $sum = ( $digits[0] - $digits[1] ) % 10;
$string .= $sum;
}
return scalar reverse $string;
}
1;
__END__
=back
=head1 BUGS
=over 4
=item * none reported yet :)
=back
=head1 TO DO
=over 4
=item * this could be a full object package with overloaded +, *, and - operators
=item * it would be nice if I could give the functions more than two arguments.
=item * addition and subtraction don't do negative numbers.
=back
=head1 SOURCE AVAILABILITY
This source is in GitHub:
https://github.com/briandfoy/math-nocarry
=head1 AUTHOR
brian d foy, C<< >>
=head1 COPYRIGHT AND LICENSE
Copyright © 2002-2021, 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
Math-NoCarry-1.113/examples/README000644 000765 000024 00000000105 13777510670 016730 0ustar00brianstaff000000 000000 See the tests in the t/ directory for examples until I add some more.Math-NoCarry-1.113/xt/changes.t000644 000765 000024 00000000203 13777510670 016461 0ustar00brianstaff000000 000000 use Test::More;
eval 'use Test::CPAN::Changes';
plan skip_all => 'Test::CPAN::Changes required for this test' if $@;
changes_ok();
Math-NoCarry-1.113/t/pod.t000644 000765 000024 00000000201 13777510670 015441 0ustar00brianstaff000000 000000 use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();
Math-NoCarry-1.113/t/multiply.t000644 000765 000024 00000002330 13777510670 016543 0ustar00brianstaff000000 000000 BEGIN { print "1..4\n"; }
END { print "not ok\n" unless $loaded }
use Math::NoCarry;
$loaded = 1;
print "ok\n";
my @triads = (
[qw( 123 456 43878)],
[qw(-123 -456 43878)],
[qw(-123 456 -43878)],
[qw( 123 -456 -43878)],
[qw(456 123 43878)],
[qw(456 879 28974)],
[qw(879 456 28974)],
[qw( 890 135 83750)],
[qw( 135 890 83750)],
[qw(-135 890 -83750)],
[qw( 135 -890 -83750)],
[qw(-135 -890 83750)],
[qw(500 321 50500)],
[qw(321 500 50500)],
);
eval {
foreach my $triad ( @triads )
{
my( $n, $m, $expected ) = @$triad;
my $product = Math::NoCarry::multiply( $n, $m );
die "[$n x $m] gave [$product], but I expected [$expected]\n"
unless $product == $expected;
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
foreach my $triad ( @triads )
{
foreach my $n ( @$triad )
{
my $product = Math::NoCarry::multiply( $n );
die "[$n] gave [$product], but I expected [$n]\n"
unless $product == $n;
}
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
my $product = Math::NoCarry::multiply();
die "[NULL] gave [$product], but I expected [FALSE]\n"
if $product;
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
Math-NoCarry-1.113/t/load.t000644 000765 000024 00000000277 13777510670 015613 0ustar00brianstaff000000 000000 BEGIN {
@classes = qw(Math::NoCarry);
}
use Test::More tests => scalar @classes;
foreach my $class ( @classes )
{
print "bail out! $class did not compile\n" unless use_ok( $class );
}
Math-NoCarry-1.113/t/add.t000644 000765 000024 00000002076 13777510670 015423 0ustar00brianstaff000000 000000 BEGIN { print "1..4\n"; }
END { print "not ok\n" unless $loaded }
use Math::NoCarry;
$loaded = 1;
print "ok\n";
my @triads = (
[qw(123 456 579)],
[qw(890 135 925)],
[qw(456 879 225)],
);
eval {
foreach my $triad ( @triads )
{
my( $n, $m, $expected ) = @$triad;
my $sum1 = Math::NoCarry::add( $n, $m );
my $sum2 = Math::NoCarry::add( $m, $n );
die "Different results for different orders!\n" .
"[$n + $m] gave [$sum1]\n[$m + $n] gave [$sum2]\n"
if $sum1 != $sum2;
die "[$n + $m] gave [$sum1], but I expected [$expected]\n"
unless $sum1 == $expected;
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
foreach my $triad ( @triads )
{
foreach my $n ( @$triad )
{
my $sum = Math::NoCarry::add( $n );
die "[$n] gave [$sum], but I expected [$n]\n"
unless $sum == $n;
}
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
my $sum = Math::NoCarry::add();
die "[NULL] gave [$sum], but I expected [FALSE]\n"
if $sum;
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
Math-NoCarry-1.113/t/subtract.t000644 000765 000024 00000002066 13777510670 016521 0ustar00brianstaff000000 000000 BEGIN { print "1..4\n"; }
END { print "not ok\n" unless $loaded }
use Math::NoCarry;
$loaded = 1;
print "ok\n";
my @triads = (
[qw(123 456 579)],
[qw(890 135 925)],
[qw(456 879 225)],
);
eval {
foreach my $triad ( @triads )
{
my( $expected, $m, $n ) = @$triad;
my $diff1 = Math::NoCarry::subtract( $n, $m );
my $diff2 = Math::NoCarry::subtract( $n, $expected );
die "[$n - $m] gave [$diff], but I expected [$expected]\n"
unless $diff1 == $expected;
die "[$n - $expected] gave [$diff], but I expected [$m]\n"
unless $diff2 == $m;
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
foreach my $triad ( @triads )
{
foreach my $n ( @$triad )
{
my $diff = Math::NoCarry::subtract( $n );
die "[$n] gave [$diff], but I expected [$n]\n"
unless $diff == $n;
}
}
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
eval {
my $diff = Math::NoCarry::subtract();
die "[NULL] gave [$diff], but I expected [FALSE]\n"
if $diff;
};
print STDERR $@ if $@;
print $@ ? 'not ' : '', "ok\n";
Math-NoCarry-1.113/t/test_manifest000644 000765 000024 00000000070 13777510670 017266 0ustar00brianstaff000000 000000 load.t
pod.t
pod_coverage.t
add.t
multiply.t
subtract.t
Math-NoCarry-1.113/t/pod_coverage.t000644 000765 000024 00000000313 13777510670 017320 0ustar00brianstaff000000 000000 use Test::More;
eval "use Test::Pod::Coverage";
if( $@ )
{
plan skip_all => "Test::Pod::Coverage required for testing POD";
}
else
{
plan tests => 1;
pod_coverage_ok( "Math::NoCarry" );
}