Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 69 lines (54 sloc) 1.476 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])';
f3b94f9 [t/spec] test for RT #74336
moritz authored
17 #?rakudo skip 'bogus error message'
5309a5f [t/spec] add tests for RT #60404
moritz authored
18 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
19 is count((1, 2, 3)), 3, 'count((1, 2, 3))';
20
21 sub count2($a) {
22 my $x = 0;
23 $x++ for $a;
24 return $x;
25 }
26
27 is count2((1,2,3)), 1, 'count2((1,2,3))';
5309a5f [t/spec] add tests for RT #60404
moritz authored
28 }
29
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
30 {
31 sub pa(@a) { @a.WHAT; }
32 my @b = 2, 3;
ccbeedd [t/spec]: Use isa_ok instead of WHAT to test types.
pmichaud authored
33 isa_ok pa(@b), Array, 'basic array type sanity';
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
34 dies_ok { pa(3) }, 'non-slurpy array does not take a single Int';
35
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
36 sub ph(%h) { 1 } #OK not used
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
37 dies_ok { ph(3) }, 'an Int is not a Hash';
2c5007f [t/spec] test for RT #62172
moritz authored
38 }
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
39
2c5007f [t/spec] test for RT #62172
moritz authored
40 # this used to be a rakudobug, RT #62172
41 {
42 my @a = 1..8;
43 sub t1(@a) { return +@a };
44 sub t2(@a) { return t1(@a) };
45 is t2(@a), 8, 'can pass arrays through multiple subs';
785f27d [t/spec] more unfudging, and add tests to passing-arrays.t
moritz authored
46 }
681c0b6 [t] merge passig-arrays-to-functions.t into passing-arrays.t
moritz authored
47
48 {
49 sub test_two_array(@a,@b)
50 {
51 return @a[0] + @b[0];
52 }
53
54 is(test_two_array([100,5],[20,300]), 120,
55 "Passing array references to functions accepting arrays works.");
56 }
31d034d [t/spec] test for RT #67876
moritz authored
57
58 # A Rakudo regression
59
60 {
8dc7d4b [t/spec] mark various tests that intentionally declare things that are n...
lwall authored
61 sub ro_a(@a) { }; #OK not used
31d034d [t/spec] test for RT #67876
moritz authored
62 sub ro_b(@a) { ro_a(@a) };
63 my @x = 1, 2, 4;
64 lives_ok { ro_b(@x) }, 'can pass parameter Array on to next function';
65 lives_ok { @x = 5, 6 }, '... and that did not make the caller Array ro';
66 }
67
68 # vim: ft=perl6
Something went wrong with that request. Please try again.