This file is indexed.

/usr/share/doc/libtype-tiny-perl/examples/versus-scalar-validation.pl is in libtype-tiny-perl 1.000005-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
78
79
80
81
82
83
84
85
86
87
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use Test::Benchmark;
use Benchmark qw(timethis);

$Test::Benchmark::VERBOSE = 1;

{
	package UseSV;
	
	use Scalar::Validation qw(:all);
	
	sub test {
		my $p_bool = par p_bool => -Enum => [0 => '1']               => shift;
		my $p_123  = par p_123  => -Enum => {1 => 1, 2 => 1, 3 => 1} => shift;
		my $p_free = par p_free => sub { $_ > 5 } => shift, sub { "$_ is not larger than 5" };
		p_end \@_;
		
		return $p_bool + $p_123 + $p_free;
	}
}

{
	package UseTP;
	
	use Type::Params qw(compile);
	use Types::Standard qw(Enum);
	use Types::XSD::Lite qw(Integer);
	
	my $_check = compile Enum[0,1], Enum[1..3], Integer[minExclusive => 5];
	
	sub test {
		my ($p_bool, $p_123, $p_free) = $_check->(@_);
		return $p_bool + $p_123 + $p_free;
	}
}

subtest "Scalar::Validation works ok" => sub {
	is( UseSV::test(1,2,7), 10 );
	
	like(
		exception { UseSV::test(2,2,2) },
		qr/^Error/,
	);
};

subtest "Type::Params works ok" => sub {
	is( UseTP::test(1,2,7), 10 );
	
	like(
		exception { UseTP::test(2,2,2) },
		qr/did not pass type constraint/,
	);
};

is_fastest('TP', -1, {
	SV  => q[ UseSV::test(1,2,7) ],
	TP  => q[ UseTP::test(1,2,7) ],
}, 'Type::Params is fastest at passing validations');

is_fastest('TP', -1, {
	SV  => q[ eval { UseSV::test(1,2,3) } ],
	TP  => q[ eval { UseTP::test(1,2,3) } ],
}, 'Type::Params is fastest at failing validations');

done_testing;

__END__
	# Subtest: Scalar::Validation works ok
	ok 1
	ok 2
	1..2
ok 1 - Scalar::Validation works ok
	# Subtest: Type::Params works ok
	ok 1
	ok 2
	1..2
ok 2 - Type::Params works ok
ok 3 - Type::Params is fastest at passing validations
# TP -  2 wallclock secs ( 1.17 usr +  0.00 sys =  1.17 CPU) @ 6564.10/s (n=7680)
# SV -  1 wallclock secs ( 1.03 usr +  0.00 sys =  1.03 CPU) @ 4744.66/s (n=4887)
ok 4 - Type::Params is fastest at failing validations
# TP -  1 wallclock secs ( 1.05 usr +  0.00 sys =  1.05 CPU) @ 3412.38/s (n=3583)
# SV -  1 wallclock secs ( 1.07 usr +  0.03 sys =  1.10 CPU) @ 1285.45/s (n=1414)
1..4