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