Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (55 sloc) 1.484 kb
5309a5f [t/spec] add tests for RT #60404
moritz authored
1 use v6;
2 use Test;
0477942 some more smartlinks updated
szabgab authored
3
4 # L<S06/Parameters and arguments>
5 # TODO: better smart-linking
6
31d034d [t/spec] test for RT #67876
moritz authored
7 plan 11;
5309a5f [t/spec] add tests for RT #60404
moritz authored
8
9 {
10 sub count(@a) {
11 my $x = 0;
12 $x++ for @a;
13 return $x;
14 }
15
14a452f [t/spec]: Fix/unfudge tests in passing-arrays.t .
pmichaud authored
16 is count([1, 2, 3, 4]), 4, 'count([1, 2, 3, 4])';
5309a5f [t/spec] add tests for RT #60404
moritz authored
17 is count(my @b = 1, 2, 3, 4), 4, 'count(my @b = 1, 2, 3)';
1216c98 [t/spec] Another test for passing with lists/scalar interaction that Rak...
jnthn authored
18 is count((1, 2, 3)), 3, 'count((1, 2, 3))';
19
20 sub count2($a) {
21 my $x = 0;
22 $x++ for $a;
23 return $x;
24 }
25
26 is count2((1,2,3)), 1, 'count2((1,2,3))';
5309a5f [t/spec] add tests for RT #60404
moritz authored
27 }
28
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
29 {
30 sub pa(@a) { @a.WHAT; }
31 my @b = 2, 3;
ccbeedd [t/spec]: Use isa_ok instead of WHAT to test types.
pmichaud authored
32 isa_ok pa(@b), Array, 'basic array type sanity';
77ec25f @coke pugs fudge
coke authored
33 #?pugs todo
a238bb3 @moritz remove bogus test
moritz authored
34 dies_ok { eval('pa(3)') }, 'non-slurpy array does not take a single Int';
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
35
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
36 sub ph(%h) { 1 } #OK not used
77ec25f @coke pugs fudge
coke authored
37 #?pugs todo
888689e @moritz small niecza fudging
moritz authored
38 dies_ok { eval('ph(3)') }, 'an Int is not a Hash';
2c5007f [t/spec] test for RT #62172
moritz authored
39 }
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
40
2c5007f [t/spec] test for RT #62172
moritz authored
41 # this used to be a rakudobug, RT #62172
42 {
43 my @a = 1..8;
44 sub t1(@a) { return +@a };
45 sub t2(@a) { return t1(@a) };
46 is t2(@a), 8, 'can pass arrays through multiple subs';
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
47 }
681c0b6 [t] merge passig-arrays-to-functions.t into passing-arrays.t
moritz authored
48
49 {
50 sub test_two_array(@a,@b)
51 {
52 return @a[0] + @b[0];
53 }
54
55 is(test_two_array([100,5],[20,300]), 120,
56 "Passing array references to functions accepting arrays works.");
57 }
31d034d [t/spec] test for RT #67876
moritz authored
58
59 # A Rakudo regression
60
61 {
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
62 sub ro_a(@a) { }; #OK not used
31d034d [t/spec] test for RT #67876
moritz authored
63 sub ro_b(@a) { ro_a(@a) };
64 my @x = 1, 2, 4;
65 lives_ok { ro_b(@x) }, 'can pass parameter Array on to next function';
66 lives_ok { @x = 5, 6 }, '... and that did not make the caller Array ro';
67 }
68
69 # vim: ft=perl6
Something went wrong with that request. Please try again.