Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (34 sloc) 1.194 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
use v6;
use Test;

# L<S32::Str/Str/=item flip>

plan 13;

# As a function :
is( flip('Pugs'), 'sguP', "as a function");

# As a method :
is( "".flip, "", "empty string" );
is( 'Hello World !'.flip, '! dlroW olleH', "literal" );

# On a variable ?
my Str $a = 'Hello World !';
is( $a.flip, '! dlroW olleH', "with a Str variable" );
is( $a, 'Hello World !', "flip should not be in-place" );
is( $a .= flip, '! dlroW olleH', "after a .=flip" );

# Multiple iterations (don't work in 6.2.12) :
is( 'Hello World !'.flip.flip, 'Hello World !',
        "two flip in a row." );

# flip with unicode :
is( '䀻«'.flip, '«»€ä', "some unicode characters" );

#?niecza 2 todo 'graphemes not implemented'
#?rakudo 2 todo 'graphemes not implemented'
#?pugs 2 skip 'graphemes not implemented'
is( "a\c[COMBINING DIAERESIS]b".flip, 'bä', "grapheme precomposed" );
is( "a\c[COMBINING DOT ABOVE, COMBINING DOT BELOW]b".flip,
    "ba\c[COMBINING DOT ABOVE, COMBINING DOT BELOW]",
    "grapheme without precomposed");

is 234.flip, '432', '.flip on non-string';
is flip(123), '321', 'flip() on non-strings';
{
    my $x = 'abc';
    $x.=flip;
    is $x, 'cba', 'in-place flip';
}


# vim: ft=perl6
Something went wrong with that request. Please try again.