[svn:parrot] r37599 - in trunk: . docs t/examples
coke at svn.parrot.org
coke at svn.parrot.org
Thu Mar 19 20:33:16 UTC 2009
Author: coke
Date: Thu Mar 19 20:33:13 2009
New Revision: 37599
URL: https://trac.parrot.org/parrot/changeset/37599
Log:
First pass at RT# 41765 - test examples in pod.
Added:
trunk/t/examples/pod.t (contents, props changed)
Modified:
trunk/MANIFEST
trunk/docs/compiler_faq.pod
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Thu Mar 19 19:46:18 2009 (r37598)
+++ trunk/MANIFEST Thu Mar 19 20:33:13 2009 (r37599)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Mar 18 19:53:30 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Mar 19 20:27:45 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -1678,6 +1678,7 @@
t/examples/pasm.t [test]
t/examples/past.t [test]
t/examples/pir.t [test]
+t/examples/pod.t [test]
t/examples/shootout.t [test]
t/examples/streams.t [test]
t/examples/subs.t [test]
Modified: trunk/docs/compiler_faq.pod
==============================================================================
--- trunk/docs/compiler_faq.pod Thu Mar 19 19:46:18 2009 (r37598)
+++ trunk/docs/compiler_faq.pod Thu Mar 19 20:33:13 2009 (r37599)
@@ -108,23 +108,29 @@
Any subroutine that contains a C<.yield> directive is automatically
created as a Coroutine PMC:
+=begin PIR
.sub my_coro # automagically a Coroutine PMC
- ...
+ .param pmc result
+ #...
.yield (result)
- ...
+ #...
.end
-
+=end PIR
=head2 How do I generate a tail call in PIR?
+=begin PIR
.sub foo
- # do something
+ # ...
.tailcall bar(42) # tail call sub bar
.end
.sub bar
- # ...
+ .param int answer
+ inc answer
+ .return(answer)
.end
+=end PIR
The sub C<bar> will return to the caller of C<foo>. (Warning! This fails
in some cases. XXX Find the RT ticket and reference it here.)
Added: trunk/t/examples/pod.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/examples/pod.t Thu Mar 19 20:33:13 2009 (r37599)
@@ -0,0 +1,74 @@
+#! perl
+# Copyright (C) 2009, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+
+use Test::More qw(no_plan);
+use Parrot::Test;
+
+use lib qw( lib );
+BEGIN {
+ eval 'use Parrot::Test::Pod';
+ if ($@) {
+ plan skip_all => 'Prerequisites for Parrot::Test::Pod not satisfied';
+ exit;
+ }
+}
+
+my $self = Parrot::Test::Pod->new( {
+ argv => [ @ARGV ],
+} );
+
+my $need_testing_ref = $self->identify_files_for_POD_testing( {
+ second_analysis => 'oreilly_summary_malformed',
+} );
+
+foreach my $file ( @{ $need_testing_ref } ) {
+ foreach my $contents (get_samples($file)) {
+ pir_output_like($contents,qr//,"$file\n$contents");
+ }
+}
+
+#################### SUBROUTINES ####################
+
+sub get_samples {
+ my $file = shift;
+
+ my $contents;
+ {
+ local undef $/;
+ open my $fh, '<', $file;
+ $contents = <$fh>;
+ }
+
+ return $contents =~ (/^=begin PIR$(.*?)^=end PIR$/smg);
+}
+
+=head1 NAME
+
+t/examples/pod.t - Compile examples found in POD
+
+=head1 SYNOPSIS
+
+ # test all files
+ % prove t/examples/pod.t
+
+ # test specific files
+ % perl t/examples/pod.t docs/compiler_faq.pod
+
+=head1 DESCRIPTION
+
+Tests the syntax for any embedded PIR for all files listed in F<MANIFEST> and
+F<MANIFEST.generated>. Any invalid examples are reported in the test output.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
More information about the parrot-commits
mailing list