File: 50-escape.t

package info (click to toggle)
libstring-escape-perl 2010.002-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 362; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 675 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

use strict;
use Test;
BEGIN { plan tests => 3, todo => [] }

use String::Escape qw( printable unprintable escape );

{
	my ( $original, $printable, $comparison );

	# Backslash escapes for newline and tab characters

	$original = "\tNow is the time\nfor all good folk\nto party.\n";
	$comparison = '\\tNow is the time\\nfor all good folk\\nto party.\\n';

	ok( escape('qprintable', $original) eq '"' . $comparison . '"' );
}

{
	# Can pass in function references

	my $running_total;
	my @results = escape( sub { $running_total += shift; }, 23, 4, 2, 13 );
	ok( $results[3] == 42 );
}

{ 
	eval {
		escape( 'no-such-escape-style', 'foobar' )
	};
	ok( $@ )
}