develooper Front page | perl.perl5.porters | Postings from April 2000

[PATCH] Re: [ID 20000410.010] Unicoss 10.0.0.6 and perl 5.6.0

Thread Next
From:
M.J.T. Guy
Date:
April 18, 2000 10:24
Subject:
[PATCH] Re: [ID 20000410.010] Unicoss 10.0.0.6 and perl 5.6.0
Message ID:
E12hbk1-0006Ws-00@ursa.cus.cam.ac.uk
Robert Payne <payner@ncisv11.NCIFCRF.GOV> wrote
> op/64bitint..........FAILED at test 23
> op/bop...............FAILED at test 12
> op/misc..............PROG: 
> use integer;
> print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
> EXPECTED:
> -1 0 0 1 !
> GOT:
> 7 0 0 -7 !
> FAILED at test 3
> 
> op/pack..............FAILED at test 10
> 
> Failed 5 test scripts out of 230, 97.83% okay.
> 
> How important are these failures ?

At least two of them are bugs in the tests.


op/bop test 12:
This is testing the >> operator on a negative LHS under "use integer",
and assuming that you get sign bit propagation.    But under "use integer"
you get "what the underlying C happens to do", and the C standard
explicitly leaves undefined whether sign propagation occurs in this case.


op/misc test 3:
Similarly, this is using the >> operator under "use integer" to
calculate the constant $cusp for the test.    So on most platforms
it's getting a value of 0 for $cusp; probably not what the test designer
intended.     Also, it's checking the result of the % operator with
negative arguments; this is also not defined by the C standard.

Two additional questions about this test:
a)   The "use integer" was added recently (between 5.5.660 and 5.6.rc1).
     Why?     What exactly is this test trying to exercise?
b)   In view of the rubric at the top of t/op/misc.t

# NOTE: Please don't add tests to this file unless they *need* to be run in
# separate executable and can't simply use eval.

     why is this test where it is?


The attached patch fixes[*] these two tests.    Whether it's the "right"
fix depends on the answers to the above questions.

[*] Of course, I've only checked it on platforms I have access to;
    someone else will need to check it on Unicos.


Mike Guy

--- ./t/op/bop.t.orig	Tue Apr 18 17:34:38 2000
+++ ./t/op/bop.t	Tue Apr 18 17:14:33 2000
@@ -39,7 +39,7 @@
 	do { use integer; 1 << ($bits - 1) } == -$cusp)
        ? "ok 11\n" : "not ok 11\n");
 print ((($cusp >> 1) == ($cusp / 2) &&
-	do { use integer; $cusp >> 1 } == -($cusp / 2))
+	do { use integer; abs($cusp >> 1) } == ($cusp / 2))
        ? "ok 12\n" : "not ok 12\n");
 
 $Aaz = chr(ord("A") & ord("z"));
--- ./t/op/misc.t.orig	Tue Apr 18 17:34:38 2000
+++ ./t/op/misc.t	Tue Apr 18 17:57:47 2000
@@ -59,12 +59,12 @@
 EXPECT
 a := b := c
 ########
-use integer;
 $cusp = ~0 ^ (~0 >> 1);
+use integer;
 $, = " ";
-print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, ($cusp + 1) % 8, "!\n";
+print +($cusp - 1) % 8, $cusp % 8, -$cusp % 8, 8 | (($cusp + 1) % 8 + 7), "!\n";
 EXPECT
--1 0 0 1 !
+7 0 0 8 !
 ########
 $foo=undef; $foo->go;
 EXPECT

End of patch

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About