1112163Sdas#!./perl
2112163Sdas
3112163Sdasuse strict;
4112163Sdasuse warnings;
5227753Stheraven
6227753Stheravenuse Sub::Util qw( prototype set_prototype );
7227753Stheravenuse Test::More tests => 13;
8227753Stheraven
9227753Stheravensub f { }
10112163Sdasis( prototype('f'), undef, 'no prototype');
11112163Sdasis( CORE::prototype('f'), undef, 'no prototype from CORE');
12112163Sdas
13112163Sdasmy $r = set_prototype('$', \&f);
14112163Sdasis( prototype('f'), '$', 'prototype');
15112163Sdasis( CORE::prototype('f'), '$', 'prototype from CORE');
16112163Sdasis( $r,   \&f, 'return value');
17112163Sdas
18112163Sdasset_prototype(undef, \&f);
19112163Sdasis( prototype('f'), undef, 'remove prototype');
20112163Sdas
21112163Sdasset_prototype('', \&f);
22112163Sdasis( prototype('f'), '', 'empty prototype');
23112163Sdas
24112163Sdassub g (@) { }
25112163Sdasis( prototype('g'), '@', '@ prototype');
26112163Sdas
27112163Sdasset_prototype(undef, \&g);
28112163Sdasis( prototype('g'), undef, 'remove prototype');
29112163Sdas
30112163Sdassub stub;
31112163Sdasis( prototype('stub'), undef, 'non existing sub');
32112163Sdas
33112163Sdasset_prototype('$$$', \&stub);
34112163Sdasis( prototype('stub'), '$$$', 'change non existing sub');
35112163Sdas
36112163Sdassub f_decl ($$$$);
37112163Sdasis( prototype('f_decl'), '$$$$', 'forward declaration');
38112163Sdas
39112163Sdasset_prototype('\%', \&f_decl);
40112163Sdasis( prototype('f_decl'), '\%', 'change forward declaration');
41112163Sdas