Debian Codegraph @

t/80extended+feature-class.t

raw
1 #!/usr/bin/perl
2
3 use v5.14;
4 use warnings;
5
6 use Test2::V0;
7 BEGIN {
8 $] >= 5.026000 or plan skip_all => "No parse_subsignature()";
9
10 # version 5.37.10 added the ability to start_subparse() with CVf_IsMETHOD,
11 # which we need
12 plan skip_all => "feature 'class' is not available"
13 unless $^V ge v5.37.10;
14 }
15
16 use Test2::Require::Module 'Sublike::Extended' => '0.29';
17
18 use Sublike::Extended;
19
20 use feature 'class';
21 no warnings 'experimental::class';
22
23 # extended method
24 {
25 class C1 {
26 extended method f (:$x, :$y) { return "x=$x y=$y" }
27 }
28
29 is( C1->new->f( x => "first", y => "second" ), "x=first y=second",
30 'extended method' );
31 }
32
33 # method + S:E 0.29
34 {
35 use Sublike::Extended 'method';
36
37 class C2 {
38 method f (:$x, :$y) { return "x=$x y=$y" }
39 }
40
41 is( C2->new->f( x => "third", y => "fourth" ), "x=third y=fourth",
42 'method with extended keyword' );
43 }
44
45 done_testing;