root/t/junction/junction_any_pick.t

Revision 21719, 0.9 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
5plan 2;
6
7=begin pod
8
9This code shows the bug:
10    pugs -e 'my @a = ("one", "two", "three"); sub foo (@a) { my $t = any(@a).pick(); say WHAT($t); say $t }; foo(@a)'
11
12prints out:
13    Array
14    one two three
15
16But this code:
17    pugs -e 'my @a = ("one", "two", "three"); my $t = any(@a).pick(); say WHAT($t); say $t'
18
19prints out:
20    Str
21    ("one" "two" or "three")
22   
23And this code:
24    pugs -e 'sub foo2 { any(1 .. 10).pick() }; say WHAT(foo2());'
25
26prints out:
27    Int
28
29    sub foo (@a) { my $t = any(@a).pick(); say WHAT($t); say $t }; foo(1..3)
30succeeds:
31    Int
32    2
33
34    my @b = (1..3); sub foo (@a) { my $t = any(@a).pick(); say WHAT($t); say $t }; foo(*@b);
35succeeds:
36    Int
37    3
38
39=end pod
40
41my @test_string = ("one", "two", "three");
42my @test_int = 1 .. 10;
43
44sub foo (@a) { any(@a).pick() }
45
46isa_ok(foo(@test_string), 'Str');
47isa_ok(foo(@test_int), 'Int');
Note: See TracBrowser for help on using the browser.