Author: bernhard
Date: Wed Oct 26 11:17:12 2005
New Revision: 9576

Added:
   trunk/examples/pir/readline.pir
      - copied, changed from r9573, trunk/examples/assembly/slurp.pasm
Removed:
   trunk/examples/assembly/slurp.pasm
Modified:
   trunk/MANIFEST
   trunk/examples/pasm/lexical.pasm
   trunk/t/examples/pir.t
Log:
Migrate examples/assembly/slurp.pasm to PIR
and call it examples/pir/readline.pir.


Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Wed Oct 26 11:17:12 2005
@@ -456,7 +456,6 @@ examples/assembly/ncurses_life.imc      
 examples/assembly/pmcmops.pasm                    [main]doc
 examples/assembly/queens.pasm                     [main]doc
 examples/assembly/queens_r.imc                    [main]doc
-examples/assembly/slurp.pasm                      [main]doc
 examples/assembly/small.xml                       [main]doc
 examples/assembly/stack.pasm                      [main]doc
 examples/assembly/substr.pasm                     [main]doc
@@ -600,6 +599,7 @@ examples/pir/io.pir                     
 examples/pir/life.pir                             [main]doc
 examples/pir/local_label.pir                      [main]doc
 examples/pir/mandel.pir                           [main]doc
+examples/pir/readline.pir                         [main]doc
 examples/pir/sudoku.pir                           [main]doc
 examples/pni/PQt.C                                [main]doc
 examples/pni/QtHelloWorld.pasm                    [main]doc

Modified: trunk/examples/pasm/lexical.pasm
==============================================================================
--- trunk/examples/pasm/lexical.pasm    (original)
+++ trunk/examples/pasm/lexical.pasm    Wed Oct 26 11:17:12 2005
@@ -3,11 +3,11 @@
 
 =head1 NAME
 
-examples/assembly/lexical.pasm - Lexical scope
+examples/pasm/lexical.pasm - Lexical scope
 
 =head1 SYNOPSIS
 
-    % ./parrot examples/assembly/lexical.pasm
+    % ./parrot examples/pasm/lexical.pasm
 
 =head1 DESCRIPTION
 

Copied: trunk/examples/pir/readline.pir (from r9573, 
trunk/examples/assembly/slurp.pasm)
==============================================================================
--- trunk/examples/assembly/slurp.pasm  (original)
+++ trunk/examples/pir/readline.pir     Wed Oct 26 11:17:12 2005
@@ -1,31 +1,37 @@
+# This line will be printed by ./parrot examples/pir/readline.t
+
 # Copyright (C) 2001-2003 The Perl Foundation.  All rights reserved.
 # $Id$
 
 =head1 NAME
 
-examples/assembly/slurp.pasm - Read,concatenate and print
+examples/pir/readline.pir - Read,concatenate and print
 
 =head1 SYNOPSIS
 
-    % ./parrot examples/assembly/slurp.pasm
+    % ./parrot examples/pir/readline.pir
 
 =head1 DESCRIPTION
 
 Reads from C<stdin> and concatenates to a buffer. When an empty line is
-received the buffer is printed.
+received the buffer is printed and the program is terminated.
 
 =cut
 
-       getstdin P0
-       set S1, ""
+.sub "example" :main
+        .local pmc stdin
+        .local string buffer, line
+
+       stdin = getstdin
+       buffer = ""
+
 AGAIN:
-       readline S0, P0
-       length I1, S0
-       le I1, 1, MAINLOOP
-       concat S1, S0
+       line = readline stdin
+       I1 = length line
+       if I1 <= 1 goto MAINLOOP
+       concat buffer, line
        branch AGAIN
 
 MAINLOOP:
-       print S1
-       end
-
+       print buffer
+.end

Modified: trunk/t/examples/pir.t
==============================================================================
--- trunk/t/examples/pir.t      (original)
+++ trunk/t/examples/pir.t      Wed Oct 26 11:17:12 2005
@@ -32,7 +32,7 @@ Bernhard Schmalhofer - <Bernhard.Schmalh
 =cut
 
 use strict;
-use Parrot::Test tests => 8;
+use Parrot::Test tests => 9;
 use Test::More;
 use Parrot::Config;
 
@@ -192,3 +192,13 @@ while ( my ( $example, $expected ) = eac
     like( $sum, qr/4 generations in/, 'life ran for 4 generations' );
 }
 
+# readline.pir expects something on standard input 
+{
+    my $readline_fn = "examples$PConfig{slash}pir$PConfig{slash}readline.pir";
+    my $expected = << 'END_EXPECTED';
+# This line will be printed by ./parrot examples/pir/readline.t
+END_EXPECTED
+    my $out = `$PARROT $readline_fn < $readline_fn`;
+    is( $out, $expected,, 'print untill first empty line' );
+}
+

Reply via email to