File: 12-general.t

package info (click to toggle)
libdeclare-constraints-simple-perl 0.03-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 300 kB
  • sloc: perl: 2,068; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 660 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
#!/usr/bin/perl
use warnings;
use strict;

use Test::More;

use Declare::Constraints::Simple
    only => qw(ReturnTrue ReturnFalse);

my @test_sets = (
    [ReturnTrue,        undef,      1,  'ReturnTrue undef'],
    [ReturnTrue,        12,         1,  'ReturnTrue number'],
    [ReturnTrue,        [],         1,  'ReturnTrue array ref'],
    
    [ReturnFalse('x'),  undef,      0,  'ReturnFalse undef'],
    [ReturnFalse('x'),  [],         0,  'ReturnFalse array ref'],
);

plan tests => scalar(@test_sets);

for (@test_sets) {
    my ($check, $value, $expect, $title) = @$_;
    my $result = $check->($value);
    is(($result ? 1 : 0), $expect, $title);
}