File: 10formatting.t

package info (click to toggle)
libstring-tagged-terminal-perl 0.08-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 172 kB
  • sloc: perl: 653; makefile: 13
file content (43 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use String::Tagged::Terminal;
use Convert::Color;

# ->new_from_formatting
{
   # 100% red is index 9
   my $st = String::Tagged::Terminal->new_from_formatting(
      String::Tagged->new_tagged( "red", fg => Convert::Color->new( 'rgb:1,0,0' ) )
   );

   is( $st->get_tag_at( 0, "fgindex" ), 9, '$st has fgindex tag' );

   # monospace is altfont=1
   $st = String::Tagged::Terminal->new_from_formatting(
      String::Tagged->new_tagged( "mono", monospace => 1 )
   );

   is( $st->get_tag_at( 0, "altfont" ), 1, '$st has altfont tag' );
}

# ->as_formatting
{
   # 100% green is index 10
   my $st = String::Tagged::Terminal->new_tagged( "green", fgindex => 10 )
      ->as_formatting;

   is( uc $st->get_tag_at( 0, "fg" )->hex, "00FF00", '$st has fg tag' );

   # altfont=1 is monospace
   $st = String::Tagged::Terminal->new_tagged( "fixed", altfont => 1 )
      ->as_formatting;

   ok( $st->get_tag_at( 0, "monospace" ), '$st has monospace tag' );
}

done_testing;