Index: lib/Parrot/Test/PGE.pm
===================================================================
--- lib/Parrot/Test/PGE.pm	(revision 13228)
+++ lib/Parrot/Test/PGE.pm	(working copy)
@@ -108,6 +108,23 @@
     goto &Parrot::Test::pir_output_like;
 }
 
+=item C<p6rule_throws($pattern, $expected, $description, @todo)>
+
+Compiles the Perl 6 pattern, catching any thrown exceptions.  The test
+passes if the pattern throws an exception and the exception message
+matches the C<$expected> parameter.  Note that C<$expected> is a
+I<Perl 5> pattern.
+
+=cut
+
+sub p6rule_throws {
+    my ($pattern) = (shift);
+
+    unshift @_ => Parrot::Test::PGE::_generate_pir_catch_for($pattern);
+
+    goto &Parrot::Test::pir_output_like;
+}
+
 =item C<pgeglob_is($target, $pattern, $description, @todo)>
 
 Runs the target string against the Perl 6 pattern, passing the test
@@ -217,6 +234,39 @@
         .end\n);
 }
 
+sub _generate_pir_catch_for {
+    my($pattern) = @_;
+    $pattern = _parrot_stringify($pattern);
+    return qq(
+        .sub _PGE_Test
+            .local pmc p6rule_compile
+            load_bytecode "PGE.pbc"
+            load_bytecode "PGE/Dumper.pir"
+            load_bytecode "PGE/Text.pir"
+            load_bytecode "PGE/Util.pir"
+            p6rule_compile = compreg "PGE::P6Regex"
+
+            .local string pattern
+            .local pmc rulesub
+            pattern = "$pattern"
+            push_eh handler
+            rulesub = p6rule_compile(pattern)
+            if_null rulesub, compile_fail
+          compile_success:
+            print "OK"
+            goto end
+          compile_fail:
+            print "unknown compile error"
+            goto end
+          handler:
+            .local pmc exception
+            .local string message
+            .get_results (exception, message)
+            print message
+          end:
+        .end\n);
+}
+
 sub _generate_subrule_pir {
     my($target, $pattern) = @_;
     $target = _parrot_stringify($target);
Index: t/compilers/pge/p6regex/syntax_errors.t
===================================================================
--- t/compilers/pge/p6regex/syntax_errors.t	(revision 0)
+++ t/compilers/pge/p6regex/syntax_errors.t	(revision 0)
@@ -0,0 +1,44 @@
+#!perl
+# Copyright (C) 2001-2005, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( t . lib ../lib ../../lib ../../../lib );
+use Test::More;
+use Parrot::Test;
+use Parrot::Test::PGE;
+
+
+=head1 NAME
+
+t/compilers/pge/p6regex/syntax_errors.t - How PGE catches syntax errors
+
+=head1 DESCRIPTION
+
+Tries to compile a bunch of know broken P6 regexps, testing the
+exceptions that get thrown.
+
+=head1 SYNOPSIS
+
+	% prove t/compilers/pge/p6regex/syntax_errors.t
+
+=cut
+
+p6rule_throws('{{ ',
+    qr/Missing closing braces for closure/, 'unterminated closure');
+
+p6rule_throws('\\1',
+    qr/\\1 and \\012 illegal/, 'back references');
+
+p6rule_throws('\x[',
+    qr/Missing close bracket for \\x/, 'unterminated \\x[..]');
+
+p6rule_throws('\X[',
+    qr/Missing close bracket for \\x/, 'unterminated \\X[..]');
+
+p6rule_throws(' :i a',
+    qr/Too late for modifier/, 'whitespace before modifier', todo => 'not implemented');
+
+# remember to change the number of tests :-)
+BEGIN { plan tests => 5; }
