t/lib/Test/Platypus.pm
raw| 1 | package Test::Platypus; |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | use Test2::API qw( context ); |
| 6 | use Exporter qw( import ); |
| 7 | |
| 8 | our @EXPORT = qw( platypus ); |
| 9 | |
| 10 | sub platypus { |
| 11 | my($count, $code) = @_; |
| 12 | |
| 13 | my $ffi = eval { |
| 14 | require FFI::Platypus; |
| 15 | FFI::Platypus->new; |
| 16 | }; |
| 17 | |
| 18 | if($ffi) |
| 19 | { |
| 20 | $code->($ffi); |
| 21 | } |
| 22 | else |
| 23 | { |
| 24 | my $ctx = context(); |
| 25 | $ctx->skip('', "Test requires FFI::Platypus") for 1..$count; |
| 26 | $ctx->release; |
| 27 | } |
| 28 | |
| 29 | } |
| 30 | |
| 31 | 1; |