Re: [PATCH?] Error in t/src/list.t on FreeBSD

2004-01-06 Thread Leopold Toetsch
Lars Balker Rasmussen <[EMAIL PROTECTED]> wrote:

> I've rewritten list.t and hash.t to use this scheme, generalizing the
> layout a bit in the process.

Thanks, applied.

> 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 removed that. Its not needed anymore, running it via run_native now
does a proper setup of the stack limit (lo_var_ptr).

leo


Re: [PATCH?] Error in t/src/list.t on FreeBSD

2004-01-05 Thread Lars Balker Rasmussen
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 -	1.5
+++ t/src/exit.t	5 Jan 2004 18:16:30 -
@@ -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 -	1.10
+++ t/src/hash.t	5 Jan 2004 18:16:30 -
@@ -3,63 +3,79 @@
 
 use Parrot::Test tests => 10;
 
-c_output_is(<<'CODE', <<'OUTPUT', "new_hash");
+my $main = <<'CODE';
+#include 
+#include 
 
-#include 
-#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 
-#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 
-#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 
-#include "parrot/parrot.h"
-#include "parrot/embed

Re: [PATCH?] Error in t/src/list.t on FreeBSD

2004-01-05 Thread Leopold Toetsch
Lars Balker Rasmussen <[EMAIL PROTECTED]> wrote:
> I was seeing an error in the second test in t/src/list.t on FreeBSD:

> set_integer_keyed() not implemented in class 'PerlInt'

> I tracked it down to two consecutive calls to pmc_new() returning the
> same pointer, which is generally not what you want.

All these (non-trivial) source tests, that create some resources should
use the scheme of t/src/basic_3.

leo


[PATCH?] Error in t/src/list.t on FreeBSD

2004-01-03 Thread Lars Balker Rasmussen
I was seeing an error in the second test in t/src/list.t on FreeBSD:

set_integer_keyed() not implemented in class 'PerlInt'

I tracked it down to two consecutive calls to pmc_new() returning the
same pointer, which is generally not what you want.  Copying the
following line from imcc/main.c to just before the first pmc_new() in
the second test in t/src/list.t fixed the problem.

interpreter->DOD_block_level++;
 
But I'm unsure if this is the right way to go about it, or rather, if
the line above belongs in Parrot_init() or elsewhere.

Cheers,
-- 
Lars Balker Rasmussen  Consult::Perl