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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +33 -0
  3. data/README.md +25 -8
  4. data/examples/path_from_arg0.md +43 -43
  5. data/examples/path_from_arg0.rb +25 -23
  6. data/lib/libpath/constants/unix.rb +74 -74
  7. data/lib/libpath/constants/windows.rb +75 -75
  8. data/lib/libpath/constants.rb +20 -20
  9. data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
  13. data/lib/libpath/exceptions.rb +1 -1
  14. data/lib/libpath/form/unix.rb +118 -118
  15. data/lib/libpath/form/windows.rb +228 -214
  16. data/lib/libpath/form.rb +20 -21
  17. data/lib/libpath/internal_/array.rb +57 -57
  18. data/lib/libpath/internal_/platform.rb +30 -31
  19. data/lib/libpath/internal_/string.rb +25 -20
  20. data/lib/libpath/internal_/unix/form.rb +124 -119
  21. data/lib/libpath/internal_/windows/drive.rb +80 -75
  22. data/lib/libpath/internal_/windows/form.rb +205 -194
  23. data/lib/libpath/libpath.rb +4 -1
  24. data/lib/libpath/path/unix.rb +120 -118
  25. data/lib/libpath/path/windows.rb +126 -124
  26. data/lib/libpath/path.rb +21 -21
  27. data/lib/libpath/util/unix.rb +261 -261
  28. data/lib/libpath/util/windows.rb +403 -403
  29. data/lib/libpath/util.rb +20 -20
  30. data/lib/libpath/version.rb +25 -26
  31. data/lib/libpath.rb +1 -1
  32. data/test/performance/benchmark_drive_letter.rb +50 -10
  33. data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
  34. data/test/performance/benchmark_rindex2.rb +56 -48
  35. data/test/performance/benchmark_split.rb +16 -10
  36. data/test/unit/compare/ts_all.rb +4 -4
  37. data/test/unit/equate/ts_all.rb +4 -4
  38. data/test/unit/equate/unix/ts_all.rb +4 -4
  39. data/test/unit/equate/windows/ts_all.rb +4 -4
  40. data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
  41. data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
  42. data/test/unit/exceptions/ts_all.rb +4 -4
  43. data/test/unit/form/tc_absolute_functions.rb +242 -240
  44. data/test/unit/form/ts_all.rb +4 -4
  45. data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
  46. data/test/unit/form/unix/ts_all.rb +4 -4
  47. data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
  48. data/test/unit/form/windows/ts_all.rb +4 -4
  49. data/test/unit/internal_/tc_array.rb +36 -32
  50. data/test/unit/internal_/ts_all.rb +4 -4
  51. data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
  52. data/test/unit/internal_/unix/form/ts_all.rb +4 -4
  53. data/test/unit/internal_/unix/tc_split_path.rb +387 -384
  54. data/test/unit/internal_/unix/ts_all.rb +4 -4
  55. data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
  56. data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
  57. data/test/unit/internal_/windows/form/ts_all.rb +4 -4
  58. data/test/unit/internal_/windows/tc_split_path.rb +874 -869
  59. data/test/unit/internal_/windows/ts_all.rb +4 -4
  60. data/test/unit/parse/ts_all.rb +4 -4
  61. data/test/unit/path/tc_path.rb +732 -732
  62. data/test/unit/path/ts_all.rb +4 -4
  63. data/test/unit/path/unix/tc_path.rb +544 -540
  64. data/test/unit/path/unix/ts_all.rb +4 -4
  65. data/test/unit/path/windows/tc_path.rb +608 -603
  66. data/test/unit/path/windows/ts_all.rb +4 -4
  67. data/test/unit/tc_version.rb +25 -22
  68. data/test/unit/ts_all.rb +4 -4
  69. data/test/unit/util/tc_combine_paths.rb +110 -105
  70. data/test/unit/util/tc_derive_relative_path.rb +8 -3
  71. data/test/unit/util/tc_make_path_canonical.rb +142 -138
  72. data/test/unit/util/ts_all.rb +4 -4
  73. data/test/unit/util/unix/tc_combine_paths.rb +38 -34
  74. data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
  75. data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
  76. data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
  77. data/test/unit/util/unix/ts_all.rb +4 -4
  78. data/test/unit/util/windows/tc_combine_paths.rb +82 -77
  79. data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
  80. data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
  81. data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
  82. data/test/unit/util/windows/ts_all.rb +4 -4
  83. 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
- 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
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
+