Index: t/op/sprintf2.t
===================================================================
--- t/op/sprintf2.t	(revision 41935)
+++ t/op/sprintf2.t	(working copy)
@@ -1,14 +1,7 @@
-#!perl
-# Copyright (C) 2001-2008, Parrot Foundation.
+#!parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
 # $Id$
 
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-
-use Test::More;
-use Parrot::Test;
-
 =head1 NAME
 
 t/op/sprintf2.t - Auxilliary tests for the sprintf opcode
@@ -19,41 +12,115 @@
 
 =head1 DESCRIPTION
 
-Executes sprintf tests that sprintf.t can't handle yet.
+Executes sprintf tests that were generated by tools/dev/sprintf2.pl
 
 =cut
 
-# [ 'format', [arguments], "expected output", 'description' ]
-my @tests = (
-  [ '<%*d>', [4,12], "<  12>\n", 'positive length' ],
-  [ '<%*d>', [-4,12], "<12  >\n", 'negative length' ],
-  [ '<%-*d>', [4,12], "<12  >\n", 'minus option, positive length' ],
-  [ '|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|', [65,65,65,65,65,65,3,65,-4,65],
-    "|A|A|A|A|A     |     A|  A|A   |\n", 'misc w/ minus option' ],
-  [ '<%*s>', [4,'"hi"'], "<  hi>\n", 'string, positive length' ],
-  [ '<%*s>', [-4,'"hi"'], "<hi  >\n", 'string, negative length' ],
-  [ '<%-*s>', [4,'"hi"'], "<hi  >\n", 'string, minus flag' ],
-  [ '<%*.*f>', [7,2,123.456], "< 123.46>\n", 'float length&prec' ],
-  [ '<%*.*f>', [-7,2,123.456], "<123.46 >\n", 'float -length&prec' ],
-);
 
-plan tests => scalar @tests;
+.sub main :main
+    .include 'test_more.pir'
 
-foreach my $test (@tests) {
-  my $code = ".sub main\n"
-           . "  \$P0 = new 'ResizablePMCArray'\n";
-  foreach my $arg (@{$$test[1]}) {
-    $code .= "  push \$P0,$arg\n";
-  }
-  $code .= "  \$S0 = sprintf '$$test[0]', \$P0\n"
-        .  "  say \$S0\n"
-        .  ".end\n";
-  pir_output_is( $code, $$test[2], $$test[3] );
-}
+    plan(9)
 
+    positive_length()
+    negative_length()
+    minus_option__positive_length()
+    misc_w__minus_option()
+    string__positive_length()
+    string__negative_length()
+    string__minus_flag()
+    float_length_and_prec()
+    float_neg_length_and_prec()
+
+.end
+
+.sub positive_length
+  $P0 = new 'ResizablePMCArray'
+  push $P0,4
+  push $P0,12
+  $S0 = sprintf '<%*d>', $P0
+  is( $S0, '<  12>', 'positive length' )
+.end
+
+.sub negative_length
+  $P0 = new 'ResizablePMCArray'
+  push $P0,-4
+  push $P0,12
+  $S0 = sprintf '<%*d>', $P0
+  is( $S0, '<12  >', 'negative length' )
+.end
+
+.sub minus_option__positive_length
+  $P0 = new 'ResizablePMCArray'
+  push $P0,4
+  push $P0,12
+  $S0 = sprintf '<%-*d>', $P0
+  is( $S0, '<12  >', 'minus option, positive length' )
+.end
+
+.sub misc_w__minus_option
+  $P0 = new 'ResizablePMCArray'
+  push $P0,65
+  push $P0,65
+  push $P0,65
+  push $P0,65
+  push $P0,65
+  push $P0,65
+  push $P0,3
+  push $P0,65
+  push $P0,-4
+  push $P0,65
+  $S0 = sprintf '|%c|%0c|%-1c|%1c|%-6c|%6c|%*c|%*c|', $P0
+  is( $S0, '|A|A|A|A|A     |     A|  A|A   |', 'misc w/ minus option' )
+.end
+
+.sub string__positive_length
+  $P0 = new 'ResizablePMCArray'
+  push $P0,4
+  push $P0,"hi"
+  $S0 = sprintf '<%*s>', $P0
+  is( $S0, '<  hi>', 'string, positive length' )
+.end
+
+.sub string__negative_length
+  $P0 = new 'ResizablePMCArray'
+  push $P0,-4
+  push $P0,"hi"
+  $S0 = sprintf '<%*s>', $P0
+  is( $S0, '<hi  >', 'string, negative length' )
+.end
+
+.sub string__minus_flag
+  $P0 = new 'ResizablePMCArray'
+  push $P0,4
+  push $P0,"hi"
+  $S0 = sprintf '<%-*s>', $P0
+  is( $S0, '<hi  >', 'string, minus flag' )
+.end
+
+.sub float_length_and_prec
+  $P0 = new 'ResizablePMCArray'
+  push $P0,7
+  push $P0,2
+  push $P0,123.456
+  $S0 = sprintf '<%*.*f>', $P0
+  is( $S0, '< 123.46>', 'float length&prec' )
+.end
+
+.sub float_neg_length_and_prec
+  $P0 = new 'ResizablePMCArray'
+  push $P0,-7
+  push $P0,2
+  push $P0,123.456
+  $S0 = sprintf '<%*.*f>', $P0
+  is( $S0, '<123.46 >', 'float -length&prec' )
+.end
+
+
+
 # Local Variables:
-#   mode: cperl
+#   mode: pir
 #   cperl-indent-level: 4
 #   fill-column: 100
 # End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:
