~ubuntu-branches/ubuntu/raring/parrot/raring-proposed

« back to all changes in this revision

Viewing changes to t/src/extend.t

  • Committer: Bazaar Package Importer
  • Author(s): Allison Randal
  • Date: 2011-07-30 18:45:03 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110730184503-34d4mprtfx6pt5h3
Tags: 3.6.0-1
* New upstream release
* debian/watch:
  - Modified regular expression to capture numbered directory name
    (patch from Dominique Dumont).
* debian/rules:
  - Split build-arch and build-indep, resolving lintian warning.
  - Update path to pbc_disassemble for manpage generation (patch
    from Dominique Dumont).
* debian/patches:
  - Added patch 02_fix_perl_interpreter_path.patch, resolving
    lintian warnings.
* debian/control:
  - Added DM-Upload-Allowed field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!perl
2
 
# Copyright (C) 2001-2010, Parrot Foundation.
 
2
# Copyright (C) 2001-2011, Parrot Foundation.
3
3
 
4
4
use strict;
5
5
use warnings;
14
14
 
15
15
plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile(qw/src parrot_config.o/);
16
16
 
17
 
plan tests => 18;
 
17
plan tests => 24;
18
18
 
19
19
=head1 NAME
20
20
 
30
30
 
31
31
=cut
32
32
 
 
33
sub linedirective
 
34
{
 
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";
 
39
}
 
40
 
 
41
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_PMC_null' );
 
42
#include <stdio.h>
 
43
#include "parrot/embed.h"
 
44
#include "parrot/extend.h"
 
45
 
 
46
int
 
47
main(int argc, const char *argv[])
 
48
{
 
49
    Parrot_Interp interp  = Parrot_new(NULL);
 
50
    Parrot_PMC    pmcnull;
 
51
 
 
52
    /* Interpreter set-up */
 
53
    if (interp) {
 
54
        pmcnull  = Parrot_PMC_null();
 
55
        Parrot_destroy(interp);
 
56
    }
 
57
    return 0;
 
58
}
 
59
CODE
 
60
OUTPUT
 
61
 
 
62
 
 
63
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_get_root_namespace/Parrot_(un)register_pmc' );
 
64
#include <stdio.h>
 
65
#include "parrot/embed.h"
 
66
#include "parrot/extend.h"
 
67
 
 
68
int
 
69
main(int argc, const char *argv[])
 
70
{
 
71
    Parrot_Interp interp  = Parrot_new(NULL);
 
72
    Parrot_PMC    ns;
 
73
 
 
74
    /* Interpreter set-up */
 
75
    if (interp) {
 
76
        ns  = Parrot_get_root_namespace(interp);
 
77
        Parrot_register_pmc(interp, ns);
 
78
        Parrot_unregister_pmc(interp, ns);
 
79
 
 
80
        Parrot_printf(interp,"%P\n", ns);
 
81
        Parrot_destroy(interp);
 
82
    }
 
83
    return 0;
 
84
}
 
85
CODE
 
86
 
 
87
OUTPUT
33
88
 
34
89
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_intreg' );
35
 
 
36
90
#include <stdio.h>
37
91
#include "parrot/embed.h"
38
92
#include "parrot/extend.h"
60
114
42
61
115
OUTPUT
62
116
 
 
117
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_fprintf');
 
118
#include <stdio.h>
 
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"
 
123
 
 
124
int
 
125
main(int argc, const char *argv[])
 
126
{
 
127
    Parrot_PMC pio;
 
128
    Parrot_Interp interp  = Parrot_new(NULL);
 
129
    pio = Parrot_io_STDOUT(interp);
 
130
 
 
131
    /* Interpreter set-up */
 
132
    if (interp) {
 
133
        Parrot_fprintf(interp, pio,"42\n");
 
134
    }
 
135
    return 0;
 
136
}
 
137
 
 
138
CODE
 
139
42
 
140
OUTPUT
 
141
 
 
142
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_printf/Parrot_eprintf with no interp');
 
143
#include <stdio.h>
 
144
#include "parrot/embed.h"
 
145
#include "parrot/extend.h"
 
