Move Memoize from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Memoize / t / prototype.t
CommitLineData
a0cb3900 1#!/usr/bin/perl
2
484fdf61 3use lib '..';
a0cb3900 4use Memoize;
5$EXPECTED_WARNING = '(no warning expected)';
6
7
8print "1..4\n";
9
10sub q1 ($) { $_[0] + 1 }
11sub q2 () { time }
12sub q3 { join "--", @_ }
13
14$SIG{__WARN__} = \&handle_warnings;
15
16$RES = 'ok';
17memoize 'q1';
18print "$RES 1\n";
19
20$RES = 'ok';
21memoize 'q2';
22print "$RES 2\n";
23
24$RES = 'ok';
25memoize 'q3';
26print "$RES 3\n";
27
28# Let's see if the prototype is actually honored
29@q = (1..5);
30$r = q1(@q);
31print (($r == 6) ? '' : 'not ', "ok 4\n");
32
33sub handle_warnings {
34 print $_[0];
35 $RES = 'not ok' unless $_[0] eq $EXPECTED_WARNING;
36}