root/t/syntax/list_quote_junction.t

Revision 21719, 1.2 kB (checked in by lwall, 5 months ago)

[STD] detect obsolete use of =cut
[t/*.t] delete obsolete uses of =cut

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5=begin kwid
6
7= DESCRIPTION
8
9Tests that the C<any()> and list quoting constructs
10play well together and match well.
11
12The following should match:
13
14  "foo" ~~ any <foo bar baz>
15  "foo" ~~ any(<foo bar baz>)
16  "bar" ~~ any <foo bar baz>
17  "bar" ~~ any(<foo bar baz>)
18
19The following should not match:
20
21  "fo"      ~~ any <foo bar baz>
22  "oo"      ~~ any <foo bar baz>
23  "bar b"   ~~ any <foo bar baz>
24  "bar baz" ~~ any(<foo bar baz>)
25
26Note: There is a small caveat regarding the convenient
27C<< any <foo bar baz> >> syntax, if not used with parentheses:
28
29  say( any <foo bar baz>,"Hello World")
30
31is different from
32
33  say( (any <foo bar baz>), "Hello World")
34
35=end kwid
36
37my @matching_strings = <foo bar>;
38my @nonmatching_strings = ('fo','foo ', 'foo bar baz', 'oo', 'bar b', 'bar baz');
39
40plan ((+@matching_strings+@nonmatching_strings)*2);
41
42for @matching_strings -> $str {
43  ok( $str ~~ (any <foo bar baz>), "'$str' matches any <foo bar baz>" );
44  ok( $str ~~ any(<foo bar baz>), "'$str' matches any(<foo bar baz>)" );
45};
46
47for @nonmatching_strings -> $str {
48  ok( ($str !~~ any <foo bar baz>), "'$str' does not match any <foo bar baz>" );
49  ok( $str !~~ any(<foo bar baz>), "'$str' does not match any(<foo bar baz>)" );
50};
Note: See TracBrowser for help on using the browser.