File: 60class.t

package info (click to toggle)
libmeta-perl 0.014-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 212 kB
  • sloc: perl: 613; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 879 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

BEGIN {
   $^V ge v5.38 or
      plan skip_all => "Not supported on Perl $^V";
}

use meta;
no warnings qw( meta::experimental );

use feature 'class';
no warnings qw( experimental::class );

package NotAClass {
   sub not_a_method {}
}

class IsAClass {
   sub not_a_method {}
   method is_a_method {}
}

# ->is_class
{
   ok( !meta::package->get( "NotAClass" )->is_class,
      'metapkg for non-class is not a class' );

   ok( meta::package->get( "IsAClass" )->is_class,
      'metapkg for class is a class' );
}

# ->is_method
{
   my $metapkg = meta::package->get( "IsAClass" );

   ok( !$metapkg->get_symbol( '&not_a_method' )->is_method,
      'metasub for not_a_method is not a method' );

   ok( $metapkg->get_symbol( '&is_a_method' )->is_method,
      'metasub for is_a_method is a method' );
}

done_testing;