146
 
 
147
int
 
148
main(int argc, const char *argv[])
 
149
{
 
150
    Parrot_printf(NULL,"42\n");
 
151
    Parrot_eprintf(NULL,"42\n");
 
152
    return 0;
 
153
}
 
154
 
 
155
CODE
 
156
42
 
157
42
 
158
OUTPUT
 
159
 
63
160
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_numreg' );
64
161
 
65
162
#include <stdio.h>
100
197
main(int argc, const char *argv[])
101
198
{
102
199
    Parrot_Interp interp = Parrot_new(NULL);
103
 
    Parrot_String output;
 
200
    Parrot_String output, output2;
104
201
 
105
202
    /* Interpreter set-up */
106
203
    if (interp) {
116
213
Test
117
214
OUTPUT
118
215
 
 
216
c_output_is( <<'CODE', <<'OUTPUT', 'Parrot_new_string/Parrot_(un)register_string' );
 
217
 
 
218
#include <stdio.h>
 
219
        #include "parrot/embed.h"
 
220
#include "parrot/extend.h"
 
221
 
 
222
int
 
223
main(int argc, const char *argv[])
 
224
{
 
225
    Parrot_Interp interp = Parrot_new(NULL);
 
226
    Parrot_String output, output2;
 
227
 
 
228
    /* Interpreter set-up */
 
229
    if (interp) {
 
230
        output = Parrot_new_string(interp, "Test_reg_unreg", 14, "iso-8859-1", 0);
 
231
 
 
232
        Parrot_register_string(interp, output);
 
233
        Parrot_unregister_string(interp, output);
 
234
 
 
235
        Parrot_eprintf(interp, "%S\n", output);
 
236
 
 
237
        Parrot_destroy(interp);
 
238
    }
 
239
    return 0;
 
240
}
 
241
 
 
242
CODE
 
243
Test_reg_unreg
 
244
OUTPUT
 
245
 
119
246
c_output_is( <<'CODE', <<'OUTPUT', 'set/get_strreg' );
120
247
 
121
248
#include <stdio.h>
178
305
101010
179
306
OUTPUT
180
307
 
 
308
c_output_is( linedirective(__LINE__) . <<'CODE', <<'OUTPUT', 'Parrot_free_cstring');
 
309
#include <stdio.h>
 
310
#include "parrot/parrot.h"
 
311
#include "parrot/embed.h"
 
312
#include "parrot/extend.h"
 
313
 
 
314
static void fail(const char *msg);
 
315
static Parrot_String createstring(Parrot_Interp interp, const char * value);
 
316
static Parrot_Interp new_interp();
 
317
 
 
318
static void fail(const char *msg)
 
319
{
 
320
    fprintf(stderr, "failed: %s\n", msg);
 
321
    exit(EXIT_FAILURE);
 
322
}
 
323
 
 
324
static Parrot_String createstring(Parrot_Interp interp, const char * value)
 
325
{
 
326
    return Parrot_new_string(interp, value, strlen(value), (const char*)NULL, 0);
 
327
}
 
328
 
 
329
static Parrot_Interp new_interp()
 
330
{
 
331
    Parrot_Interp interp = Parrot_new(NULL);
 
332
    if (!interp)
 
333
        fail("Cannot create parrot interpreter");
 
334
    return interp;
 
335
 
 
336
}
 
337
 
 
338
int main(int argc, const char **argv)
 
339
{
 
340
    Parrot_Interp interp;
 
341
    Parrot_String err, string;
 
342
    Parrot_PMC func_pmc;
 
343
    char *str;
 
344
 
 
345
    interp = new_interp();
 
346
 
 
347
    string = createstring(interp, "PIR");
 
348
    str    = Parrot_str_to_cstring(interp, string);
 
349
 
 
350
    Parrot_free_cstring(str);
 
351
 
 
352
    Parrot_destroy(interp);
 
353
    return 0;
 
354
}
 
355
CODE
 
356
OUTPUT
 
357
 
181
358
c_output_is( <<'CODE', <<'OUTPUT', 'PMC_set/get_integer_keyed_int' );
182
359
 
183
360
#include <stdio.h>