File: 01match-regexp.t

package info (click to toggle)
libsyntax-keyword-match-perl 0.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: perl: 902; ansic: 34; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 460 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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Syntax::Keyword::Match;

# literals
{
   my $ok;
   match("abcd" : =~) {
      case(m/\w+/) { $ok++ }
      case(m/\d+/) { fail('Not this one sorry'); }
   }
   ok( $ok, 'Literal match' );
}

# default
{
   my $ok;
   match("XYZ" : =~) {
      case(m/a/) { fail("Not a") }
      case(m/b/) { fail("Not b") }
      default    { $ok++ }
   }
   ok( $ok, 'Default block executed' );
}

done_testing;