Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (39 sloc) 1.536 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
a66e3be [t/spec] unfudge two passing tests for rakudo
moritz authored
40 #?rakudo 2 todo 'RT 65128'
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
41 eval_lives_ok
42 'my Num List sub f () { return () }; f()',
43 'return of empty list should live';
44 is eval('my Num List sub f () { return () }; (f(), "a")'), ['a'],
45 'return of empty list should be empty list';
46
47 eval_dies_ok
48 'my Num List sub f () { ("A") }; f()',
49 'implicit return of list with wrong type dies';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
50
51 # vim: ft=perl6
Something went wrong with that request. Please try again.