Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some floats with many digits don't survive roundtrip with .perl #3564

Closed
p6rt opened this issue Oct 24, 2014 · 8 comments
Closed

some floats with many digits don't survive roundtrip with .perl #3564

p6rt opened this issue Oct 24, 2014 · 8 comments
Labels
JVM Related to Rakudo-JVM

Comments

@p6rt
Copy link

p6rt commented Oct 24, 2014

Migrated from rt.perl.org#123048 (status was 'resolved')

Searchable as RT123048$

@p6rt
Copy link
Author

p6rt commented Oct 24, 2014

From @usev6

Today I got a failure while spectesting for rakudo.jvm​:

Failure summary​:
S02-names-vars/perl.rakudo.jvm 84 - .perl on user-defined type roundtrips okay

I investigated and the test in question runs fine most of the time but fails only once in a while. The test in question is on the last line of following code​:

# RT #​61918
#?niecza skip ">>>Stub code executed"
{
  class RT61918 {
  has $.inst is rw;
  has $!priv;
  has $.string = 'krach';

  method init {
  $.inst = [ rand, rand ];
  $!priv = [ rand, rand ].perl;
  }
  }

  my $t1 = RT61918.new();
  my $t1_new = $t1.perl;
  $t1.init;
  my $t1_init = $t1.perl;

  ok $t1_new ne $t1_init, 'changing object changes .perl output';

  # TODO​: more tests that show EVAL($t1_init) has the same guts as $t1.
  ok $t1_new ~~ /<< krach >>/, 'attribute value appears in .perl output';

  # RT #​62002 -- validity of default .perl
  my $t2_init = EVAL($t1_init).perl;
  is $t1_init, $t2_init, '.perl on user-defined type roundtrips okay';
}

To me it looks as if "rand" (in method "init") sporadically generates values that don't survive the roundtrip on JVM. I tried to reproduce the failure and eventually came up with an example​:

$ perl6-j -e 'my $a = 0.219947518065601987e0; say $a.perl; say EVAL($a.perl).perl'
0.21994751806560198e0
0.219947518065602e0

Moar and Parrot return less decimal places for $a.perl already​:

$ perl6-m -e 'my $a = 0.219947518065601987e0; say $a.perl; say EVAL($a.perl).perl'
0.219947518065602e0
0.219947518065602e0

So .perl behaves differently in this case on JVM and Moar/Parrot.

Maybe I'm looking in the wrong direction, but the test failure should not occur. I'm going to fudge the test ('skip') for rakudo.jvm.

@p6rt
Copy link
Author

p6rt commented Oct 27, 2014

From @moritz

Hi,

On 10/24/2014 06​:16 PM, Christian Bartolomaeus (via RT) wrote​:

# New Ticket Created by Christian Bartolomaeus
# Please include the string​: [perl #​123048]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123048 >

Today I got a failure while spectesting for rakudo.jvm​:

Failure summary​:
S02-names-vars/perl.rakudo.jvm 84 - .perl on user-defined type roundtrips okay

I investigated and the test in question runs fine most of the time but fails only once in a while. The test in question is on the last line of following code​:

# RT #​61918
#?niecza skip ">>>Stub code executed"
{
class RT61918 {
has $.inst is rw;
has $!priv;
has $.string = 'krach';

     method init \{
         $\.inst = \[ rand, rand \];
         $\!priv = \[ rand, rand \]\.perl;
     \}
 \}

 my $t1 = RT61918\.new\(\);
 my $t1\_new = $t1\.perl;
 $t1\.init;
 my $t1\_init = $t1\.perl;

 ok $t1\_new ne $t1\_init, 'changing object changes \.perl output';

 \# TODO&#8203;: more tests that show EVAL\($t1\_init\) has the same guts as $t1\.
 ok $t1\_new ~~ /\<\< krach >>/, 'attribute value appears in \.perl output';

 \# RT #&#8203;62002 \-\- validity of default \.perl
 my $t2\_init = EVAL\($t1\_init\)\.perl;
 is $t1\_init, $t2\_init, '\.perl on user\-defined type roundtrips okay';

}

