File: 80extended%2Bfeature-class.t

package info (click to toggle)
libxs-parse-sublike-perl 0.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: ansic: 944; perl: 930; sh: 6; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 909 bytes parent folder | download
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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;
BEGIN {
   $] >= 5.026000 or plan skip_all => "No parse_subsignature()";

   # version 5.37.10 added the ability to start_subparse() with CVf_IsMETHOD,
   # which we need
   plan skip_all => "feature 'class' is not available"
      unless $^V ge v5.37.10;
}

use Test2::Require::Module 'Sublike::Extended' => '0.29';

use Sublike::Extended;

use feature 'class';
no warnings 'experimental::class';

# extended method
{
   class C1 {
      extended method f (:$x, :$y) { return "x=$x y=$y" }
   }

   is( C1->new->f( x => "first", y => "second" ), "x=first y=second",
      'extended method' );
}

# method + S:E 0.29
{
   use Sublike::Extended 'method';

   class C2 {
      method f (:$x, :$y) { return "x=$x y=$y" }
   }

   is( C2->new->f( x => "third", y => "fourth" ), "x=third y=fourth",
      'method with extended keyword' );
}

done_testing;