File: 10_legacy_extract.t

package info (click to toggle)
libtest-inline-perl 2.213-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 444 kB
  • ctags: 265
  • sloc: perl: 3,241; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,344 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

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

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use File::Slurp ();
use File::Spec::Functions ':ALL';
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
}