File: pod_test.pl

package info (click to toggle)
libinline-java-perl 0.58~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 964 kB
  • ctags: 684
  • sloc: perl: 4,717; java: 2,844; makefile: 35
file content (82 lines) | stat: -rw-r--r-- 1,431 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
use strict ;

use blib ;
use Getopt::Long ;

BEGIN {
	mkdir('./_Inline_test', 0777) unless -e './_Inline_test';
}

use Inline Config => 
           DIRECTORY => './_Inline_test';

require Inline::Java ;
								  

my %opts = () ;
GetOptions (\%opts,
	"d",    	# debug
	"s=i",    	# skip to
	"o=i",    	# only
) ;


my $skip_to = $opts{s} || 0 ;
my $cnt = -1 ;

foreach my $podf ('Java.pod', 'Java/Callback.pod', 'Java/PerlNatives/PerlNatives.pod'){
	open(POD, "<$podf") or 
		die("Can't open $podf file") ;
	my $pod = join("", <POD>) ;
	close(POD) ;

	my $del = "\n=for comment\n" ;

	my @code_blocks = ($pod =~ m/$del(.*?)$del/gs) ;

	foreach my $code (@code_blocks){
		$cnt++ ;

		if ((defined($opts{o}))&&($opts{o} != $cnt)){
			print "skipped\n" ;
			next ;
		}

		if ($cnt < $skip_to){
			print "skipped\n" ;
			next ;
		}

		print "-> Code Block $cnt ($podf)\n" ;

		$code =~ s/(\n)(   )/$1/gs ;  
		$code =~ s/(((END(_OF_JAVA_CODE)?)|STUDY)\')/$1, NAME => "main::main" / ;  
		$code =~ s/(STUDY\')/$1, AUTOSTUDY => 1 / ;  

		if (($code =~ /SHARED_JVM/)&&($opts{o} != $cnt)){
			print "skipped\n" ;
			next ;
		}

		$code =~ s/print\((.*) \. \"\\n\"\) ; # prints (.*)/{
			"print (((($1) eq ('$2')) ? \"ok\" : \"not ok ('$1' ne '$2')\") . \"\\n\") ;" ;
		}/ge ;

		my $Entry = '$Entry' ;
		debug($code) ;

		eval $code ;
		if ($@){
			die $@ ;
		}
	}
}


sub debug {
	my $msg = shift ;
	if ($opts{d}){
		print $msg ;
	}
}