File: 08-import-specs.t

package info (click to toggle)
liblatex-encode-perl 0.092.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 372 kB
  • ctags: 17
  • sloc: perl: 1,282; makefile: 4
file content (33 lines) | stat: -rwxr-xr-x 1,493 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl
# $Id: 08-import-specs.t 19 2012-08-29 06:19:44Z andrew $

use strict;
use warnings;

use Test::More tests => 9;

use blib;
use LaTeX::Encode
    ':all',
    add    => { "\$"       => 'DOLLAR',
                "\x{00A3}" => 'POUND' },
    remove => [ qw( % ) ];

diag('add/remove specified on \'use LaTeX::Encode\'');
is(latex_encode('$'),        'DOLLAR', '\'$\' => \'DOLLAR\' - mapping added on import');
is(latex_encode("\x{00A3}"), 'POUND',  '\'£\' => \'POUND\'  - mapping added on import');
is(latex_encode('%'),        '%',      '\'%\' => \'%\')     - mapping removed on import');

diag('resetting and forgetting mappings specified on import');
LaTeX::Encode->reset_latex_encodings(1);

is(latex_encode('$'),        '\\$',              '\'$\' => \'\\$\'              - standard mapping restored on reset');
is(latex_encode("\x{00A3}"), '{\\textsterling}', '\'£\' => \'{\\textsterling}\' - standard mapping restored on reset');
is(latex_encode('%'),        '\\%',              '\'%\' => \'\\%\'              - standard mapping restored on reset');

diag('resetting and remembering mappings specified on import');
LaTeX::Encode->reset_latex_encodings();

is(latex_encode('$'),        'DOLLAR',           '\'$\' => \'DOLLAR\' - our mapping restored on reset');
is(latex_encode("\x{00A3}"), 'POUND',            '\'£\' => \'POUND\'  - our mapping restored on reset');
is(latex_encode('%'),        '%',                '\'%\' => \'%\')     - our mapping restored on reset');