Author: bernhard
Date: Wed Nov 2 13:36:44 2005
New Revision: 9728
Added:
trunk/examples/pir/substr.pir
- copied, changed from r9726, trunk/examples/assembly/substr.pasm
Removed:
trunk/examples/assembly/substr.pasm
Modified:
trunk/MANIFEST
trunk/t/examples/pir.t
Log:
Convert the example 'assembly/substr.pasm' to PIR
and add it as a test case in pir.t
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Wed Nov 2 13:36:44 2005
@@ -457,7 +457,6 @@ examples/assembly/pmcmops.pasm
examples/assembly/queens.pasm [main]doc
examples/assembly/queens_r.imc [main]doc
examples/assembly/stack.pasm [main]doc
-examples/assembly/substr.pasm [main]doc
examples/assembly/thr-primes.imc [main]doc
examples/assembly/trace.pasm [main]doc
examples/assembly/uniq.pasm [main]doc
@@ -605,6 +604,7 @@ examples/pir/life.pir
examples/pir/local_label.pir [main]doc
examples/pir/mandel.pir [main]doc
examples/pir/readline.pir [main]doc
+examples/pir/substr.pir [main]doc
examples/pir/sudoku.pir [main]doc
examples/pni/PQt.C [main]doc
examples/pni/QtHelloWorld.pasm [main]doc
Copied: trunk/examples/pir/substr.pir (from r9726,
trunk/examples/assembly/substr.pasm)
==============================================================================
--- trunk/examples/assembly/substr.pasm (original)
+++ trunk/examples/pir/substr.pir Wed Nov 2 13:36:44 2005
@@ -3,34 +3,35 @@
=head1 NAME
-examples/assembly/substr.pasm - Substring
+examples/pir/substr.pir - playing with substr
=head1 SYNOPSIS
- % ./parrot examples/assembly/substr.pasm
+ % ./parrot examples/pir/substr.pir
=head1 DESCRIPTION
-A C<substr> version of "Hello World".
+A excuberating C<substr> version of "Hello World".
=cut
- set I2, 1
- set I1, 0
- set S1, "Hello World"
- set I3, 0
- set I4, 0
- length I5, S1
-WAX: substr S2, S1, I3, I4
+.sub "example" :main
+ I2 = 1
+ I1 = 0
+ S1 = "Hello World"
+ I3 = 0
+ I4 = 0
+ I5 = length S1
+WAX: S2 = substr S1, I3, I4
print S2
print "\n"
- add I4, I4, I2
- eq I4, I5, WANE
+ I4 = I4 + I2
+ if I4 == I5 goto WANE
branch WAX
-WANE: length I1, S1
+WANE: I1 = length S1
print S1
print "\n"
chopn S1, 1
- eq I1, I3, DONE
- branch WANE
-DONE: end
+ unless I1 == I3 goto WANE
+DONE:
+.end
Modified: trunk/t/examples/pir.t
==============================================================================
--- trunk/t/examples/pir.t (original)
+++ trunk/t/examples/pir.t Wed Nov 2 13:36:44 2005
@@ -32,7 +32,7 @@ Bernhard Schmalhofer - <Bernhard.Schmalh
=cut
use strict;
-use Parrot::Test tests => 9;
+use Parrot::Test tests => 10;
use Test::More;
use Parrot::Config;
@@ -131,6 +131,32 @@ END_EXPECTED
...........::::::::::::::::::::::::::::::::::::::::::::::::::::::..........
END_EXPECTED
+ 'substr.pir' => << 'END_EXPECTED',
+
+H
+He
+Hel
+Hell
+Hello
+Hello
+Hello W
+Hello Wo
+Hello Wor
+Hello Worl
+Hello World
+Hello Worl
+Hello Wor
+Hello Wo
+Hello W
+Hello
+Hello
+Hell
+Hel
+He
+H
+
+END_EXPECTED
+
'sudoku.pir' => << 'END_EXPECTED',
+---------+---------+---------+
| 1 . . | . . . | . . . |