File: 80match-equ.t

package info (click to toggle)
libsyntax-operator-equ-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 352; pascal: 34; makefile: 3
file content (49 lines) | stat: -rw-r--r-- 1,092 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
44
45
46
47
48
49
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

BEGIN {
   plan skip_all => "Syntax::Keyword::Match >= 0.08 is not available"
   unless eval { require Syntax::Keyword::Match;
                 Syntax::Keyword::Match->VERSION( '0.08' ); };
   plan skip_all => "Syntax::Operator::Equ is not available"
   unless eval { require Syntax::Operator::Equ };

   Syntax::Keyword::Match->import;
   Syntax::Operator::Equ->import;

   diag( "Syntax::Keyword::Match $Syntax::Keyword::Match::VERSION, " .
         "Syntax::Operator::Equ $Syntax::Operator::Equ::VERSION" );
}

# literals
{
   my $ok;
   match("abc" : equ) {
      case("abc") { $ok++ }
      case("def") { fail('Not this one sorry'); }
   }
   ok( $ok, 'Literal match' );
}

# undef is not ""
{
   my $ok;
   match("" : equ) {
      case(undef) { fail('Not this one sorry'); }
      case("")    { $ok++ }
   }
   ok( $ok, '"" did not match undef' );

   undef $ok;
   match(undef : equ) {
      case("")    { fail('Not this one sorry'); }
      case(undef) { $ok++ }
   }
   ok( $ok, 'undef did not match ""' );
}

done_testing;