File: 00-load.t

package info (click to toggle)
libnet-dns-perl 1.29-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,608 kB
  • sloc: perl: 19,379; makefile: 9
file content (86 lines) | stat: -rw-r--r-- 1,641 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
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
# $Id: 00-load.t 1823 2020-11-16 16:29:45Z willem $	-*-perl-*-
#

use strict;
use warnings;
use Test::More;

my @module = qw(
		Net::DNS
		Digest::BubbleBabble
		Digest::HMAC
		Digest::MD5
		Digest::SHA
		Encode
		File::Spec
		IO::File
		IO::Select
		IO::Socket::IP
		MIME::Base64
		Net::LibIDN2
		PerlIO
		Scalar::Util
		Time::Local
		Win32::API
		Win32::IPHelper
		Win32::TieRegistry
		);

my @diag;
foreach my $module (@module) {
	eval "require $module";		## no critic
	for ( eval { $module->VERSION || () } ) {
		s/^(\d+\.\d)$/${1}0/;
		push @diag, sprintf "%-25s  %s", $module, $_;
	}
}
diag join "\n\t", "\nThese tests were run using:", @diag;


plan tests => 20 + scalar(@Net::DNS::EXPORT);


use_ok('Net::DNS');

is( Net::DNS->version, $Net::DNS::VERSION, 'Net::DNS->version' );


#
# Check on-demand loading using this (incomplete) list of RR packages
my @rrs = qw( A AAAA CNAME MX NS NULL PTR SOA TXT );

sub is_rr_loaded {
	my $rr = shift;
	return $INC{"Net/DNS/RR/$rr.pm"} ? 1 : 0;
}

#
# Make sure that we start with none of the RR packages loaded
foreach my $rr (@rrs) {
	ok( !is_rr_loaded($rr), "not yet loaded Net::DNS::RR::$rr" );
}

#
# Check that each RR package is loaded on demand
local $SIG{__WARN__} = sub { };					# suppress warnings

foreach my $rr (@rrs) {
	my $object = eval { Net::DNS::RR->new( name => '.', type => $rr ); };
	diag($@) if $@;						# report exceptions

	ok( is_rr_loaded($rr), "loaded package Net::DNS::RR::$rr" );
}


#
# Check that Net::DNS symbol table was imported correctly
foreach my $sym (@Net::DNS::EXPORT) {
	ok( defined &{$sym}, "$sym is imported" );
}


exit;

__END__