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

Using Parrot's Digest feature on a Str coming out of Str.split works differently from a Str that doesn't in Rakudo #1397

Closed
p6rt opened this issue Nov 11, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 11, 2009

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

Searchable as RT70415$

@p6rt
Copy link
Author

p6rt commented Nov 11, 2009

From @masak

$ cat bug
sub digest(Str $text) is export {
  my $binary = Q​:PIR {
  .local string text
  .local pmc digest

  # Input
  $P0 = find_lex '$text'
  text = $P0

  # Choose the right digest.
  $P1 = loadlib 'digest_group'
  digest = new 'SHA256'

  # Calculate the digest.
  digest.'Init'()
  digest.'Update'(text)
  $S0 = digest.'Final'()

  %r = box $S0
  };
  # Convert to hex.
  return [~] map { sprintf '%02x', .ord }, $binary.comb;
}

say digest('user_name=carl'.split("=")[1]);
say digest('carl');

$ perl6 bug
04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb
69bfe1e6e44821df7f8a0927bd7e61ef208fdb25deaa4353450bc3fb904abd52

@p6rt
Copy link
Author

p6rt commented Nov 11, 2009

From @masak

<moritz_> rakudo​: say 'user_name=carl'.split("=")[1].PARROT
<p6eval> rakudo 50e495​: String␤
<moritz_> rakudo​: say 'carl'.PARROT
<p6eval> rakudo 50e495​: Str␤
<moritz_> there you go.
* masak adds moritz_'s discovery to the ticket

@p6rt
Copy link
Author

p6rt commented Nov 11, 2009

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 11, 2009

From @moritz

Fixed in f87efac027edf84bff2b8578a9762ac8ab8b44ca, jnthn++

@p6rt
Copy link
Author

p6rt commented Nov 11, 2009

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

@p6rt p6rt closed this as completed Nov 11, 2009
@p6rt
Copy link
Author

p6rt commented Feb 2, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/integration/real-strings.t

commit b3197187a377336d0a0ce53ee22d1cc8b1136433
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sat Nov 14 19​:47​:08 2009 +0000

  [t/spec] test for RT #​70415, split() should return real strings
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;29087 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/integration/real-strings.t b/t/spec/integration/real-strings.t
index 5b14597..9707aee 100644
--- a/t/spec/integration/real-strings.t
+++ b/t/spec/integration/real-strings.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 11;
+plan *;
 
 # Rakudo had a regression that
 # string returned from regexes were Parrot strings, not Perl 6 strings.
@@ -20,6 +20,8 @@ plan 11;
        'Still works with strings returned from split() (lives)';
     is $x.trans(['a'] => ['b']), 'b',
        'Still works with strings returned from split() (result)';
+    $x = 'abc'.split('b').[0];
+    is $x.trans(['a'] => ['b']), 'b', 'same for split(Str)';
 }
 
 dies_ok { for "a b c".split(/\s/) -> $foo { $foo = $foo; } }, 'variables returned from split and passed to pointy block are still ro';
@@ -56,4 +58,6 @@ is "helo".lc.trans(("aeiou" => "AEIOU")),   'hElO', '.flip.trans (RT 66300)';
     is $x, +%*VM.keys, '%*VM.kv is self-consistent';
 }
 
+done_testing;
+
 # vim: ft=perl6

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant