File: split.t

package info (click to toggle)
libre-engine-re2-perl 0.18%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 440 kB
  • sloc: cpp: 270; perl: 80; makefile: 2; sh: 1
file content (46 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (5)
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
use strict;
use Test::More tests => 20;
use re::engine::RE2;

{
    my ($a, $b, $c) = split /(:)/, "a:b";
    is($a, "a");
    is($b, ":");
    is($c, "b");
}

# The " " special case
{
    my ($a, $b, $c, $d, $e) = split " ", " foo bar  zar ";
    is($a, "foo");
    is($b, "bar");
    is($c, "zar");
    is($d, "");
    is($e, undef);
}

# The /^/ special case
{
    my ($a, $b, $c) = split /^/, "a\nb\nc\n";
    is($a, "a\n");
    is($b, "b\n");
    is($c, "c\n");
}

# The /\s+/ special case
{
    my ($a, $b, $c, $d) = split /\s+/, "a b  c\t d";
    is($a, "a");
    is($b, "b");
    is($c, "c");
    is($d, "d");
}

{
    my ($a, $b, $c, $d, $e) = split / /, " x y ";
    is($a, "");
    is($b, "x");
    is($c, "y");
    is($d, "");
    is($e, undef);
}