File: override_do.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 (69 lines) | stat: -rw-r--r-- 1,391 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
use warnings;
use strict;

use Test::More tests => 10;

our @warnings;
BEGIN {
	$^W = 1;
	$SIG{__WARN__} = sub { push @warnings, $_[0] };
}

our $have_runtime_hint_hash;
BEGIN { $have_runtime_hint_hash = "$]" >= 5.009004; }
sub test_runtime_hint_hash($$) {
	SKIP: {
		skip "no runtime hint hash", 1 unless $have_runtime_hint_hash;
		is +((caller(0))[10] || {})->{$_[0]}, $_[1];
	}
}

our @do_activity;

BEGIN {
	my $next_do = defined(&CORE::GLOBAL::do) ?
		\&CORE::GLOBAL::do : sub { CORE::do($_[0]) };
	no warnings "redefine";
	*CORE::GLOBAL::do = sub {
		push @do_activity, "a";
		return $next_do->(@_);
	};
}

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

BEGIN {
	my $next_do = defined(&CORE::GLOBAL::do) ?
		\&CORE::GLOBAL::do : sub { CORE::do($_[0]) };
	no warnings "redefine";
	no warnings "prototype";
	*CORE::GLOBAL::do = sub ($) {
		push @do_activity, "b";
		return $next_do->(@_);
	};
}

BEGIN {
	$^H |= 0x20000 if "$]" < 5.009004;
	$^H{"Lexical::SealRequireHints/test"} = 1;
}

BEGIN {
	is $^H{"Lexical::SealRequireHints/test"}, 1;
	@do_activity = ();
}
BEGIN {
	do "t/seal_0.pm" or die $@ || $!;
	t::seal_0->import;
}
BEGIN {
	is $^H{"Lexical::SealRequireHints/test"}, 1;
	is $^H{"Lexical::SealRequireHints/test0"}, 1;
	isnt scalar(@do_activity), 0;
	is_deeply \@do_activity, [("b","a") x (@do_activity>>1)];
}

is_deeply \@warnings, [];

1;