File: 56_ellipsis.t

package info (click to toggle)
libstring-print-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 208 kB
  • sloc: perl: 989; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,437 bytes parent folder | download
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
44
45
46
47
48
49
50
51
#!/usr/bin/env perl
# Test the ellipsis modifier

use warnings;
use strict;
use utf8;

use Test::More;

use String::Print;

my $f = String::Print->new;
isa_ok($f, 'String::Print');

my $text1 = "123456789012345678901234567890";
is $f->sprinti("Intro: {text}", text => $text1), "Intro: $text1", 'no modifier';

is $f->sprinti("Intro: {text EL(50)}", text => $text1), "Intro: $text1", 'fits in field easily';

### these are all examples from the manual page

is $f->sprinti("Intro: {text EL(10)}", text => $text1),
	"Intro: 12345678⋯ ", 'default ellipsis';

is $f->sprinti("Intro: {text EL(10,)}", text => $text1),
	"Intro: 12345678⋯ ", 'default ellipsis, empty replace';

is $f->sprinti("Intro: {text EL(1,)}", text => $text1),
	"Intro: ⋯ ", 'replace too large';

is $f->sprinti("Intro: {text EL(10,⋮)}", text => $text1),
	"Intro: 123456789⋮", 'vertical ellipsis';

is $f->sprinti("Intro: {text EL(10⋮)}", text => $text1),
	"Intro: 123456789⋮", 'vertical ellipsis without comma';

is $f->sprinti("Intro: {text EL(10,XY)}", text => $text1),
	"Intro: 12345678XY", 'longer replacement';

is $f->sprinti("Intro: {text EL(10XY)}", text => $text1),
	"Intro: 12345678XY", 'longer replacement without comma';

# Defaults

$f->setDefaults(EL => { width => 20 });
is $f->sprinti("Intro: {text EL}", text => $text1),
	"Intro: 123456789012345678⋯ ", 'defaults';

#XXX this needs testing for wide and zero-width strings

done_testing;