File: substrs.t

package info (click to toggle)
libdata-sorting-perl 0.9-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 863; makefile: 2
file content (72 lines) | stat: -rw-r--r-- 1,362 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!perl
use strict;
use Test::More tests => 8;
BEGIN { use_ok('Data::Sorting'); }
require 't/sort_tests.pl';

test_sort_cases (
  {
    values => [ 
	'Alpha:Sigma:On', 
	'Beta:Delta:Off', 
	'Gamma:Chi:On', 
	'Omega:Epsilon:Off',
    ],
    sorted => [],
  },
  {
    values => [ 
	'Gamma:Chi:On', 
	'Beta:Delta:Off', 
	'Alpha:Sigma:On', 
	'Omega:Epsilon:Off',
    ],
    sorted => [ -extract => 'substr', [1,3]  ],
  },
  {
    values => [ 
	'Alpha:Sigma:On', 
	'Beta:Delta:Off', 
	'Gamma:Chi:On', 
	'Omega:Epsilon:Off',
    ],
    sorted => [ -extract => 'split', [':', 0]  ],
  },
  {
    values => [ 
	'Gamma:Chi:On', 
	'Beta:Delta:Off', 
	'Omega:Epsilon:Off', 
	'Alpha:Sigma:On', 
    ],
    sorted => [ -extract => 'split', [':', 1]  ],
  },
  {
    values => [ 
	'Beta:Delta:Off', 
	'Omega:Epsilon:Off', 
	'Alpha:Sigma:On', 
	'Gamma:Chi:On', 
    ],
    sorted => [ -extract => 'split', [':', 2], [':', 0] ],
  },
  {
    values => [ 
	'Beta:Delta:Off', 
	'Gamma:Chi:On', 
	'Alpha:Sigma:On', 
	'Omega:Epsilon:Off', 
    ],
    sorted => [ -extract => 'compound', ['split'=>[':', 1], 'substr'=>[1,3] ] ],
  },
  {
    values => [ 
	'Beta:Delta:Off', 
	'Omega:Epsilon:Off', 
	'Alpha:Sigma:On', 
	'Gamma:Chi:On', 
    ],
    sorted => [ -extract => 'split', [':', 2]  ],
    okidxs => [ [ 1, 2, 3, 4 ], [ 2, 1, 3, 4 ], [ 1, 2, 4, 3 ], [ 2, 1, 4, 3 ] ]
  },
);