#!/usr/bin/perl
-# $Id: test.pl,v 1.4 2004/02/20 21:50:10 eagle Exp $
+# $Id: test.pl,v 1.5 2005/08/21 18:31:58 eagle Exp $
#
# test.pl -- Test suite for the Term::ANSIColor Perl module.
#
# Before "make install" is performed this script should be runnable with "make
# test". After "make install" it should work as "perl test.pl".
-############################################################################
+##############################################################################
# Ensure module can be loaded
-############################################################################
+##############################################################################
-BEGIN { $| = 1; print "1..13\n" }
+BEGIN { $| = 1; print "1..16\n" }
END { print "not ok 1\n" unless $loaded }
delete $ENV{ANSI_COLORS_DISABLED};
use Term::ANSIColor qw(:constants color colored uncolor);
$loaded = 1;
print "ok 1\n";
-
-############################################################################
+##############################################################################
# Test suite
-############################################################################
+##############################################################################
# Test simple color attributes.
if (color ('blue on_green', 'bold') eq "\e[34;42;1m") {
} else {
print "not ok 13\n";
}
+
+# Test colored with 0 and EACHLINE.
+$Term::ANSIColor::EACHLINE = "\n";
+if (colored ('0', 'blue', 'bold') eq "\e[34;1m0\e[0m") {
+ print "ok 14\n";
+} else {
+ print "not ok 14\n";
+}
+if (colored ("0\n0\n\n", 'blue', 'bold')
+ eq "\e[34;1m0\e[0m\n\e[34;1m0\e[0m\n\n") {
+ print "ok 15\n";
+} else {
+ print "not ok 15\n";
+}
+
+# Test colored with the empty string and EACHLINE.
+if (colored ('', 'blue', 'bold') eq '') {
+ print "ok 16\n";
+} else {
+ print "not ok 16\n";
+}