File: context.t

package info (click to toggle)
liblexical-sealrequirehints-perl 0.012-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 340; makefile: 3
file content (77 lines) | stat: -rw-r--r-- 1,614 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use warnings;
use strict;

use Test::More tests => 27;

BEGIN { use_ok "Lexical::SealRequireHints"; }
BEGIN { unshift @INC, "./t/lib"; }

my $retval;

eval { $retval = require t::context_0; 1 };
is $@, "";
is $retval, "t::context_0 return";

eval { $retval = require t::context_0; 1 };
is $@, "";
is $retval, 1;

eval { $retval = [ require t::context_1 ]; 1 };
is $@, "";
is_deeply $retval, ["t::context_1 return"];

eval { $retval = [ require t::context_1 ]; 1 };
is $@, "";
is_deeply $retval, [1];

eval { require t::context_2; 1 };
is $@, "";

eval { require t::context_2; 1 };
is $@, "";

eval { $retval = do "t/context_d0.pl"; 1 };
is $@, "";
is $retval, "t::context_d0 return";

eval { $retval = do "t/context_d0.pl"; 1 };
is $@, "";
is $retval, "t::context_d0 return";

eval { $retval = [ do "t/context_d1.pl" ]; 1 };
is $@, "";
is_deeply $retval, [
	("$]" >= 5.007001 ? ("t::context_d1 return", "in three") : ()),
	"parts",
];

eval { $retval = [ do "t/context_d1.pl" ]; 1 };
is $@, "";
is_deeply $retval, [
	("$]" >= 5.007001 ? ("t::context_d1 return", "in three") : ()),
	"parts",
];

eval { do "t/context_d2.pl"; 1 };
is $@, "";

eval { do "t/context_d2.pl"; 1 };
is $@, "";

sub diecxt() {
	die wantarray ? "ARRAY\n" : defined(wantarray) ? "SCALAR\n" : "VOID\n";
}
eval { $retval = require(diecxt()); 1 };
is $@, "SCALAR\n";
eval { $retval = [ require(diecxt()) ]; 1 };
is $@, "SCALAR\n";
eval { require(diecxt()); 1 };
is $@, "SCALAR\n";
eval { $retval = do(diecxt()); 1 };
is $@, "SCALAR\n";
eval { $retval = [ do(diecxt()) ]; 1 };
is $@, "SCALAR\n";
eval { do(diecxt()); 1 };
is $@, "SCALAR\n";

1;