Changeset 22544

Show
Ignore:
Timestamp:
10/08/08 21:57:50 (6 weeks ago)
Author:
moritz
Message:

[t/spec] tests for Str.trans with regex and closures. One failing on rakudo
(RT #59730).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • t/spec/S05-transliteration/with-closure.t

    r22488 r22544  
    11use v6; 
    22use Test; 
    3 plan 10; 
     3plan 14; 
    44 
    55# L<S05/Transliteration/"If the right side of the arrow is a closure"> 
    6  
    7 { 
    86 
    97my $x = 0; 
     
    3634is $y, 2,                            'Closure invoked twice (once per replacement)'; 
    3735 
    38 }; 
     36{ 
     37    # combined regex / closure 
     38    my $count = 0; 
     39    is 'hello'.trans(/l/ => { ++$count }), 'he12o', 'regex and closure mix'; 
     40    is 'hello'.trans(/l/ => { $_ x 2 }), 'hellllo', 'regex and closure mix (with $/ as topic)'; 
     41    is 'hello'.trans(/(l)/ => { $_[0] x 2 }), 'hellllo', 'regex and closure mix (with $/ as topic and capture)'; 
     42} 
     43 
     44#?rakudo todo 'Str.trans with regex+closure, RT #59730' 
     45is 'hello'.trans(/(l)/ => { $_[0].ord }), 'he108108o', 'capturing regex + closure with .ord on $_';