From b42d0ec9e46a4139cf3556f5cc00b0bf1daacdeb Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Wed, 4 Feb 1998 14:59:47 +0200 Subject: [PATCH] almost OK: perl 5.00457 on i386-freebsd-thread 3.0 Date: Wed, 4 Feb 1998 12:59:47 +0200 (EET) Subject: Re: [PATCH] 5.004_04 and 5.004_57: Complex.pm and complex.t Date: Thu, 5 Feb 1998 18:08:20 +0200 (EET) p4raw-id: //depot/perl@476 --- t/lib/complex.t | 148 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 46 deletions(-) (limited to 't/lib') diff --git a/t/lib/complex.t b/t/lib/complex.t index 3390334d34..2783e42f66 100755 --- a/t/lib/complex.t +++ b/t/lib/complex.t @@ -3,13 +3,9 @@ # $RCSfile: complex.t,v $ # # Regression tests for the Math::Complex pacakge -# -- Raphael Manfredi September 1996 -# -- Jarkko Hietaniemi March-October 1997 -# -- Daniel S. Lewart September-October 1997 - -$VERSION = '1.05'; - -# $Id: complex.t,v 1.1 1997/10/15 10:02:15 jhi Exp jhi $ +# -- Raphael Manfredi since Sep 1996 +# -- Jarkko Hietaniemi since Mar 1997 +# -- Daniel S. Lewart since Sep 1997 BEGIN { chdir 't' if -d 't'; @@ -18,6 +14,8 @@ BEGIN { use Math::Complex; +$VERSION = sprintf("%s", q$Id: complex.t,v 1.8 1998/02/05 16:03:39 jhi Exp $ =~ /(\d+\.d+)/); + my ($args, $op, $target, $test, $test_set, $try, $val, $zvalue, @set, @val); $test = 0; @@ -26,7 +24,7 @@ my @script = ( 'my ($res, $s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10, $z0,$z1,$z2);' . "\n\n" ); -my $eps = 1e-11; +my $eps = 1e-13; while () { s/^\s+//; @@ -59,16 +57,70 @@ while () { } } +# + +sub test_mutators { + my $op; + + $test++; +push(@script, <<'EOT'); +{ + my $z = cplx( 1, 1); + $z->Re(2); + $z->Im(3); + print 'not ' unless Re($z) == 2 and Im($z) == 3; +EOT + push(@script, qq(print "ok $test\\n"}\n)); + + $test++; +push(@script, <<'EOT'); +{ + my $z = cplx( 1, 1); + $z->abs(3 * sqrt(2)); + print 'not ' unless (abs($z) - 3 * sqrt(2)) < $eps and + (arg($z) - pi / 4 ) < $eps and + (Re($z) - 3 ) < $eps and + (Im($z) - 3 ) < $eps; +EOT + push(@script, qq(print "ok $test\\n"}\n)); + + $test++; +push(@script, <<'EOT'); +{ + my $z = cplx( 1, 1); + $z->arg(-3 / 4 * pi); + print 'not ' unless (arg($z) + 3 / 4 * pi) < $eps and + (abs($z) - sqrt(2) ) < $eps and + (Re($z) + 1 ) < $eps and + (Im($z) + 1 ) < $eps; +EOT + push(@script, qq(print "ok $test\\n"}\n)); +} + +test_mutators(); + +my $constants = ' +my $i = cplx(0, 1); +my $pi = cplx(pi, 0); +my $pii = cplx(0, pi); +my $pip2 = cplx(pi/2, 0); +my $zero = cplx(0, 0); +'; + +push(@script, $constants); + + # test the divbyzeros sub test_dbz { for my $op (@_) { $test++; -# push(@script, qq(print "# '$op'\n";)); - push(@script, qq(eval '$op';)); - push(@script, qq(print 'not ' unless (\$@ =~ /Division by zero/);)); - push(@script, qq( print "ok $test\\n";\n)); + push(@script, <