Leopold Toetsch <[EMAIL PROTECTED]> writes:
> All these (non-trivial) source tests, that create some resources should
> use the scheme of t/src/basic_3.
I've rewritten list.t and hash.t to use this scheme, generalizing the
layout a bit in the process. I'm not sure about the reasoning for one
of the interpreter setups in the old hash.t (marked with XXX), and
whether it's needed now - seems to work fine without, but that may not
be the point.
I'll do the rest of them later, but I really should work on other
stuff now :-)
Cheers,
--
Lars Balker Rasmussen Consult::Perl
Index: t/src/exit.t
===================================================================
RCS file: /cvs/public/parrot/t/src/exit.t,v
retrieving revision 1.5
diff -u -a -r1.5 exit.t
--- t/src/exit.t 13 Dec 2003 15:01:19 -0000 1.5
+++ t/src/exit.t 5 Jan 2004 18:16:30 -0000
@@ -10,6 +10,7 @@
printf("pre-exit\n");
Parrot_exit(0);
printf("post-exit\n");
+ return 0;
}
CODE
pre-exit
Index: t/src/hash.t
===================================================================
RCS file: /cvs/public/parrot/t/src/hash.t,v
retrieving revision 1.10
diff -u -a -r1.10 hash.t
--- t/src/hash.t 13 Dec 2003 15:01:19 -0000 1.10
+++ t/src/hash.t 5 Jan 2004 18:16:30 -0000
@@ -3,63 +3,79 @@
use Parrot::Test tests => 10;
-c_output_is(<<'CODE', <<'OUTPUT', "new_hash");
+my $main = <<'CODE';
+#include <parrot/parrot.h>
+#include <parrot/embed.h>
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+int exit_value = 0;
+
+int main(int argc, char* argv[])
+{
+ Parrot_Interp interpreter = Parrot_new(NULL);
+ if (!interpreter) {
+ return 1;
+ }
+ Parrot_init(interpreter);
+
+ Parrot_run_native(interpreter, the_test);
+
+ Parrot_exit(exit_value);
+ return exit_value;
+}
+
+CODE
+
+c_output_is($main . <<'CODE', <<'OUTPUT', "new_hash");
+
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
- printf("ok\n");
+ PIO_eprintf(interpreter, "ok\n");
- return 0;
+ return NULL;
}
CODE
ok
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_put");
-
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_put");
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -67,39 +83,35 @@
value.val.int_val = 42;
hash_put(interpreter, hash, key, &value);
- printf("ok\n");
+ PIO_eprintf(interpreter, "ok\n");
- return 0;
+ return NULL;
}
CODE
ok
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_get");
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_get");
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
-
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry _value;
HashEntry *value = &_value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -108,39 +120,35 @@
hash_put(interpreter, hash, key, value);
value = hash_get(interpreter, hash, key);
- printf("%i\n", (int)value->val.int_val);
+ PIO_eprintf(interpreter, "%i\n", (int)value->val.int_val);
- return 0;
+ return NULL;
}
CODE
42
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_get with NULL key");
-
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_get with NULL key");
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry _value;
HashEntry *value = &_value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
/*
@@ -157,39 +165,35 @@
hash_put(interpreter, hash, key, value);
value = hash_get(interpreter, hash, key);
- printf("%i\n", (int)value->val.int_val);
+ PIO_eprintf(interpreter, "%i\n", (int)value->val.int_val);
- return 0;
+ return NULL;
}
CODE
42
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_get with empty string key");
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_get with empty string key");
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
-
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry _value;
HashEntry *value = &_value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "", 0);
@@ -198,36 +202,22 @@
hash_put(interpreter, hash, key, value);
value = hash_get(interpreter, hash, key);
- printf("%i\n", value->val.int_val);
+ PIO_eprintf(interpreter, "%i\n", value->val.int_val);
- return 0;
+ return NULL;
}
CODE
42
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_get with big key");
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_get with big key");
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
#define BIGLEN 999999
-int do_test(Interp *interpreter);
-
-int main(int argc, char* argv[]) {
- Interp* interpreter;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
- interpreter->lo_var_ptr = &interpreter;
-
- Parrot_init(interpreter);
- return do_test(interpreter);
-}
-
-int do_test(Interp *interpreter)
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
{
Hash *hash;
STRING *key;
@@ -235,11 +225,19 @@
HashEntry *value = &_value;
char *big;
+ UNUSED(cur_op);
+ UNUSED(start);
+
+ /* XXX - Is this needed for this test when we run in Parrot_run_native?
+ * interpreter->lo_var_ptr = &interpreter;
+ */
+
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
big = calloc(BIGLEN, sizeof(char));
@@ -252,38 +250,34 @@
hash_put(interpreter, hash, key, value);
value = hash_get(interpreter, hash, key);
- printf("%i\n", value->val.int_val);
+ PIO_eprintf(interpreter, "%i\n", value->val.int_val);
- return 0;
+ return NULL;
}
CODE
42
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_size");
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_size");
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
-
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -301,38 +295,34 @@
value.val.string_val = key;
hash_put(interpreter, hash, key, &value);
- printf("%i\n", hash_size(interpreter, hash));
+ PIO_eprintf(interpreter, "%i\n", hash_size(interpreter, hash));
- return 0;
+ return NULL;
}
CODE
3
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_delete");
-
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_delete");
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
PMC *value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -350,13 +340,13 @@
VTABLE_set_string_native(interpreter, value, key);
hash_put(interpreter, hash, key, value);
- printf("%i\n", hash_size(interpreter, hash));
+ PIO_eprintf(interpreter, "%i\n", hash_size(interpreter, hash));
hash_delete(interpreter, hash, key);
- printf("%i\n", hash_size(interpreter, hash));
+ PIO_eprintf(interpreter, "%i\n", hash_size(interpreter, hash));
- return 0;
+ return NULL;
}
CODE
@@ -364,30 +354,26 @@
2
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "hash_clone");
+c_output_is($main . <<'CODE', <<'OUTPUT', "hash_clone");
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
-
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
Hash *hash2;
STRING *key;
PMC *value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -397,15 +383,15 @@
value = hash_get(interpreter, hash, key);
- printf("%i\n", (int)VTABLE_get_integer(interpreter, value));
+ PIO_eprintf(interpreter, "%i\n", (int)VTABLE_get_integer(interpreter, value));
hash_clone(interpreter, hash, &hash2);
value = hash_get(interpreter, hash2, key);
- printf("%i\n", (int)VTABLE_get_integer(interpreter, value));
+ PIO_eprintf(interpreter, "%i\n", (int)VTABLE_get_integer(interpreter, value));
- return 0;
+ return NULL;
}
CODE
@@ -413,29 +399,25 @@
42
OUTPUT
-c_output_like(<<'CODE', <<'OUTPUT', "dump_hash");
-
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+c_output_like($main . <<'CODE', <<'OUTPUT', "dump_hash");
-int main(int argc, char* argv[]) {
- Interp* interpreter;
+static opcode_t*
+the_test(struct Parrot_Interp *interpreter,
+ opcode_t *cur_op, opcode_t *start)
+{
Hash *hash;
STRING *key;
HashEntry value;
- interpreter = Parrot_new(NULL);
-
- if ( interpreter == NULL ) return 1;
-
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
new_hash(interpreter, &hash);
if ( hash == NULL ) {
- printf("hash creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "hash creation failed\n");
+ exit_value = 1;
+ return NULL;
}
key = string_from_cstring(interpreter, "fortytwo", 0);
@@ -455,7 +437,7 @@
dump_hash(interpreter, hash);
- return 0;
+ return NULL;
}
CODE
Index: t/src/list.t
===================================================================
RCS file: /cvs/public/parrot/t/src/list.t,v
retrieving revision 1.11
diff -u -a -r1.11 list.t
--- t/src/list.t 13 Dec 2003 15:01:19 -0000 1.11
+++ t/src/list.t 5 Jan 2004 18:16:30 -0000
@@ -2,13 +2,36 @@
use Parrot::Test tests => 2;
-c_output_is(<<'CODE', <<'OUTPUT', "data types");
+my $main = <<'CODE';
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+#include <parrot/parrot.h>
+#include <parrot/embed.h>
-int main(int argc, char* argv[]) {
+static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);
+
+int exit_value = 0;
+
+int main(int argc, char* argv[])
+{
+ Parrot_Interp interpreter = Parrot_new(NULL);
+ if (!interpreter) {
+ return 1;
+ }
+ Parrot_init(interpreter);
+
+ Parrot_run_native(interpreter, the_test);
+
+ Parrot_exit(exit_value);
+ return exit_value;
+}
+
+CODE
+
+c_output_is($main . <<'CODE', <<'OUTPUT', "data types");
+
+static opcode_t*
+the_test(Parrot_Interp interpreter, opcode_t *cur_op, opcode_t *start)
+{
int x, i, j;
char c;
short t;
@@ -17,14 +40,14 @@
List* list, *list2;
PMC *p1, *p2;
- Interp* interpreter = Parrot_new(NULL);
- if (interpreter == NULL) return 1;
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
list = list_new(interpreter, enum_type_int);
if (list == NULL) {
- printf("list creation failed\n");
- return 1;
+ PIO_eprintf(interpreter, "list creation failed\n");
+ exit_value = 1;
+ return NULL;
}
for (i = 0, x = 32; x < 43; x++, i++) {
@@ -33,7 +56,7 @@
if (i < 10)
;
else
- printf("The answer is %d.\n", j);
+ PIO_eprintf(interpreter, "The answer is %d.\n", j);
}
/* test various data types */
@@ -44,7 +67,7 @@
list_assign(interpreter, list, 2 ,(void*) 'c', enum_type_char);
list_assign(interpreter, list, 3 ,(void*) 'd', enum_type_char);
c = *(char*) list_get(interpreter, list, 1, enum_type_char);
- printf("char %c\n", c);
+ PIO_eprintf(interpreter, "char %c\n", c);
list = list_new(interpreter, enum_type_short);
@@ -52,14 +75,14 @@
list_assign(interpreter, list, 21 ,(void*) -15, enum_type_short);
list_assign(interpreter, list, 22 ,(void*) 99, enum_type_short);
t = *(short*) list_get(interpreter, list, 21, enum_type_short);
- printf("short %d\n", t);
+ PIO_eprintf(interpreter, "short %d\n", t);
list = list_new(interpreter, enum_type_FLOATVAL);
f = 1234.56;
list_assign(interpreter, list, 20 ,(void*) &f, enum_type_FLOATVAL);
f = *(FLOATVAL*) list_get(interpreter, list, 20, enum_type_FLOATVAL);
- printf("num " FLOATVAL_FMT "\n", f);
+ PIO_eprintf(interpreter, "num " FLOATVAL_FMT "\n", f);
s = string_make(interpreter, "Seems ok\n", 9, 0, 0,0);
@@ -72,10 +95,10 @@
p2 = *(PMC**)list_shift(interpreter, list, enum_type_PMC);
s = VTABLE_get_string(interpreter, p2);
- printf("string %s", string_to_cstring(interpreter, s));
+ PIO_eprintf(interpreter, "string %s", string_to_cstring(interpreter, s));
i = list_length(interpreter, list);
- printf("len now %d\n", i);
+ PIO_eprintf(interpreter, "len now %d\n", i);
s = string_make(interpreter, "list\n", 5, 0, 0,0);
p1 = pmc_new(interpreter, enum_class_PerlString);
@@ -92,11 +115,11 @@
p1 = *(PMC**) list_shift(interpreter, list, enum_type_PMC);
s = VTABLE_get_string(interpreter, p1);
- printf("string %s", string_to_cstring(interpreter, s));
+ PIO_eprintf(interpreter, "string %s", string_to_cstring(interpreter, s));
p2 = *(PMC**) list_shift(interpreter, list2, enum_type_PMC);
s = VTABLE_get_string(interpreter, p2);
- printf("string %s", string_to_cstring(interpreter, s));
+ PIO_eprintf(interpreter, "string %s", string_to_cstring(interpreter, s));
list = list_new(interpreter, enum_type_STRING);
s = string_make(interpreter, "list\n", 5, 0, 0,0);
@@ -107,9 +130,9 @@
s = string_make(interpreter, "list 2\n", 7, 0, 0,0);
list_assign(interpreter, list2, 0, s, enum_type_STRING);
s = *(STRING**) list_shift(interpreter, list, enum_type_STRING);
- printf("string %s", string_to_cstring(interpreter, s));
+ PIO_eprintf(interpreter, "string %s", string_to_cstring(interpreter, s));
s = *(STRING**) list_shift(interpreter, list2, enum_type_STRING);
- printf("string %s", string_to_cstring(interpreter, s));
+ PIO_eprintf(interpreter, "string %s", string_to_cstring(interpreter, s));
/* delete test */
list = list_new(interpreter, enum_type_char);
@@ -120,7 +143,7 @@
list_delete(interpreter, list, 1, 1);
list_delete(interpreter, list, 1, 4);
j = *(char*) list_get(interpreter, list, 1, enum_type_char);
- printf("delete 1 %s\n", (j == 6+'a') ? "ok" : "nok");
+ PIO_eprintf(interpreter, "delete 1 %s\n", (j == 6+'a') ? "ok" : "nok");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 26; i++) {
@@ -129,7 +152,7 @@
}
list_delete(interpreter, list, 1, 20);
j = *(char*) list_get(interpreter, list, 1, enum_type_char);
- printf("delete 2 %s\n", (j == 21+'a') ? "ok" : "nok");
+ PIO_eprintf(interpreter, "delete 2 %s\n", (j == 21+'a') ? "ok" : "nok");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 26; i++) {
@@ -142,7 +165,7 @@
list_push(interpreter, list, (void*) c, enum_type_char);
}
j = *(char*) list_get(interpreter, list, 6, enum_type_char);
- printf("delete 3 %s\n", (j == 'E' && list_length(interpreter, list) == 28)
+ PIO_eprintf(interpreter, "delete 3 %s\n", (j == 'E' && list_length(interpreter, list) == 28)
? "ok" : "nok");
list = list_new(interpreter, enum_type_char);
@@ -155,27 +178,27 @@
list_delete(interpreter, list, 5, 3000);
list_delete(interpreter, list, 2, 996);
j = *(char*) list_get(interpreter, list, -1, enum_type_char);
- printf("delete 4 %s\n", (j == 'Z' && list_length(interpreter, list) == 5)
+ PIO_eprintf(interpreter, "delete 4 %s\n", (j == 'Z' && list_length(interpreter, list) == 5)
? "ok" : "nok");
#if 0
/* insert */
- printf("\nnew list(0..5), shift\n");
+ PIO_eprintf(interpreter, "\nnew list(0..5), shift\n");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 6; i++)
list_push(interpreter, list, (void*) 'a'+i, enum_type_char);
list_shift(interpreter, list, enum_type_char);
list_dump(0, list, 0);
- printf("insert(2, 5)\n");
+ PIO_eprintf(interpreter, "insert(2, 5)\n");
list_insert(interpreter, list, 2, 5);
list_dump(0, list, 0);
- printf("insert(1, 1)\n");
+ PIO_eprintf(interpreter, "insert(1, 1)\n");
list_insert(interpreter, list, 1, 1);
list_dump(0, list, 0);
- printf("list(1..) = 'A'..'F'\n");
+ PIO_eprintf(interpreter, "list(1..) = 'A'..'F'\n");
for (i = 0; i < 6; i++)
list_assign(interpreter, list, 1+i ,(void*)'A'+i, enum_type_char);
list_dump(0, list, 0);
- printf("4 x pop\n");
+ PIO_eprintf(interpreter, "4 x pop\n");
for (i = 0; i < 4; i++)
list_pop(interpreter, list, enum_type_char);
list_dump(0, list, 0);
@@ -193,57 +216,58 @@
list_assign(interpreter, list, i, (void*) c, enum_type_char);
}
j = *(char*) list_get(interpreter, list, 0, enum_type_char);
- printf("insert 2 %s\n", (j == 'A') ? "ok" : "nok");
+ PIO_eprintf(interpreter, "insert 2 %s\n", (j == 'A') ? "ok" : "nok");
#if 0
- printf("\nnew list(0..5)\n");
+ PIO_eprintf(interpreter, "\nnew list(0..5)\n");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 6; i++)
list_push(interpreter, list, (void*) 'a'+i, enum_type_char);
list_dump(0, list, 0);
- printf("insert(5, 3)\n");
+ PIO_eprintf(interpreter, "insert(5, 3)\n");
list_insert(interpreter, list, 5, 3);
list_dump(0, list, 0);
- printf("list(5..9) = 'A'..'E'\n");
+ PIO_eprintf(interpreter, "list(5..9) = 'A'..'E'\n");
for (i = 0; i < 5; i++)
list_assign(interpreter, list, 5+i ,(void*)'A'+i, enum_type_char);
list_dump(0, list, 0);
- printf("\nnew list(0..5)\n");
+ PIO_eprintf(interpreter, "\nnew list(0..5)\n");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 6; i++)
list_push(interpreter, list, (void*) 'a'+i, enum_type_char);
list_dump(0, list, 0);
- printf("insert(6, 3)\n");
+ PIO_eprintf(interpreter, "insert(6, 3)\n");
list_insert(interpreter, list, 6, 3);
list_dump(0, list, 0);
- printf("list(5..9) = 'A'..'E'\n");
+ PIO_eprintf(interpreter, "list(5..9) = 'A'..'E'\n");
for (i = 0; i < 5; i++)
list_assign(interpreter, list, 5+i ,(void*)'A'+i, enum_type_char);
list_dump(0, list, 0);
- printf("delete(0,1)\n");
+ PIO_eprintf(interpreter, "delete(0,1)\n");
list_delete(interpreter, list, 0, 1);
list_dump(0, list, 0);
- printf("\nnew list(0..5)\n");
+ PIO_eprintf(interpreter, "\nnew list(0..5)\n");
list = list_new(interpreter, enum_type_char);
- printf("insert(0, 3)\n");
+ PIO_eprintf(interpreter, "insert(0, 3)\n");
list_insert(interpreter, list, 0, 3);
list_dump(0, list, 0);
- printf("\nnew list(0..25)\n");
+ PIO_eprintf(interpreter, "\nnew list(0..25)\n");
list = list_new(interpreter, enum_type_char);
for (i = 0; i < 26; i++)
list_push(interpreter, list, (void*) 'a'+i, enum_type_char);
- printf("set_length(4)\n");
+ PIO_eprintf(interpreter, "set_length(4)\n");
list_set_length(interpreter, list, 4);
list_dump(0, list, 0);
- printf("set_length(-1)\n");
+ PIO_eprintf(interpreter, "set_length(-1)\n");
list_set_length(interpreter, list, -1);
list_dump(0, list, 0);
#endif
- printf("Done.\n");
- return 0;
+ PIO_eprintf(interpreter, "Done.\n");
+
+ return NULL;
}
CODE
@@ -265,13 +289,11 @@
Done.
OUTPUT
-c_output_is(<<'CODE', <<'OUTPUT', "arbitrary sized");
-
-#include <stdio.h>
-#include "parrot/parrot.h"
-#include "parrot/embed.h"
+c_output_is($main . <<'CODE', <<'OUTPUT', "arbitrary sized");
-int main(int argc, char* argv[]) {
+static opcode_t*
+the_test(Parrot_Interp interpreter, opcode_t *cur_op, opcode_t *start)
+{
int x;
List* list;
PMC *p;
@@ -279,9 +301,8 @@
char buf[100];
int i, j, ok;
- Interp* interpreter = Parrot_new(NULL);
- if (interpreter == NULL) return 1;
- Parrot_init(interpreter);
+ UNUSED(cur_op);
+ UNUSED(start);
p = pmc_new(interpreter, enum_class_Array);
@@ -303,7 +324,7 @@
VTABLE_set_integer_keyed_int(interpreter, p, key, 3);
list = list_new_init(interpreter, enum_type_sized, p);
- printf("ok 1\n");
+ PIO_eprintf(interpreter, "ok 1\n");
for (j = 0; j < 5; j++) {
for (i = 0; i < 100; i++)
@@ -320,11 +341,11 @@
}
}
if (ok)
- printf("ok 2\n");
+ PIO_eprintf(interpreter, "ok 2\n");
else
- printf("failed 2: i=%d j=%d\n", i, j);
- Parrot_exit(0);
- return 0;
+ PIO_eprintf(interpreter, "failed 2: i=%d j=%d\n", i, j);
+
+ return NULL;
}
CODE
ok 1