[svn:parrot] r37613 - in trunk: docs/book t/examples
coke at svn.parrot.org
coke at svn.parrot.org
Fri Mar 20 19:35:03 UTC 2009
Author: coke
Date: Fri Mar 20 19:35:01 2009
New Revision: 37613
URL: https://trac.parrot.org/parrot/changeset/37613
Log:
[t/docs] Verify PASM snippets too. Add a single PASM target
Modified:
trunk/docs/book/ch05_pasm.pod
trunk/t/examples/pod.t
Modified: trunk/docs/book/ch05_pasm.pod
==============================================================================
--- trunk/docs/book/ch05_pasm.pod Fri Mar 20 18:27:52 2009 (r37612)
+++ trunk/docs/book/ch05_pasm.pod Fri Mar 20 19:35:01 2009 (r37613)
@@ -53,12 +53,16 @@
value. The arguments can be either registers or constants, although the
destination argument cannot be constant.
+=begin PASM
+
LABEL:
print "The answer is: "
print 42
print "\n"
end # halt the interpreter
+=end PASM
+
X<PASM (Parrot assembly language);labels>
A label names a line of code so other instructions can refer to it.
Label names consist of letters, numbers, and underscores, exactly the
Modified: trunk/t/examples/pod.t
==============================================================================
--- trunk/t/examples/pod.t Fri Mar 20 18:27:52 2009 (r37612)
+++ trunk/t/examples/pod.t Fri Mar 20 19:35:01 2009 (r37613)
@@ -10,18 +10,9 @@
use Test::More qw(no_plan);
use Parrot::Test;
+use Parrot::Test::Pod;
use Parrot::Config qw(%PConfig);
-
-use lib qw( lib );
-BEGIN {
- eval 'use Parrot::Test::Pod';
- if ($@) {
- plan skip_all => 'Prerequisites for Parrot::Test::Pod not satisfied';
- exit;
- }
-}
-
my @files = @ARGV;
if (!@files) {
@@ -30,26 +21,28 @@
}
foreach my $file ( @files ) {
- foreach my $contents (get_samples($file)) {
- compile_pir_ok($contents, $file);
+ foreach my $snippet (get_samples($file)) {
+ compile_ok($snippet);
}
}
#################### SUBROUTINES ####################
-sub compile_pir_ok {
- my $code = shift;
- my $file = shift;
+sub compile_ok {
+ my $snippet = shift;
- my ($fh,$tempfile) = tempfile(SUFFIX => '.pir', UNLINK => 1);
- print {$fh} $code;
+ my ($fh,$tempfile) = tempfile(
+ SUFFIX => '.' . lc $snippet->{type},
+ UNLINK => 1
+ );
+ print {$fh} $snippet->{code};
close $fh;
my $cmd = File::Spec->curdir() . $PConfig{slash} .
$PConfig{test_prog} . " -o " . File::Spec->devnull() . " " .
$tempfile;
- my $description = "$file\n$code";
+ my $description = $snippet->{file} . "\n" . $snippet->{code};
is(system($cmd), 0 , $description);
}
@@ -64,7 +57,15 @@
$contents = <$fh>;
}
- return $contents =~ (/^=begin PIR$(.*?)^=end PIR$/smg);
+ my @snippets;
+ while ($contents =~ /^=begin (PIR|PASM)(.*?)^=end \1$/smg) {
+ push @snippets, {
+ file => $file,
+ type => $1,
+ code => $2,
+ };
+ }
+ return @snippets;
}
=head1 NAME
More information about the parrot-commits
mailing list