Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (46 sloc) 1.657 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 }
3d8ce31 [t/spec] Fudge for ng1.
colomon authored
12
e50fd6e [t/spec] numerous unfudges for rakudo
moritz authored
13 eval_dies_ok 'myNamedStr()', 'Correct : lexical named sub myNamedStr() should NOT BE available outside its scope';
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
14
15 {
16 my Int sub myNamedInt() { return 55 };
17 is myNamedInt(), 55, 'lexical named sub() return Int';
18 }
39a7b59 [t/spec] fudged scoped-named-subs.t for Rakudo
moritz authored
19 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
20
21
22 #packge-scoped named subs
23
24 {
25 our Str sub ourNamedStr() { return 'string' };
26 is ourNamedStr(), 'string', 'package-scoped named sub() return Str';
27 }
abc9cbd @coke pugs fudge
coke authored
28 #?pugs skip 'Cannot use Undef as a Code object'
498ffb2 @jnthn Bring a test up to latest spec on our names.
jnthn authored
29 {
30 our &ourNamedStr;
31 is ourNamedStr(), 'string', 'Correct : package-scoped named sub ourNamedStr() should BE available in the whole package';
32 }
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
33
34 {
35 our Int sub ourNamedInt() { return 55 };
36 is ourNamedInt(), 55, 'package-scoped named sub() return Int';
37 }
abc9cbd @coke pugs fudge
coke authored
38 #?pugs skip 'Cannot use Undef as a Code object'
498ffb2 @jnthn Bring a test up to latest spec on our names.
jnthn authored
39 {
40 our &ourNamedInt;
41 is ourNamedInt(), 55, 'Correct : package-scoped named sub ourNamedInt() should BE available in the whole package';
42 }
5579397 [t] move scoped_named_subs.t to spec/, remove an obsolete test
moritz authored
43
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
44 eval_dies_ok
45 'my Num List sub f () { return ("A") }; f()',
46 'Return of list with wrong type dies';
47
48 eval_lives_ok
001e798 @moritz &eval does not catch exceptions.
moritz authored
49 'my List sub f () { return () }; f()',
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
50 'return of empty list should live';
001e798 @moritz &eval does not catch exceptions.
moritz authored
51 is eval('my List sub f () { return () }; (f(), "a")'), ['a'],
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
52 'return of empty list should be empty list';
53
54 eval_dies_ok
55 'my Num List sub f () { ("A") }; f()',
56 'implicit return of list with wrong type dies';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
57
58 # vim: ft=perl6
Something went wrong with that request. Please try again.