File: Regex.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (33 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (9)
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
use Test2::Bundle::Extended -target => 'Test2::Compare::Regex';

my $one = $CLASS->new(input => qr/abc/i);

is(qr/abc/i, $one, "same regex");

ok(!$one->verify(got => qr/xyz/i, exists => 1), "Different regex");
ok(!$one->verify(got => qr/abc/, exists => 1), "Different flags");
ok(!$one->verify(exists => 0), "Must exist");

ok(!$one->verify(exists => 1, got => {}), "Must be regex");
ok(!$one->verify(exists => 1, got => undef), "Must be defined");
ok(!$one->verify(exists => 1, got => 'aaa'), "String is not valid");

is($one->name, "" . qr/abc/i, "name is regex pattern");

is($one->operator, 'eq', "got operator");

ok($one->verify(got => qr/abc/i, exists => 1), "Same regex");

like(
    dies { $CLASS->new() },
    qr/'input' is a required attribute/,
    "require a pattern"
);

like(
    dies { $CLASS->new(input => 'foo') },
    qr/'input' must be a regex , got 'foo'/,
    "must be a regex"
);

done_testing;