File: import_flags.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 (74 lines) | stat: -rw-r--r-- 1,618 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use strict; use warnings;
use lib -e 't' ? 't' : 'test';
use Test::More;
use IO_All_Test;

BEGIN {
    plan(($] < 5.008003)
          ? (skip_all => 'Broken on older perls')
          : (tests => 16)
    );
}

package One;
use IO::All -strict;


package Two;
use IO::All -utf8;


package Three;
use IO::All -strict, -utf8;


package Four;
use IO::All -foo;


package main;
main::ok(defined &One::io, 'io is exported to One');
main::ok(defined &Two::io, 'io is exported to Two');
main::ok(defined &Three::io, 'io is exported to Three');
main::ok(defined &Four::io, 'io is exported to Four');

my $io1 = One::io('xxx');
ok $io1->_strict,
   'strict flag set on object 1';
ok not($io1->_has_utf8),
   'utf8 flag not set on object 1';

my $io2 = Two::io('xxx');
ok not($io2->_strict),
   'strict flag not set on object 2';
ok $io2->_has_utf8,
   'utf8 flag set on object 2';

my $io3 = Three::io('xxx');
ok $io3->_strict,
   'strict flag set on object 3';
ok $io3->_has_utf8,
   'utf8 flag set on object 3';

eval "Four::io('xxx')";
like $@, qr/Can't find a class for method 'foo'/,
    '-foo flag causes error';

my $io2b = $io2->catfile('yyy');
is $io2b->name, f('xxx/yyy'),
   'catfile name is correct';
ok not($io2b->_strict),
   'strict flag not set on object 2b (propagated from 2)';
ok $io2b->_has_utf8,
   'utf8 flag set on object 2b (propagated from 2)';

my $io2c = Two::io('aaa')->curdir;
# use Data::Dumper;
# die Dumper \%{*$io2c};
ok not($io2c->_strict),
   'strict flag not set on object 2c (propagated from 2)';
ok $io2c->_has_utf8,
   'utf8 flag set on object 2c (propagated from 2)';


del_output_dir();