[svn:parrot] r46218 - trunk/t/src

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sun May 2 17:40:02 UTC 2010


Author: NotFound
Date: Sun May  2 17:40:01 2010
New Revision: 46218
URL: https://trac.parrot.org/parrot/changeset/46218

Log:
better error reporting in embedding tests

Modified:
   trunk/t/src/embed.t

Modified: trunk/t/src/embed.t
==============================================================================
--- trunk/t/src/embed.t	Sun May  2 14:43:43 2010	(r46217)
+++ trunk/t/src/embed.t	Sun May  2 17:40:01 2010	(r46218)
@@ -24,7 +24,15 @@
 
 =cut
 
-c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_compile_string populates the error string when an opcode is given improper arguments');
+sub linedirective
+{
+    # Provide a #line directive for the C code in the heredoc
+    # starting immediately after where this sub is called.
+    my $linenum = shift() + 1;
+    return "#line " . $linenum . ' "' . __FILE__ . '"' . "\n";
+}
+
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', 'Parrot_compile_string populates the error string when an opcode is given improper arguments');
 #include <stdio.h>
 #include <stdlib.h>
 #include "parrot/embed.h"
@@ -61,7 +69,7 @@
 The opcode 'copy' (copy<0>) was not found. Check the type and number of the arguments
 OUTPUT
 
-c_output_is( <<'CODE', <<'OUTPUT', "Minimal embed, using just the embed.h header" );
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Minimal embed, using just the embed.h header" );
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -91,7 +99,7 @@
 Done
 OUTPUT
 
-c_output_is( <<'CODE', <<'OUTPUT', "Hello world from main" );
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Hello world from main" );
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -140,7 +148,7 @@
 Hello, pir
 OUTPUT
 
-c_output_is( <<'CODE', <<'OUTPUT', "Hello world from a sub" );
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Hello world from a sub" );
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -206,7 +214,7 @@
 Hello, sub
 OUTPUT
 
-c_output_is( <<'CODE', <<'OUTPUT', "External sub" );
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "External sub" );
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -262,7 +270,7 @@
 Hello from C
 OUTPUT
 
-c_output_is( <<'CODE', <<'OUTPUT', "Insert external sub in namespace" );
+c_output_is(linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Insert external sub in namespace" );
 
 #include <stdio.h>
 #include <stdlib.h>


More information about the parrot-commits mailing list