-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
145 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use Test2::V0; | ||
use lib 't/lib'; | ||
|
||
use Function::Interface::Impl; | ||
|
||
BEGIN { | ||
no warnings qw(redefine); | ||
*Function::Interface::Impl::error = sub { | ||
return "DIED: @_"; | ||
} | ||
} | ||
|
||
use Foo; | ||
use FooNoFoo; | ||
use FooNoParamsInfo; | ||
use FooNoReturnInfo; | ||
use FooInvalidParams; | ||
use FooInvalidReturn; | ||
|
||
sub assert_valid { | ||
my ($package, $interface_package) = @_; | ||
Function::Interface::Impl::assert_valid( | ||
$package, $interface_package, __FILE__, __LINE__ | ||
); | ||
} | ||
|
||
like assert_valid('Fo', 'IFoo'), | ||
qr/^DIED: implements package is not loaded yet. required to use/, 'cannot load impl package'; | ||
|
||
like assert_valid('Foo', 'IFo'), | ||
qr/^DIED: cannot load interface package: Can't locate IFo.pm/, 'cannot load interface package'; | ||
|
||
like assert_valid('Foo', 'Test2'), | ||
qr/^DIED: cannot get interface info/, 'cannot get interface info'; | ||
|
||
like assert_valid('FooNoFoo', 'IFoo'), | ||
qr/^DIED: function `foo` is required/, 'required methods'; | ||
|
||
like assert_valid('FooNoParamsInfo', 'IFoo'), | ||
qr/^DIED: cannot get function `foo` parameters info/, 'required params info'; | ||
|
||
like assert_valid('FooNoReturnInfo', 'IFoo'), | ||
qr/^DIED: cannot get function `foo` return info/, 'required return info'; | ||
|
||
like assert_valid('FooInvalidParams', 'IFoo'), | ||
qr/^DIED: function `foo` is invalid parameters/, 'invalid params'; | ||
|
||
like assert_valid('FooInvalidReturn', 'IFoo'), | ||
qr/^DIED: function `foo` is invalid return/, 'invalid return'; | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package FooInvalidParams; | ||
use Function::Interface::Impl qw(IFoo); | ||
use Function::Return; | ||
use Function::Parameters; | ||
|
||
use Types::Standard -types; | ||
|
||
fun foo(Str $a) :Return() {} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package FooInvalidReturn; | ||
use Function::Interface::Impl qw(IFoo); | ||
use Function::Return; | ||
use Function::Parameters; | ||
|
||
use Types::Standard -types; | ||
|
||
fun foo() :Return(Str) {} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package FooNoFoo; | ||
|
||
sub test {} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package FooNoParamsInfo; | ||
use Function::Interface::Impl qw(IFoo); | ||
use Function::Return; | ||
|
||
sub foo :Return() {} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package FooNoReturnInfo; | ||
use Function::Interface::Impl qw(IFoo); | ||
use Function::Parameters; | ||
|
||
fun foo() {} | ||
|
||
1; |