X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftypes_custom.t;h=02e46fcbe940c7270ee4098cf504df54d7086344;hb=11305599a59b5a00d111f396f2b651577a90b80a;hp=df5c0285060c1d4c766d69afab98bd60e3d4714c;hpb=7193dffba45795c249b405f8636d644261380ff0;p=p5sagit%2FFunction-Parameters.git diff --git a/t/types_custom.t b/t/types_custom.t index df5c028..02e46fc 100644 --- a/t/types_custom.t +++ b/t/types_custom.t @@ -2,10 +2,13 @@ use warnings FATAL => 'all'; use strict; -use Test::More tests => 4; +use Test::More tests => 8; use Test::Fatal; use Function::Parameters qw(:strict); +use Function::Parameters { + def => { check_argument_count => 1 }, +}; { package MyTC; @@ -47,3 +50,12 @@ is foo(42, "hello"), "42/hello"; like exception { foo 41, "hello" }, qr{\bValidation failed for constraint 'even number' with value '41'}; like exception { foo 42, "1234567890~" }, qr{\bValidation failed for constraint 'short string' with value '1234567890~'}; like exception { foo 41, "1234567890~" }, qr{\bValidation failed for constraint 'even number' with value '41'}; + +def foo2((TEvenNum) $x, (TShortStr) $y) { + "$x/$y" +} + +is foo2(42, "hello"), "42/hello"; +like exception { foo2 41, "hello" }, qr{\bValidation failed for constraint 'even number' with value '41'}; +like exception { foo2 42, "1234567890~" }, qr{\bValidation failed for constraint 'short string' with value '1234567890~'}; +like exception { foo2 41, "1234567890~" }, qr{\bValidation failed for constraint 'even number' with value '41'};