File: ffi_platypus_api.t

package info (click to toggle)
libffi-platypus-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,860 kB
  • sloc: perl: 7,388; ansic: 6,862; cpp: 53; sh: 19; makefile: 14
file content (27 lines) | stat: -rw-r--r-- 438 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use Test2::V0 -no_srand => 1;
use FFI::Platypus::API;

subtest 'basic' => sub {

  {
    package FFI::Platypus::Type::C1;

    sub ffi_custom_type_api_1
    {
      return {
        native_type => 'sint8',
        perl_to_native => sub { $_[0] * 2 },
      }
    }
  }

  my $ffi = FFI::Platypus->new;
  $ffi->load_custom_type('::C1' => 'c1');
  is(
    $ffi->function( 0 => ['c1'] => 'sint8' )->call(10),
    20,
  );

};

done_testing;