File: structures.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 (153 lines) | stat: -rw-r--r-- 5,156 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!perl
use strict;
use Test::More tests => 17;
BEGIN { use_ok('Data::Sorting'); }
require 't/sort_tests.pl';

test_sort_cases (
  {
    values => [ 
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
    ],
    sorted => [ 'foo' ],
  },
  {
    values => [ 
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
    ],
    sorted => [ 'bar' ],
  },
  {
    values => [ 
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
    ],
    sorted => [ sub { (shift)->{bar} } ],
  },
  {
    values => [ 
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
    ],
    sorted => [ 'baz' ],
    okidxs => [ [ 1, 2, 3, 4 ], [ 2, 1, 3, 4 ], [ 1, 2, 4, 3 ], [ 2, 1, 4, 3 ] ]
  },
  {
    values => [ 
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
    ],
    sorted => [ 'baz', 'foo' ],
  },
  {
    values => [ 
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
    ],
    sorted => [ 'baz', 'bar' ],
  },
  {
    values => [ 
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
    ],
    sorted => [ 'baz', -order => 'reverse', 'bar' ],
  },
  {
    values => [ 
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
    ],
    sorted => [ -order => 'reverse', 'baz', 'bar' ],
  },
  {
    values => [ 
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
    ],
    sorted => [ -order => 'reverse', 'baz', -order => 'forward', 'bar' ],
  },
  {
    values => [ 
      { foo => 'Gamma', bar => 'Chi', baz => 'On' },
      { foo => 'Alpha', bar => 'Sigma', baz => 'On' },
      { foo => 'Beta', bar => 'Delta', baz => 'Off' },
      { foo => 'Omega', bar => 'Epsilon', baz => 'Off' },
    ],
    sorted => [ { order => 'reverse', sortkey => 'baz' }, 'bar' ],
  },
  {
    values => [ 
      [ 'art', { foo => 'Omega', bar => 'Epsilon', baz => 'Off' } ],
      [ 'cat', { foo => 'Beta', bar => 'Delta', baz => 'Off' } ],
      [ 'dog', { foo => 'Gamma', bar => 'Chi', baz => 'On' } ],
      [ 'set', { foo => 'Alpha', bar => 'Sigma', baz => 'On' } ],
    ],
    sorted => [ 0 ],
  },
  {
    values => [ 
      [ 'set', { foo => 'Alpha', bar => 'Sigma', baz => 'On' } ],
      [ 'cat', { foo => 'Beta', bar => 'Delta', baz => 'Off' } ],
      [ 'dog', { foo => 'Gamma', bar => 'Chi', baz => 'On' } ],
      [ 'art', { foo => 'Omega', bar => 'Epsilon', baz => 'Off' } ],
    ],
    sorted => [ [ 1, 'foo' ] ],
  },
  {
    values => [ 
      [ 'dog', { foo => 'Gamma', bar => 'Chi', baz => 'On' } ],
      [ 'cat', { foo => 'Beta', bar => 'Delta', baz => 'Off' } ],
      [ 'art', { foo => 'Omega', bar => 'Epsilon', baz => 'Off' } ],
      [ 'set', { foo => 'Alpha', bar => 'Sigma', baz => 'On' } ],
    ],
    sorted => [ [ 1, 'bar' ] ],
  },
  {
    values => [ 
      { foo => 'Gamma', bar => [ 'Chi', 'dog' ], baz => 'On' },
      { foo => 'Beta', bar => [ 'Delta', 'cat' ], baz => 'Off' },
      { foo => 'Omega', bar => [ 'Epsilon', 'art' ], baz => 'Off' },
      { foo => 'Alpha', bar => [ 'Sigma', 'set' ], baz => 'On' },
    ],
    sorted => [ [ 'bar', 0 ] ],
  },
  {
    values => [ 
      { foo => 'Omega', bar => [ 'Epsilon', 'art' ], baz => 'Off' },
      { foo => 'Beta', bar => [ 'Delta', 'cat' ], baz => 'Off' },
      { foo => 'Gamma', bar => [ 'Chi', 'dog' ], baz => 'On' },
      { foo => 'Alpha', bar => [ 'Sigma', 'set' ], baz => 'On' },
    ],
    sorted => [ [ 'bar', 1 ] ],
  },
  {
    values => [ 
      { foo => 'Beta', bar => [ 'Delta', 'cat' ], baz => 'Off' },
      { foo => 'Omega', bar => [ 'Epsilon', 'art' ], baz => 'Off' },
      { foo => 'Gamma', bar => [ 'Chi', 'dog' ], baz => 'On' },
      { foo => 'Alpha', bar => [ 'Sigma', 'set' ], baz => 'On' },
    ],
    sorted => [ 'baz', [ 'bar', 0 ] ],
  },
);