[svn:parrot] r46208 - trunk/t/src
dukeleto at svn.parrot.org
dukeleto at svn.parrot.org
Sat May 1 20:25:04 UTC 2010
Author: dukeleto
Date: Sat May 1 20:25:04 2010
New Revision: 46208
URL: https://trac.parrot.org/parrot/changeset/46208
Log:
[t] Add a test for Parrot_compile_string populating the error string
Modified:
trunk/t/src/embed.t
Modified: trunk/t/src/embed.t
==============================================================================
--- trunk/t/src/embed.t Sat May 1 20:03:09 2010 (r46207)
+++ trunk/t/src/embed.t Sat May 1 20:25:04 2010 (r46208)
@@ -8,7 +8,7 @@
use Test::More;
use Parrot::Test;
-plan tests => 6;
+plan tests => 7;
=head1 NAME
@@ -24,6 +24,43 @@
=cut
+c_output_is( <<'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"
+
+void fail(const char *msg);
+
+void fail(const char *msg)
+{
+ fprintf(stderr, "failed: %s\n", msg);
+ exit(EXIT_FAILURE);
+}
+
+
+int main(int argc, const char **argv)
+{
+ Parrot_Interp interp;
+ Parrot_String err, lang;
+ Parrot_PMC func_pmc;
+ char *str;
+
+ interp = Parrot_new(NULL);
+ if (! interp)
+ fail("Cannot create parrot interpreter");
+ lang = Parrot_str_new_constant(interp, "PIR", 3);
+
+ func_pmc = Parrot_compile_string(interp, lang, ".sub foo\n copy\n.end", &err);
+ str = Parrot_str_to_cstring(interp, err);
+ puts(str);
+ Parrot_str_free_cstring(interp, str);
+ Parrot_destroy(interp);
+ return 0;
+}
+CODE
+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" );
#include <stdio.h>
More information about the parrot-commits
mailing list