libpath-ruby 0.2.2 → 0.2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +33 -0
- data/README.md +25 -8
- data/examples/path_from_arg0.md +43 -43
- data/examples/path_from_arg0.rb +25 -23
- data/lib/libpath/constants/unix.rb +74 -74
- data/lib/libpath/constants/windows.rb +75 -75
- data/lib/libpath/constants.rb +20 -20
- data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
- data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +118 -118
- data/lib/libpath/form/windows.rb +228 -214
- data/lib/libpath/form.rb +20 -21
- data/lib/libpath/internal_/array.rb +57 -57
- data/lib/libpath/internal_/platform.rb +30 -31
- data/lib/libpath/internal_/string.rb +25 -20
- data/lib/libpath/internal_/unix/form.rb +124 -119
- data/lib/libpath/internal_/windows/drive.rb +80 -75
- data/lib/libpath/internal_/windows/form.rb +205 -194
- data/lib/libpath/libpath.rb +4 -1
- data/lib/libpath/path/unix.rb +120 -118
- data/lib/libpath/path/windows.rb +126 -124
- data/lib/libpath/path.rb +21 -21
- data/lib/libpath/util/unix.rb +261 -261
- data/lib/libpath/util/windows.rb +403 -403
- data/lib/libpath/util.rb +20 -20
- data/lib/libpath/version.rb +25 -26
- data/lib/libpath.rb +1 -1
- data/test/performance/benchmark_drive_letter.rb +50 -10
- data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
- data/test/performance/benchmark_rindex2.rb +56 -48
- data/test/performance/benchmark_split.rb +16 -10
- data/test/unit/compare/ts_all.rb +4 -4
- data/test/unit/equate/ts_all.rb +4 -4
- data/test/unit/equate/unix/ts_all.rb +4 -4
- data/test/unit/equate/windows/ts_all.rb +4 -4
- data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
- data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
- data/test/unit/exceptions/ts_all.rb +4 -4
- data/test/unit/form/tc_absolute_functions.rb +242 -240
- data/test/unit/form/ts_all.rb +4 -4
- data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
- data/test/unit/form/unix/ts_all.rb +4 -4
- data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
- data/test/unit/form/windows/ts_all.rb +4 -4
- data/test/unit/internal_/tc_array.rb +36 -32
- data/test/unit/internal_/ts_all.rb +4 -4
- data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
- data/test/unit/internal_/unix/form/ts_all.rb +4 -4
- data/test/unit/internal_/unix/tc_split_path.rb +387 -384
- data/test/unit/internal_/unix/ts_all.rb +4 -4
- data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
- data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
- data/test/unit/internal_/windows/form/ts_all.rb +4 -4
- data/test/unit/internal_/windows/tc_split_path.rb +874 -869
- data/test/unit/internal_/windows/ts_all.rb +4 -4
- data/test/unit/parse/ts_all.rb +4 -4
- data/test/unit/path/tc_path.rb +732 -732
- data/test/unit/path/ts_all.rb +4 -4
- data/test/unit/path/unix/tc_path.rb +544 -540
- data/test/unit/path/unix/ts_all.rb +4 -4
- data/test/unit/path/windows/tc_path.rb +608 -603
- data/test/unit/path/windows/ts_all.rb +4 -4
- data/test/unit/tc_version.rb +25 -22
- data/test/unit/ts_all.rb +4 -4
- data/test/unit/util/tc_combine_paths.rb +110 -105
- data/test/unit/util/tc_derive_relative_path.rb +8 -3
- data/test/unit/util/tc_make_path_canonical.rb +142 -138
- data/test/unit/util/ts_all.rb +4 -4
- data/test/unit/util/unix/tc_combine_paths.rb +38 -34
- data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
- data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
- data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
- data/test/unit/util/unix/ts_all.rb +4 -4
- data/test/unit/util/windows/tc_combine_paths.rb +82 -77
- data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
- data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
- data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
- data/test/unit/util/windows/ts_all.rb +4 -4
- metadata +9 -8
@@ -8,389 +8,392 @@ require 'test/unit'
|
|
8
8
|
|
9
9
|
class Test_LibPath_Internal_Unix_Form_split_path < Test::Unit::TestCase
|
10
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
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
11
|
+
F = ::LibPath::Internal_::Unix::Form
|
12
|
+
|
13
|
+
def test_empty
|
14
|
+
|
15
|
+
r = F.split_path ''
|
16
|
+
|
17
|
+
assert_kind_of ::Array, r
|
18
|
+
assert_equal 8, r.size
|
19
|
+
assert_nil r[0]
|
20
|
+
assert_nil r[1]
|
21
|
+
assert_nil r[2]
|
22
|
+
assert_nil r[3]
|
23
|
+
assert_nil r[4]
|
24
|
+
assert_nil r[5]
|
25
|
+
assert_kind_of ::Array, r[6]
|
26
|
+
assert_empty r[6]
|
27
|
+
assert_kind_of ::Array, r[7]
|
28
|
+
assert_empty r[7]
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_dot
|
32
|
+
|
33
|
+
r = F.split_path '.'
|
34
|
+
|
35
|
+
assert_kind_of ::Array, r
|
36
|
+
assert_equal 8, r.size
|
37
|
+
assert_equal '.', r[0]
|
38
|
+
assert_nil r[1]
|
39
|
+
assert_nil r[2]
|
40
|
+
assert_equal '.', r[3]
|
41
|
+
assert_equal '.', r[4]
|
42
|
+
assert_nil r[5]
|
43
|
+
assert_kind_of ::Array, r[6]
|
44
|
+
assert_empty r[6]
|
45
|
+
assert_kind_of ::Array, r[7]
|
46
|
+
assert_empty r[7]
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_dots
|
50
|
+
|
51
|
+
r = F.split_path '..'
|
52
|
+
|
53
|
+
assert_kind_of ::Array, r
|
54
|
+
assert_equal 8, r.size
|
55
|
+
assert_equal '..', r[0]
|
56
|
+
assert_nil r[1]
|
57
|
+
assert_nil r[2]
|
58
|
+
assert_equal '..', r[3]
|
59
|
+
assert_equal '..', r[4]
|
60
|
+
assert_nil r[5]
|
61
|
+
assert_kind_of ::Array, r[6]
|
62
|
+
assert_empty r[6]
|
63
|
+
assert_kind_of ::Array, r[7]
|
64
|
+
assert_empty r[7]
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_stems
|
68
|
+
|
69
|
+
r = F.split_path 'a'
|
70
|
+
|
71
|
+
assert_kind_of ::Array, r
|
72
|
+
assert_equal 8, r.size
|
73
|
+
assert_equal 'a', r[0]
|
74
|
+
assert_nil r[1]
|
75
|
+
assert_nil r[2]
|
76
|
+
assert_equal 'a', r[3]
|
77
|
+
assert_equal 'a', r[4]
|
78
|
+
assert_nil r[5]
|
79
|
+
assert_kind_of ::Array, r[6]
|
80
|
+
assert_empty r[6]
|
81
|
+
assert_kind_of ::Array, r[7]
|
82
|
+
assert_empty r[7]
|
83
|
+
|
84
|
+
r = F.split_path 'abc'
|
85
|
+
|
86
|
+
assert_kind_of ::Array, r
|
87
|
+
assert_equal 8, r.size
|
88
|
+
assert_equal 'abc', r[0]
|
89
|
+
assert_nil r[1]
|
90
|
+
assert_nil r[2]
|
91
|
+
assert_equal 'abc', r[3]
|
92
|
+
assert_equal 'abc', r[4]
|
93
|
+
assert_nil r[5]
|
94
|
+
assert_kind_of ::Array, r[6]
|
95
|
+
assert_empty r[6]
|
96
|
+
assert_kind_of ::Array, r[7]
|
97
|
+
assert_empty r[7]
|
98
|
+
|
99
|
+
r = F.split_path 'abcdefghi'
|
100
|
+
|
101
|
+
assert_kind_of ::Array, r
|
102
|
+
assert_equal 8, r.size
|
103
|
+
assert_equal 'abcdefghi', r[0]
|
104
|
+
assert_nil r[1]
|
105
|
+
assert_nil r[2]
|
106
|
+
assert_equal 'abcdefghi', r[3]
|
107
|
+
assert_equal 'abcdefghi', r[4]
|
108
|
+
assert_nil r[5]
|
109
|
+
assert_kind_of ::Array, r[6]
|
110
|
+
assert_empty r[6]
|
111
|
+
assert_kind_of ::Array, r[7]
|
112
|
+
assert_empty r[7]
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_basenames
|
116
|
+
|
117
|
+
r = F.split_path 'a.x'
|
118
|
+
|
119
|
+
assert_kind_of ::Array, r
|
120
|
+
assert_equal 8, r.size
|
121
|
+
assert_equal 'a.x', r[0]
|
122
|
+
assert_nil r[1]
|
123
|
+
assert_nil r[2]
|
124
|
+
assert_equal 'a.x', r[3]
|
125
|
+
assert_equal 'a', r[4]
|
126
|
+
assert_equal '.x', r[5]
|
127
|
+
assert_kind_of ::Array, r[6]
|
128
|
+
assert_empty r[6]
|
129
|
+
assert_kind_of ::Array, r[7]
|
130
|
+
assert_empty r[7]
|
131
|
+
|
132
|
+
r = F.split_path 'abc.ext'
|
133
|
+
|
134
|
+
assert_kind_of ::Array, r
|
135
|
+
assert_equal 8, r.size
|
136
|
+
assert_equal 'abc.ext', r[0]
|
137
|
+
assert_nil r[1]
|
138
|
+
assert_nil r[2]
|
139
|
+
assert_equal 'abc.ext', r[3]
|
140
|
+
assert_equal 'abc', r[4]
|
141
|
+
assert_equal '.ext', r[5]
|
142
|
+
assert_kind_of ::Array, r[6]
|
143
|
+
assert_empty r[6]
|
144
|
+
assert_kind_of ::Array, r[7]
|
145
|
+
assert_empty r[7]
|
146
|
+
|
147
|
+
r = F.split_path 'abcd.efghi.ext'
|
148
|
+
|
149
|
+
assert_kind_of ::Array, r
|
150
|
+
assert_equal 8, r.size
|
151
|
+
assert_nil r[1]
|
152
|
+
assert_nil r[2]
|
153
|
+
assert_equal 'abcd.efghi.ext', r[3]
|
154
|
+
assert_equal 'abcd.efghi', r[4]
|
155
|
+
assert_equal '.ext', r[5]
|
156
|
+
assert_kind_of ::Array, r[6]
|
157
|
+
assert_empty r[6]
|
158
|
+
assert_kind_of ::Array, r[7]
|
159
|
+
assert_empty r[7]
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_directories
|
163
|
+
|
164
|
+
r = F.split_path 'a/'
|
165
|
+
|
166
|
+
assert_kind_of ::Array, r
|
167
|
+
assert_equal 8, r.size
|
168
|
+
assert_equal 'a/', r[0]
|
169
|
+
assert_nil r[1]
|
170
|
+
assert_equal 'a/', r[2]
|
171
|
+
assert_nil r[3]
|
172
|
+
assert_nil r[4]
|
173
|
+
assert_nil r[5]
|
174
|
+
assert_kind_of ::Array, r[6]
|
175
|
+
assert_equal [ 'a/' ], r[6]
|
176
|
+
assert_kind_of ::Array, r[7]
|
177
|
+
assert_equal [ 'a/' ], r[7]
|
178
|
+
|
179
|
+
r = F.split_path 'abc/'
|
180
|
+
|
181
|
+
assert_kind_of ::Array, r
|
182
|
+
assert_equal 8, r.size
|
183
|
+
assert_equal 'abc/', r[0]
|
184
|
+
assert_nil r[1]
|
185
|
+
assert_equal 'abc/', r[2]
|
186
|
+
assert_nil r[3]
|
187
|
+
assert_nil r[4]
|
188
|
+
assert_nil r[5]
|
189
|
+
assert_kind_of ::Array, r[6]
|
190
|
+
assert_equal [ 'abc/' ], r[6]
|
191
|
+
assert_kind_of ::Array, r[7]
|
192
|
+
assert_equal [ 'abc/' ], r[7]
|
193
|
+
|
194
|
+
r = F.split_path 'abc/def/'
|
195
|
+
|
196
|
+
assert_kind_of ::Array, r
|
197
|
+
assert_equal 8, r.size
|
198
|
+
assert_equal 'abc/def/', r[0]
|
199
|
+
assert_nil r[1]
|
200
|
+
assert_equal 'abc/def/', r[2]
|
201
|
+
assert_nil r[3]
|
202
|
+
assert_nil r[4]
|
203
|
+
assert_nil r[5]
|
204
|
+
assert_kind_of ::Array, r[6]
|
205
|
+
assert_equal [ 'abc/', 'def/' ], r[6]
|
206
|
+
assert_kind_of ::Array, r[7]
|
207
|
+
assert_equal [ 'abc/', 'def/' ], r[7]
|
208
|
+
|
209
|
+
r = F.split_path '/'
|
210
|
+
|
211
|
+
assert_kind_of ::Array, r
|
212
|
+
assert_equal 8, r.size
|
213
|
+
assert_equal '/', r[0]
|
214
|
+
assert_nil r[1]
|
215
|
+
assert_equal '/', r[2]
|
216
|
+
assert_nil r[3]
|
217
|
+
assert_nil r[4]
|
218
|
+
assert_nil r[5]
|
219
|
+
assert_kind_of ::Array, r[6]
|
220
|
+
assert_equal [ '/' ], r[6]
|
221
|
+
assert_kind_of ::Array, r[7]
|
222
|
+
assert_equal [ '/' ], r[7]
|
223
|
+
|
224
|
+
r = F.split_path '/abc/'
|
225
|
+
|
226
|
+
assert_kind_of ::Array, r
|
227
|
+
assert_equal 8, r.size
|
228
|
+
assert_equal '/abc/', r[0]
|
229
|
+
assert_nil r[1]
|
230
|
+
assert_equal '/abc/', r[2]
|
231
|
+
assert_nil r[3]
|
232
|
+
assert_nil r[4]
|
233
|
+
assert_nil r[5]
|
234
|
+
assert_kind_of ::Array, r[6]
|
235
|
+
assert_equal [ '/', 'abc/' ], r[6]
|
236
|
+
assert_kind_of ::Array, r[7]
|
237
|
+
assert_equal [ '/', 'abc/' ], r[7]
|
238
|
+
|
239
|
+
r = F.split_path '/abc/def/'
|
240
|
+
|
241
|
+
assert_kind_of ::Array, r
|
242
|
+
assert_equal 8, r.size
|
243
|
+
assert_equal '/abc/def/', r[0]
|
244
|
+
assert_nil r[1]
|
245
|
+
assert_equal '/abc/def/', r[2]
|
246
|
+
assert_nil r[3]
|
247
|
+
assert_nil r[4]
|
248
|
+
assert_nil r[5]
|
249
|
+
assert_kind_of ::Array, r[6]
|
250
|
+
assert_equal [ '/', 'abc/', 'def/' ], r[6]
|
251
|
+
assert_kind_of ::Array, r[7]
|
252
|
+
assert_equal [ '/', 'abc/', 'def/' ], r[7]
|
253
|
+
|
254
|
+
r = F.split_path '~/abc/def/'
|
255
|
+
|
256
|
+
assert_kind_of ::Array, r
|
257
|
+
assert_equal 8, r.size
|
258
|
+
assert_equal '~/abc/def/', r[0]
|
259
|
+
assert_nil r[1]
|
260
|
+
assert_equal '~/abc/def/', r[2]
|
261
|
+
assert_nil r[3]
|
262
|
+
assert_nil r[4]
|
263
|
+
assert_nil r[5]
|
264
|
+
assert_kind_of ::Array, r[6]
|
265
|
+
assert_equal [ '~/', 'abc/', 'def/' ], r[6]
|
266
|
+
assert_kind_of ::Array, r[7]
|
267
|
+
assert_equal [ '~/', 'abc/', 'def/' ], r[7]
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_paths
|
271
|
+
|
272
|
+
r = F.split_path 'a/b'
|
273
|
+
|
274
|
+
assert_kind_of ::Array, r
|
275
|
+
assert_equal 8, r.size
|
276
|
+
assert_equal 'a/b', r[0]
|
277
|
+
assert_nil r[1]
|
278
|
+
assert_equal 'a/', r[2]
|
279
|
+
assert_equal 'b', r[3]
|
280
|
+
assert_equal 'b', r[4]
|
281
|
+
assert_nil r[5]
|
282
|
+
assert_kind_of ::Array, r[6]
|
283
|
+
assert_equal [ 'a/' ], r[6]
|
284
|
+
assert_kind_of ::Array, r[7]
|
285
|
+
assert_equal [ 'a/' ], r[7]
|
286
|
+
|
287
|
+
r = F.split_path 'abc/file.ext'
|
288
|
+
|
289
|
+
assert_kind_of ::Array, r
|
290
|
+
assert_equal 8, r.size
|
291
|
+
assert_equal 'abc/file.ext', r[0]
|
292
|
+
assert_nil r[1]
|
293
|
+
assert_equal 'abc/', r[2]
|
294
|
+
assert_equal 'file.ext', r[3]
|
295
|
+
assert_equal 'file', r[4]
|
296
|
+
assert_equal '.ext', r[5]
|
297
|
+
assert_kind_of ::Array, r[6]
|
298
|
+
assert_equal [ 'abc/' ], r[6]
|
299
|
+
assert_kind_of ::Array, r[7]
|
300
|
+
assert_equal [ 'abc/' ], r[7]
|
301
|
+
|
302
|
+
r = F.split_path '/abc/file.ext'
|
303
|
+
|
304
|
+
assert_kind_of ::Array, r
|
305
|
+
assert_equal 8, r.size
|
306
|
+
assert_equal '/abc/file.ext', r[0]
|
307
|
+
assert_nil r[1]
|
308
|
+
assert_equal '/abc/', r[2]
|
309
|
+
assert_equal 'file.ext', r[3]
|
310
|
+
assert_equal 'file', r[4]
|
311
|
+
assert_equal '.ext', r[5]
|
312
|
+
assert_kind_of ::Array, r[6]
|
313
|
+
assert_equal [ '/', 'abc/' ], r[6]
|
314
|
+
assert_kind_of ::Array, r[7]
|
315
|
+
assert_equal [ '/', 'abc/' ], r[7]
|
316
|
+
|
317
|
+
r = F.split_path '/abc/.ext'
|
318
|
+
|
319
|
+
assert_kind_of ::Array, r
|
320
|
+
assert_equal 8, r.size
|
321
|
+
assert_equal '/abc/.ext', r[0]
|
322
|
+
assert_nil r[1]
|
323
|
+
assert_equal '/abc/', r[2]
|
324
|
+
assert_equal '.ext', r[3]
|
325
|
+
assert_nil r[4]
|
326
|
+
assert_equal '.ext', r[5]
|
327
|
+
assert_kind_of ::Array, r[6]
|
328
|
+
assert_equal [ '/', 'abc/' ], r[6]
|
329
|
+
assert_kind_of ::Array, r[7]
|
330
|
+
assert_equal [ '/', 'abc/' ], r[7]
|
331
|
+
|
332
|
+
r = F.split_path '/abc/ext.'
|
333
|
+
|
334
|
+
assert_kind_of ::Array, r
|
335
|
+
assert_equal 8, r.size
|
336
|
+
assert_equal '/abc/ext.', r[0]
|
337
|
+
assert_nil r[1]
|
338
|
+
assert_equal '/abc/', r[2]
|
339
|
+
assert_equal 'ext.', r[3]
|
340
|
+
assert_equal 'ext', r[4]
|
341
|
+
assert_equal '.', r[5]
|
342
|
+
assert_kind_of ::Array, r[6]
|
343
|
+
assert_equal [ '/', 'abc/' ], r[6]
|
344
|
+
assert_kind_of ::Array, r[7]
|
345
|
+
assert_equal [ '/', 'abc/' ], r[7]
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_paths_with_dots_basenames
|
349
|
+
|
350
|
+
r = F.split_path '/.'
|
351
|
+
|
352
|
+
assert_kind_of ::Array, r
|
353
|
+
assert_equal 8, r.size
|
354
|
+
assert_equal '/.', r[0]
|
355
|
+
assert_nil r[1]
|
356
|
+
assert_equal '/', r[2]
|
357
|
+
assert_equal '.', r[3]
|
358
|
+
assert_equal '.', r[4]
|
359
|
+
assert_nil r[5]
|
360
|
+
assert_kind_of ::Array, r[6]
|
361
|
+
assert_equal [ '/' ], r[6]
|
362
|
+
assert_kind_of ::Array, r[7]
|
363
|
+
assert_equal [ '/' ], r[7]
|
364
|
+
|
365
|
+
r = F.split_path '/..'
|
366
|
+
|
367
|
+
assert_kind_of ::Array, r
|
368
|
+
assert_equal 8, r.size
|
369
|
+
assert_equal '/..', r[0]
|
370
|
+
assert_nil r[1]
|
371
|
+
assert_equal '/', r[2]
|
372
|
+
assert_equal '..', r[3]
|
373
|
+
assert_equal '..', r[4]
|
374
|
+
assert_nil r[5]
|
375
|
+
assert_kind_of ::Array, r[6]
|
376
|
+
assert_equal [ '/' ], r[6]
|
377
|
+
assert_kind_of ::Array, r[7]
|
378
|
+
assert_equal [ '/' ], r[7]
|
379
|
+
|
380
|
+
r = F.split_path './..'
|
381
|
+
|
382
|
+
assert_kind_of ::Array, r
|
383
|
+
assert_equal 8, r.size
|
384
|
+
assert_equal './..', r[0]
|
385
|
+
assert_nil r[1]
|
386
|
+
assert_equal './', r[2]
|
387
|
+
assert_equal '..', r[3]
|
388
|
+
assert_equal '..', r[4]
|
389
|
+
assert_nil r[5]
|
390
|
+
assert_kind_of ::Array, r[6]
|
391
|
+
assert_equal [ './' ], r[6]
|
392
|
+
assert_kind_of ::Array, r[7]
|
393
|
+
assert_equal [ './' ], r[7]
|
394
|
+
end
|
395
395
|
end
|
396
396
|
|
397
|
+
|
398
|
+
# ############################## end of file ############################# #
|
399
|
+
|