35
# Provide a #line directive for the C code in the heredoc
36
# starting immediately after where this sub is called.
37
my $linenum = shift() + 1;
38
return "#line " . $linenum . ' "' . __FILE__ . '"' . "\n";
41
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_PMC_null' );
43
#include "parrot/embed.h"
44
#include "parrot/extend.h"
47
main(int argc, const char *argv[])
49
Parrot_Interp interp = Parrot_new(NULL);
52
/* Interpreter set-up */
54
pmcnull = Parrot_PMC_null();
55
Parrot_destroy(interp);
63
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_get_root_namespace/Parrot_(un)register_pmc' );
65
#include "parrot/embed.h"
66
#include "parrot/extend.h"
69
main(int argc, const char *argv[])
71
Parrot_Interp interp = Parrot_new(NULL);
74
/* Interpreter set-up */
76
ns = Parrot_get_root_namespace(interp);
77
Parrot_register_pmc(interp, ns);
78
Parrot_unregister_pmc(interp, ns);
80
Parrot_printf(interp,"%P\n", ns);
81
Parrot_destroy(interp);
34
89
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_intreg' );
37
91
#include "parrot/embed.h"
38
92
#include "parrot/extend.h"
117
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_fprintf');
119
// This is to get Parrot_io_STDOUT, is there a better way?
120
#include "parrot/parrot.h"
121
#include "parrot/embed.h"
122
#include "parrot/extend.h"
125
main(int argc, const char *argv[])
128
Parrot_Interp interp = Parrot_new(NULL);
129
pio = Parrot_io_STDOUT(interp);
131
/* Interpreter set-up */
133
Parrot_fprintf(interp, pio,"42\n");
142
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_printf/Parrot_eprintf with no interp');
144
#include "parrot/embed.h"
145
#include "parrot/extend.h"
148
main(int argc, const char *argv[])
150
Parrot_printf(NULL,"42\n");
151
Parrot_eprintf(NULL,"42\n");
63
160
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_numreg' );
65
162
#include <stdio.h>
216
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_new_string/Parrot_(un)register_string' );
219
#include "parrot/embed.h"
220
#include "parrot/extend.h"
223
main(int argc, const char *argv[])
225
Parrot_Interp interp = Parrot_new(NULL);
226
Parrot_String output, output2;
228
/* Interpreter set-up */
230
output = Parrot_new_string(interp, "Test_reg_unreg", 14, "iso-8859-1", 0);
232
Parrot_register_string(interp, output);
233
Parrot_unregister_string(interp, output);
235
Parrot_eprintf(interp, "%S\n", output);
237
Parrot_destroy(interp);
119
246
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_strreg' );
121
248
#include <stdio.h>
308
c_output_is( linedirective(__LINE__) . <<'CODE', <<'OUTPUT', 'Parrot_free_cstring');
310
#include "parrot/parrot.h"
311
#include "parrot/embed.h"
312
#include "parrot/extend.h"
314
static void fail(const char *msg);
315
static Parrot_String createstring(Parrot_Interp interp, const char * value);
316
static Parrot_Interp new_interp();
318
static void fail(const char *msg)
320
fprintf(stderr, "failed: %s\n", msg);
324
static Parrot_String createstring(Parrot_Interp interp, const char * value)
326
return Parrot_new_string(interp, value, strlen(value), (const char*)NULL, 0);
329
static Parrot_Interp new_interp()
331
Parrot_Interp interp = Parrot_new(NULL);
333
fail("Cannot create parrot interpreter");
338
int main(int argc, const char **argv)
340
Parrot_Interp interp;
341
Parrot_String err, string;
345
interp = new_interp();
347
string = createstring(interp, "PIR");
348
str = Parrot_str_to_cstring(interp, string);
350
Parrot_free_cstring(str);
352
Parrot_destroy(interp);
181
358
c_output_is( <<'CODE', <<'OUTPUT', 'PMC_set/get_integer_keyed_int' );
183
360
#include <stdio.h>