> PLEASE can someone rewrite the tests to actually *test* things
> and print "ok 1\n" and so on?
Here it is ( for the second time )
> Quick, or I'll call Schwern in.
Ah, I thought you missed my patches, then I was correct
both attached
testsuite.diff:
-----------------------------
Run with
perl -Mlib=lib t/harness
just as make test in perl5
Tests live in t/*/*.t .
In case of failure the assembler, bytecode and output
are available as t/dir/testnnn.pasm/pbc/out
-------------------------------
things.diff
---------------------------------
This patch adds:
an hints directory ( files are named hints/lc($^O).pl )
therir contents are eval'd in Config.pl
it adds to Config.pl some flags
--debugging Enable debugging
adds -g or equivalento to compiler flags
--defaults Accept all default values
like -d option to perl5 Configure
--define name=value Defines value name as value
i.e --define cc=gcc --define ld=myld
--help This text
--version Show assembler version
Win32 does not have mmap() ( it has memory mapped files, but with
a different API, so I just read() the bytecode in a malloc()ed
buffer.
Compilation tested on Win32 (MSVC5 and MinGW ) and Linux
--------------------------------
Best regards
Mattia
P.S.: what should I do to make patches stand out better
in the mailing list?
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: things.diff
Date: 14 Sep 2001, 18:32
Size: 5076 bytes.
Type: Unknown
things.diff
diff -r -b -u -2 -N parrot.cvs/lib/Test/Parrot.pm parrot/lib/Test/Parrot.pm
--- parrot.cvs/lib/Test/Parrot.pm Thu Jan 01 01:00:00 1970
+++ parrot/lib/Test/Parrot.pm Thu Sep 13 19:01:16 2001
@@ -0,0 +1,79 @@
+#
+
+package Test::Parrot;
+
+use strict;
+use vars qw(@EXPORT @ISA);
+
+require Exporter;
+require Test::More;
+
+@EXPORT = ( qw(output_is), @Test::More::EXPORT );
+@ISA = qw(Exporter Test::More);
+
+sub import {
+ my( $class, $plan, @args ) = @_;
+
+ Test::More->import( $plan, @args );
+
+ __PACKAGE__->_export_to_level( 2, __PACKAGE__ );
+}
+
+# this kludge is an hopefully portable way of having
+# redirections ( tested on Linux and Win2k )
+sub _run_command {
+ my( $command, %redir ) = @_;
+ my( $redir_string );
+
+ while( my @dup = each %redir ) {
+ my( $from, $to ) = @dup;
+ if( $to eq 'STDERR' ) { $to = "qq{>&STDERR}" }
+ elsif( $to eq 'STDOUT' ) { $to = "qq{>&STDOUT}" }
+ elsif( $to eq '/dev/null' ) { $to = ( $^O eq 'MSWin32' ) ?
+ 'qq{> NUL:}' : "qq{> $to}" }
+ else { $to = "qq{> $to}" }
+
+ $redir_string .= "open $from, $to;"
+ }
+
+ system "$^X -e \"$redir_string;system qq{$command};\"";
+}
+
+my $count;
+
+foreach my $i ( qw(is isnt like) ) {
+ no strict 'refs';
+
+ *{"Test::Parrot::output_$i"} = sub ($$;$) {
+ ++$count;
+ my( $assembly, $output, $desc ) = @_;
+ local( *ASSEMBLY, *OUTPUT );
+ my( $as_f, $by_f, $out_f ) = map {
+ my $t = $0; $t =~ s/\.t$/$count\.$_/; $t
+ } ( qw(pasm pbc out) );
+
+ open ASSEMBLY, "> $as_f" or die "Unable to open '$as_f'";
+ binmode ASSEMBLY;
+ print ASSEMBLY $assembly;
+ close ASSEMBLY;
+
+ _run_command( "perl assemble.pl $as_f", 'STDOUT' => $by_f );
+ _run_command( "./test_prog $by_f", 'STDOUT' => $out_f );
+
+ my $prog_output;
+ open OUTPUT, "< $out_f";
+ {
+ local $/ = undef;
+ $prog_output = <OUTPUT>;
+ }
+ close OUTPUT;
+
+ @_ = ( $prog_output, $output, $desc );
+ #goto &{"Test::More::$i"};
+ my $ok = &{"Test::More::$i"}( @_ );
+ unlink( $by_f, $out_f ) if $ok;
+ }
+}
+
+1;
+
diff -r -b -u -2 -N parrot.cvs/t/harness parrot/t/harness
--- parrot.cvs/t/harness Thu Jan 01 01:00:00 1970
+++ parrot/t/harness Thu Sep 13 17:36:08 2001
@@ -0,0 +1,7 @@
+#! perl -w
+
+use strict;
+use Test::Harness qw(runtests);
+
+my @tests = map { glob( "t/$_/*.t" ) } ( qw(op misc) );
+runtests( @tests );
diff -r -b -u -2 -N parrot.cvs/t/op/basic.t parrot/t/op/basic.t
--- parrot.cvs/t/op/basic.t Thu Jan 01 01:00:00 1970
+++ parrot/t/op/basic.t Fri Sep 14 01:42:44 2001
@@ -0,0 +1,32 @@
+#! perl -w
+
+use Test::Parrot tests => 1;
+
+ok( 1 );
+exit 0;
+
+output_is( <<CODE, <<OUTPUT, "branch_ic" );
+ set_i_ic I4, 42
+ branch_ic HERE
+ set_i_ic I4, 1234
+HERE:
+ print_i I4
+ end
+CODE
+I reg 4 is 42
+OUTPUT
+
+SKIP: {
+ skip( "label constants unimplemented in assembler", 1 );
+output_is( <<CODE, <<OUTPUT, "jump" );
+ set_i_ic I4, 42
+ set_i_ic I5, HERE
+ jump_i I5
+ set_i_ic I4, 1234
+HERE:
+ print_i I4
+ end
+CODE
+I reg 4 is 42
+OUTPUT
+}
diff -r -b -u -2 -N parrot.cvs/t/op/string.t parrot/t/op/string.t
--- parrot.cvs/t/op/string.t Thu Jan 01 01:00:00 1970
+++ parrot/t/op/string.t Fri Sep 14 01:58:28 2001
@@ -0,0 +1,56 @@
+#! perl -w
+
+use Test::Parrot tests => 4;
+
+output_is( <<'CODE', <<OUTPUT, "set_s_sc" );
+ set S4, "JAPH\n"
+ print S4
+ end
+CODE
+JAPH
+OUTPUT
+
+output_is( <<'CODE', <<OUTPUT, "length_i_s" );
+ set I4, 0
+ set S4, "JAPH"
+ length I4, S4
+ print I4
+ set S3, "\n"
+ print S3
+ end
+CODE
+4
+OUTPUT
+
+output_is( <<'CODE', <<OUTPUT, "chopn_s_ic" );
+ set S4, "JAPHxyzw"
+ set S5, "japhXYZW"
+ set S3, "\n"
+ chopn S4, 3
+ chopn S4, 1
+ chopn S5, 4
+ print S4
+ print S3
+ print S5
+ print S3
+ end
+CODE
+JAPH
+japh
+OUTPUT
+
+SKIP: {
+ skip "I'm unable to write it!", 1;
+output_is( <<'CODE', <<OUTPUT, "substr_s_s_i_i" );
+ set S4, "12345JAPH01"
+ set I4, 5
+ set I5, 4
+ substr S5, S4, I4, I5
+ print S5
+ set S3, "\n"
+ print S3
+ end
+CODE
+JAPH
+OUTPUT
+}