# New Ticket Created by  "Jonathan Leto" 
# Please include the string:  [perl #57316]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57316 >


Howdy folks,

I have attached a diff which includes a patch to is_approx() in Test.pm
which prints out debugging information to STDOUT when is_approx() fails. It
seems to be borking on subtracting complex numbers.

This generates the following trace output when I run

../../parrot perl6.pbc log10.t

6309 new P25, "Perl6Scalar"           P25=PMCNULL
  6312 find_lex P8, "$got"              P8=PMCNULL
  6315 unless_null P8, 6                P8=Float=PMC(0xb6c5eb38)
  6321 find_lex P10, "$expected"        P10=PMCNULL
  6324 unless_null P10, 6               P10=Complex=PMC(0xb6c5ea58)
  6330 set_args PC16 (2), P8, P10
PC16=FixedIntegerArray=PMC(0x839403c) P8=Float=PMC(0xb6c5eb38)
P10=Complex=PMC(0xb6c5ea58)
  6334 find_sub_not_null P30, "infix:-" P30=PMCNULL
  6337 get_results PC18 (1), P12
PC18=FixedIntegerArray=PMC(0x8394020) P12=PMCNULL
  6340 invokecc P30                     P30=MultiSub=PMC(0x8214548)
  2226 get_params PC30 (2), P0, P1
PC30=FixedIntegerArray=PMC(0x8218464) P0=PMCNULL P1=PMCNULL
  2230 new P2, "Complex"                P2=PMCNULL
  2233 subtract P2, P0, P1              P2=Complex=PMC(0xb6c5da98: 0+0i)
P0=Float=PMC(0xb6c5eb38) P1=Complex=PMC(0xb6c5ea58)
set_number_keyed() not implemented in class 'Float'
current instr.: 'is_approx' pc 6044 (EVAL_20:2140)
called from Sub '_block11' pc 211 (EVAL_11:40)
called from Sub 'parrot;PCT::HLLCompiler;eval' pc 806
(src/PCT/HLLCompiler.pir:481)
called from Sub 'parrot;PCT::HLLCompiler;evalfiles' pc 1088
(src/PCT/HLLCompiler.pir:610)
called from Sub 'parrot;PCT::HLLCompiler;command_line' pc 1267
(src/PCT/HLLCompiler.pir:699)
called from Sub 'parrot;Perl6::Compiler;main' pc 14567 (perl6.pir:172)

If anyone can point me in the right direction about what in the malarky is
going on, that would be awesome.

Cheers,

-- 
[---------------------]
Jonathan Leto
[EMAIL PROTECTED]
Index: log10.t
===================================================================
--- log10.t	(revision 0)
+++ log10.t	(revision 0)
@@ -0,0 +1,7 @@
+use v6;
+use Test;
+plan 1;
+
+parrot_trace(1);
+
+is_approx(log10(-10 + 0i), 1 + 1i * pi / log(10), "got the log10 of -10");
Index: Test.pm
===================================================================
--- Test.pm	(revision 29781)
+++ Test.pm	(working copy)
@@ -61,13 +61,23 @@
 
 multi sub isnt($got, $expected) { isnt($got, $expected, ''); }
 
-multi sub is_approx($got, $expected, $desc) {
-    my $test = abs($got - $expected) <= 0.00001;
+multi sub is_approx($got, $expected, $desc, $eps) {
+    say "4 arg";
+    my $residual = abs($got - $expected);
+    my $test = $residual <= $eps;
+    unless $test {
+        print sprintf("got:\t %.8f differs from\nexpected: %.8f by\nresidual: %.8f\n", $got, $expected, $residual);
+    }
     proclaim($test, $desc);
 }
 
-multi sub is_approx($got, $expected) { is_approx($got, $expected, ''); }
+multi sub is_approx($got, $expected, $desc) {
+    say "3 arg";
+    is_approx($got, $expected, $desc, 0.00001);
+}
 
+multi sub is_approx($got, $expected) { say "2 arg"; is_approx($got, $expected, '', 0.00001); }
+
 multi sub todo($reason, $count) {
     $todo_upto_test_num = $num_of_tests_run + $count;
     $todo_reason = '# TODO ' ~ $reason;

Reply via email to