File: 10_legacy_extract.t

package info (click to toggle)
libtest-inline-perl 2.103-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 372 kB
  • ctags: 225
  • sloc: perl: 3,320; makefile: 43
file content (59 lines) | stat: -rw-r--r-- 1,566 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
#!/usr/bin/perl -w

# Check Test::Inline::Extract support for older test styles

use strict;
use lib ();
use UNIVERSAL 'isa';
use File::Spec::Functions ':ALL';
BEGIN {
	$| = 1;
	unless ( $ENV{HARNESS_ACTIVE} ) {
		require FindBin;
		chdir ($FindBin::Bin = $FindBin::Bin); # Avoid a warning
		lib->import( catdir( updir(), updir(), 'modules') );
	}
}

use Class::Autouse ':devel';
use File::Slurp ();
use Test::More tests => 7;
use Test::Inline::Extract ();





#####################################################################
# Test the examples from Inline.pm
{
	my $inline_file = File::Slurp::read_file(
		catfile( 't.data', '10_legacy_extract', 'Inline.pm' ),
		scalar_ref => 1,
		) or die "Failed to load Inline.pm test file";
	is( ref($inline_file), 'SCALAR', 'Loaded Inline.pm examples' );

	my $Extract = Test::Inline::Extract->new( $inline_file );
	isa_ok( $Extract, 'Test::Inline::Extract' );

	my $elements = $Extract->elements;
	is( ref($elements), 'ARRAY', '->elements returns an ARRAY ref' );
	is( scalar(@$elements), 3, '->elements returns three elements' );
	is( $elements->[0], 'package My::Pirate;', 'First element matches expected' );
	is( $elements->[1], <<'END_ELEMENT', 'Second element matches expected' );
=begin testing

my @p = is_pirate('Blargbeard', 'Alfonse', 'Capt. Hampton', 'Wesley');
is(@p,  2,   "Found two pirates.  ARRR!");

=end testing
END_ELEMENT
	is( $elements->[2], <<'END_ELEMENT', 'Third element matches expected' );
=for example begin

use LWP::Simple;
getprint "http://www.goats.com";

=for example end
END_ELEMENT
}