1#!/usr/bin/perl 2 3use lib '..'; 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} 37