To me it looks as if "rand" (in method "init") sporadically generates values that don't survive the roundtrip on JVM. I tried to reproduce the failure and eventually came up with an example​:

$ perl6-j -e 'my $a = 0.219947518065601987e0; say $a.perl; say EVAL($a.perl).perl'
0.21994751806560198e0
0.219947518065602e0

Moar and Parrot return less decimal places for $a.perl already​:

$ perl6-m -e 'my $a = 0.219947518065601987e0; say $a.perl; say EVAL($a.perl).perl'
0.219947518065602e0
0.219947518065602e0

So .perl behaves differently in this case on JVM and Moar/Parrot.

Maybe I'm looking in the wrong direction, but the test failure should not occur. I'm going to fudge the test ('skip') for rakudo.jvm.

The better approach is to isolate the user-defined type roundtrips test
from roundtripping floats with many digits.

So rather remove the rand's, replace them by fixed values, and have
separate tests for round-tripping 0.21994751806560198e0. Then fudge that
test for JVM as needed.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Oct 27, 2014

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 27, 2014

From @usev6

Hi,

On Mon Oct 27 02​:19​:48 2014, moritz wrote​:

[...]
To me it looks as if "rand" (in method "init") sporadically generates
values that don't survive the roundtrip on JVM. I tried to reproduce
the failure and eventually came up with an example​:

$ perl6-j -e 'my $a = 0.219947518065601987e0; say $a.perl; say
EVAL($a.perl).perl'
0.21994751806560198e0
0.219947518065602e0

Moar and Parrot return less decimal places for $a.perl already​:

$ perl6-m -e 'my $a = 0.219947518065601987e0; say $a.perl; say
EVAL($a.perl).perl'
0.219947518065602e0
0.219947518065602e0

So .perl behaves differently in this case on JVM and Moar/Parrot.

Maybe I'm looking in the wrong direction, but the test failure should
not occur. I'm going to fudge the test ('skip') for rakudo.jvm.

The better approach is to isolate the user-defined type roundtrips
test from roundtripping floats with many digits.

So rather remove the rand's, replace them by fixed values, and have
separate tests for round-tripping 0.21994751806560198e0. Then fudge
that test for JVM as needed.

Cheers,
Moritz

I did that with commit Raku/roast@2cba5c0ede
I'm gonna change the subject of this ticket accordingly.

Thanks for the suggestion!

Cheers,
Christian

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 27, 2014

From @usev6

Hi,

On Mon Oct 27 02​:19​:48 2014, moritz wrote​:

[...]
To me it looks as if "rand" (in method "init") sporadically generates
values that don't survive the roundtrip on JVM. I tried to reproduce
the failure and eventually came up with an example​:

$ perl6-j -e 'my $a = 0.219947518065601987e0; say $a.perl; say
EVAL($a.perl).perl'
0.21994751806560198e0
0.219947518065602e0

Moar and Parrot return less decimal places for $a.perl already​:

$ perl6-m -e 'my $a = 0.219947518065601987e0; say $a.perl; say
EVAL($a.perl).perl'
0.219947518065602e0
0.219947518065602e0

So .perl behaves differently in this case on JVM and Moar/Parrot.

Maybe I'm looking in the wrong direction, but the test failure should
not occur. I'm going to fudge the test ('skip') for rakudo.jvm.

The better approach is to isolate the user-defined type roundtrips
test from roundtripping floats with many digits.

So rather remove the rand's, replace them by fixed values, and have
separate tests for round-tripping 0.21994751806560198e0. Then fudge
that test for JVM as needed.

Cheers,
Moritz

I did that with commit Raku/roast@2cba5c0ede
I'm gonna change the subject of this ticket accordingly.

Thanks for the suggestion!

Cheers,
Christian

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

From @usev6

The test in S02-names-vars/perl.t is passing now. I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

From @usev6

The test in S02-names-vars/perl.t is passing now. I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

@usev6 - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 10, 2017
@p6rt p6rt added the JVM Related to Rakudo-JVM label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JVM Related to Rakudo-JVM
Projects
None yet
Development

No branches or pull requests

1 participant