Commit | Line | Data |
e3e5e1ea |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | unshift @INC, '../lib'; |
6 | } |
7 | |
8 | # Test suite for the Term::ANSIColor Perl module. Before `make install' is |
9 | # performed this script should be runnable with `make test'. After `make |
10 | # install' it should work as `perl test.pl'. |
11 | |
12 | ############################################################################ |
13 | # Ensure module can be loaded |
14 | ############################################################################ |
15 | |
16 | BEGIN { $| = 1; print "1..7\n" } |
17 | END { print "not ok 1\n" unless $loaded } |
18 | use Term::ANSIColor qw(:constants color colored); |
19 | $loaded = 1; |
20 | print "ok 1\n"; |
21 | |
22 | |
23 | ############################################################################ |
24 | # Test suite |
25 | ############################################################################ |
26 | |
27 | # Test simple color attributes. |
28 | if (color ('blue on_green', 'bold') eq "\e[34;42;1m") { |
29 | print "ok 2\n"; |
30 | } else { |
31 | print "not ok 2\n"; |
32 | } |
33 | |
34 | # Test colored. |
35 | if (colored ("testing", 'blue', 'bold') eq "\e[34;1mtesting\e[0m") { |
36 | print "ok 3\n"; |
37 | } else { |
38 | print "not ok 3\n"; |
39 | } |
40 | |
41 | # Test the constants. |
42 | if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting") { |
43 | print "ok 4\n"; |
44 | } else { |
45 | print "not ok 4\n"; |
46 | } |
47 | |
48 | # Test AUTORESET. |
49 | $Term::ANSIColor::AUTORESET = 1; |
50 | if (BLUE BOLD "testing" eq "\e[34m\e[1mtesting\e[0m\e[0m") { |
51 | print "ok 5\n"; |
52 | } else { |
53 | print "not ok 5\n"; |
54 | } |
55 | |
56 | # Test EACHLINE. |
57 | $Term::ANSIColor::EACHLINE = "\n"; |
58 | if (colored ("test\n\ntest", 'bold') |
59 | eq "\e[1mtest\e[0m\n\n\e[1mtest\e[0m") { |
60 | print "ok 6\n"; |
61 | } else { |
62 | print colored ("test\n\ntest", 'bold'), "\n"; |
63 | print "not ok 6\n"; |
64 | } |
65 | |
66 | # Test EACHLINE with multiple trailing delimiters. |
67 | $Term::ANSIColor::EACHLINE = "\r\n"; |
68 | if (colored ("test\ntest\r\r\n\r\n", 'bold') |
69 | eq "\e[1mtest\ntest\r\e[0m\r\n\r\n") { |
70 | print "ok 7\n"; |
71 | } else { |
72 | print "not ok 7\n"; |
73 | } |