Let's say I have,
use experimental 'signatures';
sub foo ($bar) { return 0 };
Now if I call it without the right arity, I'll get an error.
# Too few arguments for subroutine 'main::foo'
foo()
# Too many arguments for subroutine 'main::foo'
foo(1,2);
However, how can I test that. Let's say I want to make sure that someone implements a package Bar
such that its function foo
requires one argument. Is there a way to do this without running that code.
I see this question as different from my other question because even if I can't read the signature through some kind of Perl API, there may be a way to test that a subroutine is declared with a specific signature? An answer to that question can be used to answer this one. But an answer to this question may not answer that one.
From irc.freenode.net/#perl,
15:06 < Grinnz> EvanCarroll: yes, there's no way to do that either
He's speaking in reference to an earlier question about getting the signature of a function with an API.