File: 03multiple.t

package info (click to toggle)
libstring-format-perl 1.18-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 173; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,352 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl
# vim: set ft=perl ts=4 sw=4:

# ======================================================================
# 03multiple.t
#
# Attempting to pass a multi-character format string will not work.
# This means that stringf will return the malformed format characters
# as they were passed in.
# ======================================================================

use strict;

use Test::More tests => 3;
use String::Format;

my ($orig, $target, $result);

# ======================================================================
# Test 1
# ======================================================================
$orig   = q(My %foot hurts.);
$target = q(My %foot hurts.);
$result = stringf $orig, { 'foot' => 'pretzel' };
is $target => $result;

# ======================================================================
# Test 2, same as Test 1, but with a one-char format string.
# ======================================================================
$target = "My pretzeloot hurts.";
$result = stringf $orig, { 'f' => 'pretzel' };
is $target => $result;

# ======================================================================
# Test 3
# ======================================================================
$orig   = 'I am %undefined';
$target = 'I am not ndefined';
$result = stringf $orig, { u => "not " };
is $target => $result;