6 # Test suite for the Term::ANSIColor Perl module. Before `make install' is
7 # performed this script should be runnable with `make test'. After `make
8 # install' it should work as `perl test.pl'.
10 ############################################################################
11 # Ensure module can be loaded
12 ############################################################################
14 BEGIN { $| = 1; print "1..8\n" }
15 END { print "not ok 1\n" unless $loaded }
16 use Term::ANSIColor qw(:constants color colored);
21 ############################################################################
23 ############################################################################
25 # Test simple color attributes.
26 if (color ('blue on_green', 'bold') eq "\e[34;42;1m") {
33 if (colored ("testing", 'blue', 'bold') eq "\e[34;1mtesting\e[0m") {
40 if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting") {
47 $Term::ANSIColor::AUTORESET = 1;
48 if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting\e[0m\e[0m") {
55 $Term::ANSIColor::EACHLINE = "\n";
56 if (colored ("test\n\ntest", 'bold')
57 eq "\e[1mtest\e[0m\n\n\e[1mtest\e[0m") {
60 print colored ("test\n\ntest", 'bold'), "\n";
64 # Test EACHLINE with multiple trailing delimiters.
65 $Term::ANSIColor::EACHLINE = "\r\n";
66 if (colored ("test\ntest\r\r\n\r\n", 'bold')
67 eq "\e[1mtest\ntest\r\e[0m\r\n\r\n") {
73 # Test the array ref form.
74 $Term::ANSIColor::EACHLINE = "\n";
75 if (colored (['bold', 'on_green'], "test\n", "\n", "test")
76 eq "\e[1;42mtest\e[0m\n\n\e[1;42mtest\e[0m") {
79 print colored (['bold', 'on_green'], "test\n", "\n", "test");