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 58 lines (43 sloc) 1.811 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 46 47 48 49 50 51 52 53 54 55 56 57
use v6;

use Test;

# L<S02/Arrays/As with Perl 5 array interpolation>
# See L<http://www.nntp.perl.org/group/perl.perl6.language/23224>:
# In a private conversation with Larry this afternoon, he said that by
# default "$foo" and ~$foo and $foo.as(Str) all give the same result
# (assuming scalar context, etc.). And that "@foo[]" and ~[at]foo and
# @foo.as(Str) are the same as join(' ', @foo) where join is effectively:

plan 12;

{
  my @array = <a b c d>;

  is ~@array, "a b c d",
    "arrays whose elements don't contain whitespace stringify correctly (1)";
  is "@array[]", "a b c d", "arrays whose elements don't contain whitespace stringify correctly (2)";
  is "@array.[]", "a b c d", '@array.[] interpolates';
  is "@array", "@array", '@array (without brackets) doesnt interpolate';
}

{
  my @array = <a b c d>;
  push @array, [<e f g h>];

  is ~@array, "a b c d e f g h",
    "arrays with embedded array references stringify correctly (1)";
  is "@array[]", "a b c d e f g h", "arrays with embedded array references stringify correctly (2)";
}

{
  my @array = ("a", "b ", "c");

  is ~@array, "a b c",
    "array whose elements do contain whitespace stringify correctly (1-1)";
  is "@array[]", "a b c", "array whose elements do contain whitespace stringify correctly (1-2)";
}

{
  my @array = ("a\t", "b ", "c");

  is ~@array, "a\t b c",
    "array whose elements do contain whitespace stringify correctly (2-1)";
  is "@array[]", "a\t b c", "array whose elements do contain whitespace stringify correctly (2-2)";
}

{
  my @array = ("a\t", " b ", "c");

  is ~@array, "a\t b c",
    "array whose elements do contain whitespace stringify correctly (3-1)";
  is "@array[]", "a\t b c", "array whose elements do contain whitespace stringify correctly (3-2)";
}

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