File: 49role-compat.t

package info (click to toggle)
libobject-pad-perl 0.821-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 936 kB
  • sloc: ansic: 3,361; perl: 3,328; pascal: 28; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 693 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
#!/usr/bin/perl

use v5.18;
use warnings;

use Test2::V0;

use Object::Pad 0.800;

role ARole :compat(invokable) {
   method one { return 1 }

   method redir { return $self->two }
}

# A classical perl class
package AClass {
   use base 'ARole';

   sub new { bless [], shift }

   sub two { return 2 }
}

{
   my $obj = AClass->new;
   isa_ok( $obj, [ "AClass" ], '$obj' );

   is( $obj->one, 1, 'AClass has a ->one method' );
   is( $obj->redir, 2, 'AClass has a ->redir method' );
}

# RT152793
{
   role RT152793 :compat(invokable) {
      method f { return 42; }
   }

   undef &RT152793::f;
   pass( 'Did not crash when deleting method of invokable role (RT152793)' );
}

done_testing;