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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;
require TestDriver;
my $td = new TestDriver('numrange');
my @nrange_tests = (
[",5",
"error at * in numeric range *,5: unexpected separator",
2],
["4,,5",
"error at * in numeric range 4,*,5: unexpected separator",
2],
["4,5,",
"error at * in numeric range 4,5,*: number expected",
2],
["z1,",
"error at * in numeric range z*1,: digit not expected",
2],
["1z,",
"error at * in numeric range 1*z,: z not expected",
2],
["1-5?",
"error at * in numeric range 1-5*?: unexpected character",
2],
["1-30",
"error in numeric range 1-30: number 30 out of range",
2],
["1-10,0,5",
"error in numeric range 1-10,0,5: number 0 out of range",
2],
["1-10,1234,5",
"error in numeric range 1-10,1234,5: number 1234 out of range",
2],
["1,r,3",
"error in numeric range 1,r,3: number 16 out of range",
2],
["1,r16,3",
"error in numeric range 1,r16,3: number 0 out of range",
2],
["1,3,5-10,z-13,13,9,z,2,r2-r4",
"numeric range 1,3,5-10,z-13,13,9,z,2,r2-r4" .
" -> 1 3 5 6 7 8 9 10 15 14 13 13 9 15 2 14 13 12",
0],
["r1-r15", # r\d+ at end
"numeric range r1-r15" .
" -> 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1",
0],
);
foreach my $d (@nrange_tests)
{
my ($range, $output, $status) = @$d;
$td->runtest("numeric range $range",
{$td->COMMAND => ['numrange', $range],
$td->FILTER => "grep 'numeric range'"},
{$td->STRING => $output . "\n", $td->EXIT_STATUS => $status},
$td->NORMALIZE_NEWLINES);
}
$td->report(scalar(@nrange_tests));
|