Author: bernhard
Date: Wed Jan 11 08:36:43 2006
New Revision: 11088
Added:
trunk/src/bignum.c
- copied, changed from r11085, trunk/src/types/bignum.c
trunk/src/bignum.h
- copied, changed from r11085, trunk/src/types/bignum.h
trunk/t/pmc/bignum.t
- copied, changed from r11085, trunk/src/types/bignum_atest.pl
Removed:
trunk/src/types/
Modified:
trunk/MANIFEST
trunk/MANIFEST.SKIP
Log:
[perl #37905] move *.pl out of src/
Merge src/types/*.pl into t/pmc/bingnum.t and skip this test.
Dissolve src/types by moving src/types/bignum.* to src.
This is in line with e.g. src/string.*.
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Wed Jan 11 08:36:43 2006
@@ -1556,6 +1556,8 @@ runtime/parrot/library/postgres.declarat
runtime/parrot/library/postgres.pasm [library]
runtime/parrot/library/postgres.pir [library]
runtime/parrot/library/random_lib.pir [library]
+src/bignum.c []
+src/bignum.h []
src/builtin.c []
src/byteorder.c []
src/call_list.txt [devel]doc
@@ -1825,10 +1827,6 @@ src/sub.c
src/thread.c []
src/trace.c []
src/tsq.c []
-src/types/bignum.c []
-src/types/bignum.h []
-src/types/bignum_atest.pl []
-src/types/bignum_test.pl []
src/utils.c []
src/vtables.c []
src/warnings.c []
@@ -1974,6 +1972,7 @@ t/perl/cppcomments.t
t/perl/manifest.t []
t/pmc/array.t []
t/pmc/bigint.t []
+t/pmc/bignum.t []
t/pmc/boolean.t []
t/pmc/builtin.t []
t/pmc/complex.t []
Modified: trunk/MANIFEST.SKIP
==============================================================================
--- trunk/MANIFEST.SKIP (original)
+++ trunk/MANIFEST.SKIP Wed Jan 11 08:36:43 2006
@@ -1,5 +1,5 @@
# $Id$
-# generated by tools/dev/gen_manifest_skip.pl Tue Jan 10 20:08:51 2006
+# generated by tools/dev/gen_manifest_skip.pl Wed Jan 11 17:27:20 2006
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
@@ -96,6 +96,7 @@
^.*\.exp$
^.*\.exp/
# generated from svn:ignore of 'LICENSES/'
+# generated from svn:ignore of 'blib/lib/'
# generated from svn:ignore of 'compilers/'
# generated from svn:ignore of 'compilers/ast/'
^compilers/ast/.*\.flag$
@@ -947,6 +948,18 @@
^src/dynoplibs/.*\.h/
^src/dynoplibs/.*\.so$
^src/dynoplibs/.*\.so/
+^src/dynoplibs/.*\.obj$
+^src/dynoplibs/.*\.obj/
+^src/dynoplibs/.*\.dll$
+^src/dynoplibs/.*\.dll/
+^src/dynoplibs/.*\.pdb$
+^src/dynoplibs/.*\.pdb/
+^src/dynoplibs/.*\.ilk$
+^src/dynoplibs/.*\.ilk/
+^src/dynoplibs/.*\.lib$
+^src/dynoplibs/.*\.lib/
+^src/dynoplibs/.*\.exp$
+^src/dynoplibs/.*\.exp/
# generated from svn:ignore of 'src/encodings/'
^src/encodings/.*\.o$
^src/encodings/.*\.o/
@@ -1027,6 +1040,7 @@
^t/dynclass/.*\.pbc/
^t/dynclass/.*\.pir$
^t/dynclass/.*\.pir/
+# generated from svn:ignore of 't/dynoplibs/'
# generated from svn:ignore of 't/examples/'
^t/examples/.*\.pasm$
^t/examples/.*\.pasm/
Copied: trunk/src/bignum.c (from r11085, trunk/src/types/bignum.c)
==============================================================================
--- trunk/src/types/bignum.c (original)
+++ trunk/src/bignum.c Wed Jan 11 08:36:43 2006
@@ -42,6 +42,15 @@ Access digits, macros assume length give
=over 4
+=head1 TODO
+
+This is currently not used yet. Parrot has no BigNum support yet.
+
+==head1 SEE ALSO
+
+F<docs/docs/pdds/clip/pdd14_bignum.pod>,
+L<https://rt.perl.org/rt3/Ticket/Display.html?id=36330>
+
=cut
*/
Copied: trunk/src/bignum.h (from r11085, trunk/src/types/bignum.h)
==============================================================================
--- trunk/src/types/bignum.h (original)
+++ trunk/src/bignum.h Wed Jan 11 08:36:43 2006
@@ -12,6 +12,15 @@ Some of this file will want to be moved
directories, but some should stay here, for the sake of being easily
removed for back-porting.
+=head1 TODO
+
+This is currently not used yet. Parrot has no BigNum support yet.
+
+==head1 SEE ALSO
+
+F<docs/docs/pdds/clip/pdd14_bignum.pod>,
+L<https://rt.perl.org/rt3/Ticket/Display.html?id=36330>
+
=cut
*/
Copied: trunk/t/pmc/bignum.t (from r11085, trunk/src/types/bignum_atest.pl)
==============================================================================
--- trunk/src/types/bignum_atest.pl (original)
+++ trunk/t/pmc/bignum.t Wed Jan 11 08:36:43 2006
@@ -1,9 +1,34 @@
-#! perl -w
-
# $Id$
-# bignum all test.
-# This allows lots of tests to be run, parsed out of *.decTest, available
-# from: http://www2.hursley.ibm.com/decimal/dectest.html
+
+=head1 NAME
+
+t/pmc/bignum.t - Test the non-implemented BigNum PMC.
+
+=head1 DESCRIPTION
+
+Does nothing yet, as there is no BigNum PMC yet.
+
+The idea is to run the test cases parsed out of *.decTest, available
+from: http://www2.hursley.ibm.com/decimal/dectest.html
+
+=head1 HISTORY
+
+This was started by Alex Gogh, who went to work in Antarctica,
http://the.earth.li/~alex/halley/.
+The script was supposed to test bignum.c, which should become the basis for a
+BigNum PMC.
+
+=head1 TODO
+
+This is very broken.
+
+==head1 SEE ALSO
+
+F<docs/docs/pdds/clip/pdd14_bignum.pod>,
+L<https://rt.perl.org/rt3/Ticket/Display.html?id=36330>
+
+=cut
+
+use Test::More skip_all => 'No BigNum support yet.';
my ($test, $one, $two, $result, $prec, $round, $maxexp,
$skip ,$op, @conds, $line, $arrow);
@@ -71,7 +96,7 @@ while (<>) {
}
$testsrun += 2;
- my ($output) = `perl bignum_test.pl $one $two $op $precision $round
$extended`;
+ my ($output) = run_single_test( $one $two $op $precision $round $extended
);
chomp($output);
my @out = split(/\s+/, $output);
if ($result eq $out[0] || ($result eq '?')) {
@@ -127,5 +152,135 @@ while (<>) {
}
-print "Ran $testsrun tests ($testspass,$testsfail) = ".
- sprintf("%2.00d",100*$testspass/$testsrun )."%\n";
+
+
+
+
+
+
+
+
+# XXX The following used to be bignum_test.pl.
+# Maybe it should be factored out to Parrot::Test::BigNum.
+
+# This allows a single bignum test to be run directly through the C
+# library. Usage available by getting the args wrong.
+
+use lib "../lib";
+use Inline C => Config => CCFLAGS => '-I.';
+use Inline C => <<'END_OF_C_SECTION';
+#include "bignum.c"
+
+int runtest (char* lef, char *rih, int oper, int prec, int round, int
extended) {
+ BIGNUM *one, *two, *result;
+ char *output;
+ BN_CONTEXT context;
+ char *traps[7] = {"Lost_digits","Division_by_zero","Inexact",
+ "Invalid_operation","Overflow","Rounded","Underflow"};
+
+ context.elimit = 999999999;
+ context.precision = prec;
+ context.extended = extended;
+ context.flags = 0;
+ context.traps = 0;
+ switch (round) {
+ case 1 : context.rounding = ROUND_HALF_UP;
+ break;
+ case 2 : context.rounding = ROUND_DOWN;
+ break;
+ case 3 : context.rounding = ROUND_HALF_EVEN;
+ break;
+ case 4 : context.rounding = ROUND_CEILING;
+ break;
+ case 5 : context.rounding = ROUND_FLOOR;
+ break;
+ default : printf("Unknown rounding %i\n", round);
+ exit(1);
+ }
+
+ one = BN_from_string(lef, &context);
+ two = BN_from_string(rih, &context);
+
+ result = BN_new(1);
+
+ switch (oper) {
+ case 1 : BN_add(result, one, two, &context);
+ break;
+ case 2 : BN_subtract(result, one, two, &context);
+ break;
+ case 3 : BN_plus(result, one, &context);
+ break;
+ case 4 : BN_minus(result, one, &context);
+ break;
+ case 5 : BN_compare(result, one, two, &context);
+ break;
+ case 6 : BN_multiply(result, one, two, &context);
+ break;
+ case 7 : BN_divide(result, one, two, &context);
+ break;
+ case 8 : BN_divide_integer(result, one, two, &context);
+ break;
+ case 9 : BN_remainder(result, one, two, &context);
+ break;
+ case 10: BN_rescale(result, one, two, &context);
+ break;
+ case 11: BN_power(result, one, two, &context);
+ break;
+
+ default : printf("No operation of type %i\n", oper);
+ exit(0);
+ }
+
+ BN_to_scientific_string(result, &output);
+ printf("%s", output);
+ {
+ int i;
+ for (i=0; i< 7; i++)
+ if ((1 << i) & context.flags) printf(" %s", traps[i]);
+ }
+ printf("\n");
+ return 1;
+}
+END_OF_C_SECTION
+
+my %ops = (
+ add => 1,
+ subtract => 2,
+ plus => 3,
+ minus => 4,
+ compare => 5,
+ multiply => 6,
+ divide => 7,
+ divideint => 8,
+ remainder => 9,
+ rescale => 10,
+ power => 11,
+ );
+
+my %round = (
+ half_up => 1,
+ down => 2,
+ half_even => 3,
+ ceiling => 4,
+ floor => 5,
+ );
+
+sub run_single_test
+{
+ unless (@_ == 6) {
+ die <<ENDOFUSAGE;
+bignum_test.pl -- run test through bignum.c
+bignum_test.pl one two operation precision rounding extended
+ENDOFUSAGE
+ }
+
+ for ($_[0], $_[1]) {
+ s/^"|"$//g;
+ s/""/\"/g;
+ s/^'|'$//g;
+ s/''/\'/g;
+ }
+
+ # XXX Capture STDOUT
+ runtest($_[0], $_[1], $ops{$ARGV[2]}, $_[3], $round{$_[4]}, $_[5]);
+}