File: 01in-numbery.t

package info (click to toggle)
libsyntax-operator-in-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 201; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 841 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
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Syntax::Operator::In;
BEGIN { plan skip_all => "No PL_infix_plugin" unless XS::Parse::Infix::HAVE_PL_INFIX_PLUGIN; }

my $warnings = 0;
$SIG{__WARN__} = sub { $warnings++ };

## Circumfix notation

# List literals
ok(    3 in<==> (1..5) , '3 is in 1..5');
ok(not(6 in<==> (1..5)), '6 is not in 1..5');

## Colon notation

# List literals
ok(    3 in:== (1..5) , '3 is in 1..5');
ok(not(6 in:== (1..5)), '6 is not in 1..5');

# Arrays
my @AtoE = (10 .. 15);
ok(    13 in:== @AtoE , '13 is in @AtoE');
ok(not(16 in:== @AtoE), '16 is not in @AtoE');

# Function calls
sub hundred { return 100 .. 105 }
ok(102 in:== hundred(), '102 is in hundred()');

# This is a numeric match
ok("1.0" in:== ("1", "2"), 'match is done numerically');

ok(!$warnings, 'no warnings');

done_testing;