Test AN::Tools::Alert

From Alteeve Wiki
Revision as of 03:21, 5 May 2013 by Digimer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

 AN!Tools :: AN::Tools :: Test AN::Tools::Alert

t/Alert.t

#!/usr/bin/perl -Tw
#
# This is the test script for the AN::Tools family of modules.
# 

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

# Make sure that $parent matches $an.
my $parent=$an->Alert->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", "error", "no_fatal_errors", "_error_string", "_error_code", "_set_error", "_set_error_code", "_nice_exit");
can_ok("AN::Tools::Alert", @methods);

# Make sure that I can turn fatal errors off.
is($an->Alert->no_fatal_errors(), 0, "no_fatal_errors(); fatal errors are enabled by default.");
is($an->Alert->no_fatal_errors({set=>1}), 1, "no_fatal_errors(); fatal errors were turned off.");
is($an->Alert->no_fatal_errors(), 1, "no_fatal_errors(); fatal errors stayed off.");
is($an->Alert->no_fatal_errors({set=>0}), 0, "no_fatal_errors(); fatal errors were turned back on.");
is($an->Alert->no_fatal_errors(), 0, "no_fatal_errors(); fatal errors stayed on.");

# I can't trigger a real error at this time (a real one will be triggered in
# 't/Math.t'). For now, I will test the internal methods directly.
is($an->Alert->_error_string(), "", "Internal method '_error_string' is blank to start.");
is($an->Alert->_set_error("Test Error"), "Test Error", "Internal method '_set_error' manually set to 'Test Error'.");
is($an->Alert->_error_string(), "Test Error", "Internal method '_error_string' is now 'Test Error'.");
is($an->Alert->_set_error(), "", "Internal method '_set_error' manually cleared.");
is($an->Alert->_set_error(), "", "Internal method '_set_error' is still clear.");

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.