Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (41 sloc) 1.53 kb
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
1 use v6;
2 use Test;
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
3 plan 12;
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
4
5 # L<S06/Named subroutines>
6
7 #first lets test lexical named subs
8 {
9 my Str sub myNamedStr() { return 'string' };
10 is myNamedStr(), 'string', 'lexical named sub() return Str';
11 }
12 is eval('myNamedStr()'), '', 'Correct : lexical named sub myNamedStr() should NOT BE available outside its scope';
13
14 {
15 my Int sub myNamedInt() { return 55 };
16 is myNamedInt(), 55, 'lexical named sub() return Int';
17 }
39a7b59 [t/spec] fudged scoped-named-subs.t for Rakudo
moritz authored
18 eval_dies_ok('myNamedInt()', 'Correct : lexical named sub myNamedInt() should NOT BE available outside its scope');
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
19
20
21 #packge-scoped named subs
22
23 {
24 our Str sub ourNamedStr() { return 'string' };
25 is ourNamedStr(), 'string', 'package-scoped named sub() return Str';
26 }
27 is ourNamedStr(), 'string', 'Correct : package-scoped named sub ourNamedStr() should BE available in the whole package';
28
29
30 {
31 our Int sub ourNamedInt() { return 55 };
32 is ourNamedInt(), 55, 'package-scoped named sub() return Int';
33 }
34 is ourNamedInt(), 55, 'Correct : package-scoped named sub ourNamedInt() should BE available in the whole package';
35
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
36 eval_dies_ok
37 'my Num List sub f () { return ("A") }; f()',
38 'Return of list with wrong type dies';
39
40 #?rakudo todo 'RT 65128'
41 #?DOES 3
42 {
43 eval_lives_ok
44 'my Num List sub f () { return () }; f()',
45 'return of empty list should live';
46 is eval('my Num List sub f () { return () }; (f(), "a")'), ['a'],
47 'return of empty list should be empty list';
48
49 eval_dies_ok
50 'my Num List sub f () { ("A") }; f()',
51 'implicit return of list with wrong type dies';
52 }
Something went wrong with that request. Please try again.