Debian Codegraph @

t/33pieces-listexpr.t

raw
1 #!/usr/bin/perl
2
3 use v5.14;
4 use warnings;
5
6 use Test2::V0;
7
8 use lib "t";
9 use testcase "t::pieces";
10
11 BEGIN { $^H{"t::pieces/permit"} = 1; }
12
13 my $ret;
14
15 {
16 $ret = piecelistexpr "a term";
17 is( $ret, "a term", 'a single term' );
18 }
19
20 # listexpr vs concat
21 {
22 $ret = piecelistexpr "x" . "y";
23 is( $ret, "xy", 'listexpr consumes concat' );
24 }
25
26 # listexpr vs comma
27 {
28 $ret = join "", "x", piecelistexpr "inside", "y";
29 is( $ret, "xinside,y", 'listexpr consumes comma' );
30 }
31
32 # optional listexpr
33 {
34 my $ret1 = piecelistexpr_opt 1, 2, 3;
35 my $ret2 = piecelistexpr_opt;
36
37 is( $ret1, "1,2,3", 'optional listexpr with values' );
38 is( $ret2, undef, 'optional listexpr empty' );
39 }
40
41 done_testing;