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 55 lines (35 sloc) 1.293 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
use v6;

use Test;

=begin kwid

= DESCRIPTION

Tests that the C<any()> and list quoting constructs
play well together and match well.

The following should match:

  "foo" ~~ any <foo bar baz>
  "foo" ~~ any(<foo bar baz>)
  "bar" ~~ any <foo bar baz>
  "bar" ~~ any(<foo bar baz>)

The following should not match:

  "fo" ~~ any <foo bar baz>
  "oo" ~~ any <foo bar baz>
  "bar b" ~~ any <foo bar baz>
  "bar baz" ~~ any(<foo bar baz>)

Note: There is a small caveat regarding the convenient
C<< any <foo bar baz> >> syntax, if not used with parentheses:

  say( any <foo bar baz>,"Hello World")

is different from

  say( (any <foo bar baz>), "Hello World")

=end kwid

# L<S03/Changes to Perl 5 operators/"Note that Perl 6 is making a consistent">

my @matching_strings = <foo bar>;
my @nonmatching_strings = ('fo','foo ', 'foo bar baz', 'oo', 'bar b', 'bar baz');

plan 16;

for @matching_strings -> $str {
  ok( $str ~~ (any <foo bar baz>), "'$str' matches any <foo bar baz>" );
  ok( $str ~~ any(<foo bar baz>), "'$str' matches any(<foo bar baz>)" );
};

for @nonmatching_strings -> $str {
  ok( ($str !~~ any <foo bar baz>), "'$str' does not match any <foo bar baz>" );
  ok( $str !~~ any(<foo bar baz>), "'$str' does not match any(<foo bar baz>)" );
};

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