File: binary_utf8.t

package info (click to toggle)
libio-all-perl 0.87-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 2,017; makefile: 5
file content (36 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download | duplicates (4)
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
use strict; use warnings;
use lib -e 't' ? 't' : 'test';
use utf8;

use Test::More tests => 8;

use IO::All;
use IO_All_Test;

my $f = io->file(o_dir(), 'binary_utf8')->name;

io($f)->open('>')->binary->binmode('crlf')->print("\n");
is(-s $f, 2, "layers of a filehandle are correctly edited if defined after opening it");

io($f)->binary->binmode('crlf')->print("\n");
is(-s $f, 2, "layers of a filehandle are correctly edited if defined before opening it");

io($f)->binary->utf8->print("\n");
is(-s $f, 1, "a filehandle marked binary should never mangle newlines");

io($f)->open('>')->binary->encoding('UTF-8')->print("ö\n");
is(-s $f, 3, ":raw and utf8 encoding work correctly if defined after opening fh");

io($f)->binary->encoding('UTF-8')->print("ö\n");
is(-s $f, 3, ":raw and utf8 encoding work correctly if defined before opening fh");

io($f)->open('>')->binmode->encoding('UTF-8')->print("ö\n");
is(-s $f, 3, "binmode functions correctly without args after opening it");

io($f)->encoding('UTF-8')->binmode->print("ö\n");
is(-s $f, 2, "binmode functions correctly without args before opening it");

io($f)->binary->encoding('UTF-8')->binmode->print("ö\n");
is(-s $f, 2, "binmode functions correctly without args before opening it");

del_output_dir();