#!/usr/bin/perl -Tw

use AN::Tut::Tools 0.0.001;
my $an=AN::Tut::Tools->new();

# Make sure that $parent matches $an.
my $parent=$an->Math->_parent();
is($an, $parent, "Internal 'parent' method returns same blessed reference as is in \$an.");

# Make sure that all methods are available.
my @methods=("_parent", "add", "subtract", "add_and_say");
can_ok("AN::Tut::Tools::Math", @methods);

# Test adding a few numbers. Start with ints, then try signed and unsigned ints
# and floats.
#  Got					Expect	Message
is($an->Math->add(4, 8), 		12, 	"add(); Simple integer addition test.");
is($an->Math->add(4, 8.5), 		12.5, 	"add(); Integer plus float addition test.");
is($an->Math->add(5.25, 8.5), 		13.75, 	"add(); Float addition test.");
is($an->Math->add(15, -3), 		12, 	"add(); Signed integer addition test.");
is($an->Math->add(3, -15), 		-12, 	"add(); Signed integer addition with negative result test.");
is($an->Math->add(-15, -3), 		-18, 	"add(); Double-negative integer addition with negative result test.");
is($an->Math->add(+15, -3), 		12, 	"add(); Signed integer addition including '+' test.");

# Now test subtracting a few numbers. Same style of tests as above.
#  Got					Expect	Message
is($an->Math->subtract(15, 3), 		12, 	"subtract(); Simple integer subtraction test.");
is($an->Math->subtract(15, 2.5), 	12.5, 	"subtract(); Integer minus float subtraction test.");
is($an->Math->subtract(15.45, 2.5), 	12.95, 	"subtract(); Float subtraction test.");
is($an->Math->subtract(15, -3), 	18, 	"subtract(); Signed integer subtraction test.");
is($an->Math->subtract(3, -15), 	18, 	"subtract(); Signed integer subtraction with positive result test.");
is($an->Math->subtract(-15, -3), 	-12, 	"subtract(); Double-negative integer subtraction with negative result test.");
is($an->Math->subtract(+15, -3), 	18, 	"subtract(); Signed integer subtraction including '+' test.");

# Now test the 'add_and_say' method.
is(
	"I added: [15] and: [20] and got: [35].", 
	$an->Math->add_and_say(15, 20), 
	"add_and_say(); Test default language processing of a simple integer addition."
);
is(
	"J'ai additionné: [2] et: [18] et la somme est: [20].", 
	$an->Math->add_and_say(2, 18, "fr"), 
	"add_and_say(); Test specified language processing of a simple integer addition."
);
