Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (39 sloc) 1.537 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 }
28 is ourNamedStr(), 'string', 'Correct : package-scoped named sub ourNamedStr() should BE available in the whole package';
29
30
31 {
32 our Int sub ourNamedInt() { return 55 };
33 is ourNamedInt(), 55, 'package-scoped named sub() return Int';
34 }
35 is ourNamedInt(), 55, 'Correct : package-scoped named sub ourNamedInt() should BE available in the whole package';
36
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
37 eval_dies_ok
38 'my Num List sub f () { return ("A") }; f()',
39 'Return of list with wrong type dies';
40
a66e3be [t/spec] unfudge two passing tests for rakudo
moritz authored
41 #?rakudo 2 todo 'RT 65128'
cd128b1 my Num List sub should allow return of empty list RT #65128
ron authored
42 eval_lives_ok
43 'my Num List sub f () { return () }; f()',
44 'return of empty list should live';
45 is eval('my Num List sub f () { return () }; (f(), "a")'), ['a'],
46 'return of empty list should be empty list';
47
48 eval_dies_ok
49 'my Num List sub f () { ("A") }; f()',
50 'implicit return of list with wrong type dies';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
51
52 # vim: ft=perl6
Something went wrong with that request. Please try again.