[svn:parrot] r43193 - trunk/t/compilers/tge

bubaflub at svn.parrot.org bubaflub at svn.parrot.org
Tue Dec 22 05:28:31 UTC 2009


Author: bubaflub
Date: Tue Dec 22 05:28:31 2009
New Revision: 43193
URL: https://trac.parrot.org/parrot/changeset/43193

Log:
convert t/compilers/tge/parser.t to PIR

Modified:
   trunk/t/compilers/tge/parser.t

Modified: trunk/t/compilers/tge/parser.t
==============================================================================
--- trunk/t/compilers/tge/parser.t	Tue Dec 22 05:26:12 2009	(r43192)
+++ trunk/t/compilers/tge/parser.t	Tue Dec 22 05:28:31 2009	(r43193)
@@ -1,13 +1,7 @@
-#!perl
+#!parrot
 # Copyright (C) 2005-2009, Parrot Foundation.
 # $Id$
 
-use strict;
-use warnings;
-use lib qw(t . lib ../lib ../../lib ../../../lib);
-use Test::More;
-use Parrot::Test tests => 2;
-
 =head1 NAME
 
 t/parser.t
@@ -22,11 +16,16 @@
 
 =cut
 
-pir_output_is( <<'CODE', <<'OUT', "parse a basic attribute grammar" );
-
-.sub _main :main
+.sub main :main
     load_bytecode 'TGE.pbc'
+    .include 'test_more.pir'
+    plan(2)
 
+    test_parse_a_basic_attribute_grammar()
+    test_parse_failure()
+.end
+
+.sub test_parse_a_basic_attribute_grammar
     .local string source
     source = <<'GRAMMAR'
     transform min (Leaf) {
@@ -45,33 +44,23 @@
     .local pmc match
     .local pmc start_rule
     start_rule = get_global ['TGE';'Parser'], "start"
-    print "loaded start rule\n"
     match = start_rule(source)
-    print "matched start rule\n"
 
     # Verify the match
     unless match goto match_fail           # if match fails stop
-    print "parse succeeded\n"
-    goto cleanup
+    ok(1, "parse a basic attribute grammar" )
+    .return()
 
   match_fail:
-    print "parse failed\n"
+    ok(0, "parse a basic attribute grammar" )
 
-  cleanup:
-    end
 .end
 
-CODE
-loaded start rule
-matched start rule
-parse succeeded
-OUT
-
-pir_error_output_like( <<'CODE', qr/Syntax error at line 4, near "transform "/, "parse failure" );
-
-.sub _main :main
+.sub test_parse_failure
+    $S0 = "Syntax error at line 4, near \"transform \"\n"
+    throws_substring(<<'CODE', $S0, 'parse failure')
+.sub main 
     load_bytecode 'TGE.pbc'
-
     .local string source
     source = <<'GRAMMAR'
     transform min (Leaf) {
@@ -86,12 +75,12 @@
     start_rule = get_global ['TGE';'Parser'], "start"
     match = start_rule(source, 'grammar'=>'TGE::Parser') # should throw.
 .end
-
 CODE
+.end
 
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4
 #   fill-column: 100
 # End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 filetype=pir:


More information about the parrot-commits mailing list