Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (20 sloc) 0.778 kb
b254a8bc » Auzon
2008-05-27 [gsoc_spectest] Test reorganization.
1 use v6;
2
3 use Test;
4
efc7dbc0 » lwall
2008-07-19 [STD] implement :P5
5 =begin comment
b254a8bc » Auzon
2008-05-27 [gsoc_spectest] Test reorganization.
6
7 This tests the &?ROUTINE magical value
8
efc7dbc0 » lwall
2008-07-19 [STD] implement :P5
9 =end comment
b254a8bc » Auzon
2008-05-27 [gsoc_spectest] Test reorganization.
10
11 plan 4;
12
13 # L<S06/The C<&?ROUTINE> object>
14 # L<S02/Names/Which routine am I in>
15 sub factorial { @_[0] < 2 ?? 1 !! @_[0] * &?ROUTINE(@_[0] - 1) }
16
17 my $result1 = factorial(3);
18 is($result1, 6, 'the &?ROUTINE magical works correctly');
19
20 my $factorial = sub { @_[0] < 2 ?? 1 !! @_[0] * &?ROUTINE(@_[0] - 1) };
21 my $result2 = $factorial(3);
22 is($result2, 6, 'the &?ROUTINE magical works correctly in anon-subs');
23
24 sub postfix:<!!!> (Int $n) { $n < 2 ?? 1 !! $n * &?ROUTINE($n - 1) }
25 my $result3 = 3!!!;
26 is($result3, 6, 'the &?ROUTINE magical works correctly in overloaded operators' );
27
28 my $baz = try { &?ROUTINE };
29 ok(defined($baz), '&?ROUTINE is defined for the MAIN routine');
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
30
31 # vim: ft=perl6
Something went wrong with that request. Please try again.