libpath-ruby 0.2.2 → 0.2.2.1

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 +71 -71
  7. data/lib/libpath/constants/windows.rb +72 -72
  8. data/lib/libpath/constants.rb +18 -19
  9. data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
  13. data/lib/libpath/exceptions.rb +1 -1
  14. data/lib/libpath/form/unix.rb +104 -103
  15. data/lib/libpath/form/windows.rb +200 -199
  16. data/lib/libpath/form.rb +18 -18
  17. data/lib/libpath/internal_/array.rb +53 -53
  18. data/lib/libpath/internal_/platform.rb +24 -24
  19. data/lib/libpath/internal_/string.rb +18 -18
  20. data/lib/libpath/internal_/unix/form.rb +116 -116
  21. data/lib/libpath/internal_/windows/drive.rb +59 -59
  22. data/lib/libpath/internal_/windows/form.rb +189 -189
  23. data/lib/libpath/libpath.rb +3 -0
  24. data/lib/libpath/path/unix.rb +114 -112
  25. data/lib/libpath/path/windows.rb +120 -118
  26. data/lib/libpath/path.rb +18 -20
  27. data/lib/libpath/util/unix.rb +258 -258
  28. data/lib/libpath/util/windows.rb +400 -400
  29. data/lib/libpath/util.rb +18 -19
  30. data/lib/libpath/version.rb +23 -24
  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
@@ -2,227 +2,231 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *(['..'] * 3), 'lib')
4
4
 
5
+
5
6
  require 'libpath/util'
6
7
 
7
8
  require 'test/unit'
8
9
 
9
10
  require 'libpath/internal_/platform'
10
11
 
12
+
11
13
  class Test_LibPath_Util_make_path_canonical_via_extend < Test::Unit::TestCase
12
14
 
13
- F = ::LibPath::Util
15
+ F = ::LibPath::Util
14
16
 
15
- def test_empty
17
+ def test_empty
16
18
 
17
- assert_equal '', F.make_path_canonical('')
18
- end
19
+ assert_equal '', F.make_path_canonical('')
20
+ end
19
21
 
20
- def test_root
22
+ def test_root
21
23
 
22
- assert_equal '/', F.make_path_canonical('/')
24
+ assert_equal '/', F.make_path_canonical('/')
23
25
 
24
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
26
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
25
27
 
26
- assert_equal '\\', F.make_path_canonical('//')
27
- else
28
+ assert_equal '\\', F.make_path_canonical('//')
29
+ else
28
30
 
29
- assert_equal '/', F.make_path_canonical('//')
30
- end
31
- end
31
+ assert_equal '/', F.make_path_canonical('//')
32
+ end
33
+ end
32
34
 
33
- def test_one_dot
35
+ def test_one_dot
34
36
 
35
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
37
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
36
38
 
37
- assert_equal '.\\', F.make_path_canonical('.')
39
+ assert_equal '.\\', F.make_path_canonical('.')
38
40
 
39
- assert_equal '.\\', F.make_path_canonical('.\\')
40
- assert_equal '.\\', F.make_path_canonical('.\\', make_slashes_canonical: true)
41
+ assert_equal '.\\', F.make_path_canonical('.\\')
42
+ assert_equal '.\\', F.make_path_canonical('.\\', make_slashes_canonical: true)
41
43
 
42
- assert_equal './', F.make_path_canonical('./')
43
- assert_equal '.\\', F.make_path_canonical('.\\', make_slashes_canonical: true)
44
- else
44
+ assert_equal './', F.make_path_canonical('./')
45
+ assert_equal '.\\', F.make_path_canonical('.\\', make_slashes_canonical: true)
46
+ else
45
47
 
46
- assert_equal './', F.make_path_canonical('.')
48
+ assert_equal './', F.make_path_canonical('.')
47
49
 
48
- assert_equal './', F.make_path_canonical('./')
49
- assert_equal './', F.make_path_canonical('./', make_slashes_canonical: true)
50
- end
51
- end
50
+ assert_equal './', F.make_path_canonical('./')
51
+ assert_equal './', F.make_path_canonical('./', make_slashes_canonical: true)
52
+ end
53
+ end
52
54
 
53
- def test_two_dots
55
+ def test_two_dots
54
56
 
55
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
57
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
56
58
 
57
- assert_equal '..\\', F.make_path_canonical('..')
58
- assert_equal '..\\', F.make_path_canonical('..//')
59
- assert_equal '../', F.make_path_canonical('../')
59
+ assert_equal '..\\', F.make_path_canonical('..')
60
+ assert_equal '..\\', F.make_path_canonical('..//')
61
+ assert_equal '../', F.make_path_canonical('../')
60
62
 
61
- assert_equal '/dir.14/', F.make_path_canonical('/dir.14/dir.2/..')
62
- assert_equal 'dir.14/', F.make_path_canonical('dir.14/dir.2/..')
63
+ assert_equal '/dir.14/', F.make_path_canonical('/dir.14/dir.2/..')
64
+ assert_equal 'dir.14/', F.make_path_canonical('dir.14/dir.2/..')
63
65
 
64
- assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../..')
65
- assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../../..')
66
- assert_equal '.\\', F.make_path_canonical('dir.14/dir.2/../..')
66
+ assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../..')
67
+ assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../../..')
68
+ assert_equal '.\\', F.make_path_canonical('dir.14/dir.2/../..')
67
69
 
68
- assert_equal '\\', F.make_path_canonical('\\dir.14\\dir.2\\..\\..')
69
- assert_equal '\\', F.make_path_canonical('\\dir.14\\dir.2\\..\\..\\..')
70
- assert_equal '.\\', F.make_path_canonical('dir.14\\dir.2\\..\\..')
71
- else
70
+ assert_equal '\\', F.make_path_canonical('\\dir.14\\dir.2\\..\\..')
71
+ assert_equal '\\', F.make_path_canonical('\\dir.14\\dir.2\\..\\..\\..')
72
+ assert_equal '.\\', F.make_path_canonical('dir.14\\dir.2\\..\\..')
73
+ else
72
74
 
73
- assert_equal '../', F.make_path_canonical('..')
74
- assert_equal '../', F.make_path_canonical('../')
75
+ assert_equal '../', F.make_path_canonical('..')
76
+ assert_equal '../', F.make_path_canonical('../')
75
77
 
76
- assert_equal '/dir.14/', F.make_path_canonical('/dir.14/dir.2/..')
77
- assert_equal 'dir.14/', F.make_path_canonical('dir.14/dir.2/..')
78
+ assert_equal '/dir.14/', F.make_path_canonical('/dir.14/dir.2/..')
79
+ assert_equal 'dir.14/', F.make_path_canonical('dir.14/dir.2/..')
78
80
 
79
- assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../..')
80
- assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../../..')
81
- assert_equal './', F.make_path_canonical('dir.14/dir.2/../..')
82
- end
81
+ assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../..')
82
+ assert_equal '/', F.make_path_canonical('/dir.14/dir.2/../../..')
83
+ assert_equal './', F.make_path_canonical('dir.14/dir.2/../..')
84
+ end
83
85
 
84
- end
86
+ end
85
87
 
86
- def test_redundant_slashes
88
+ def test_redundant_slashes
87
89
 
88
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
90
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
89
91
 
90
- assert_equal '.\\', F.make_path_canonical('.//')
91
- assert_equal '.\\', F.make_path_canonical('.\\\\')
92
+ assert_equal '.\\', F.make_path_canonical('.//')
93
+ assert_equal '.\\', F.make_path_canonical('.\\\\')
92
94
 
93
- assert_equal '..\\', F.make_path_canonical('..//')
94
- else
95
+ assert_equal '..\\', F.make_path_canonical('..//')
96
+ else
95
97
 
96
- assert_equal './', F.make_path_canonical('.//')
98
+ assert_equal './', F.make_path_canonical('.//')
97
99
 
98
- assert_equal '../', F.make_path_canonical('..//')
99
- end
100
- end
100
+ assert_equal '../', F.make_path_canonical('..//')
101
+ end
102
+ end
101
103
 
102
- def test_basenames
104
+ def test_basenames
103
105
 
104
- assert_equal 'a', F.make_path_canonical('a')
106
+ assert_equal 'a', F.make_path_canonical('a')
105
107
 
106
- assert_equal 'file.ext', F.make_path_canonical('file.ext')
107
- end
108
+ assert_equal 'file.ext', F.make_path_canonical('file.ext')
109
+ end
108
110
 
109
- def test_trailing_dots
111
+ def test_trailing_dots
110
112
 
111
- assert_equal 'a.', F.make_path_canonical('a.')
112
- assert_equal 'a.', F.make_path_canonical('./a.')
113
- assert_equal 'a.', F.make_path_canonical('././././a.')
114
- assert_equal 'a.', F.make_path_canonical('abc/../a.')
113
+ assert_equal 'a.', F.make_path_canonical('a.')
114
+ assert_equal 'a.', F.make_path_canonical('./a.')
115
+ assert_equal 'a.', F.make_path_canonical('././././a.')
116
+ assert_equal 'a.', F.make_path_canonical('abc/../a.')
115
117
 
116
- assert_equal 'a..', F.make_path_canonical('a..')
117
- assert_equal 'a..', F.make_path_canonical('./a..')
118
- assert_equal 'a..', F.make_path_canonical('././././a..')
119
- assert_equal 'a..', F.make_path_canonical('abc/../a..')
120
- assert_equal 'a..', F.make_path_canonical('abc//../a..')
118
+ assert_equal 'a..', F.make_path_canonical('a..')
119
+ assert_equal 'a..', F.make_path_canonical('./a..')
120
+ assert_equal 'a..', F.make_path_canonical('././././a..')
121
+ assert_equal 'a..', F.make_path_canonical('abc/../a..')
122
+ assert_equal 'a..', F.make_path_canonical('abc//../a..')
121
123
 
122
- assert_equal 'a...', F.make_path_canonical('a...')
123
- assert_equal 'a...', F.make_path_canonical('./a...')
124
- assert_equal 'a...', F.make_path_canonical('././././a...')
125
- assert_equal 'a...', F.make_path_canonical('abc/../a...')
124
+ assert_equal 'a...', F.make_path_canonical('a...')
125
+ assert_equal 'a...', F.make_path_canonical('./a...')
126
+ assert_equal 'a...', F.make_path_canonical('././././a...')
127
+ assert_equal 'a...', F.make_path_canonical('abc/../a...')
126
128
 
127
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
129
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
128
130
 
129
- assert_equal 'a.', F.make_path_canonical('a.')
130
- assert_equal 'a.', F.make_path_canonical('.\\a.')
131
- assert_equal 'a.', F.make_path_canonical('.\\.\\.\\.\\a.')
132
- assert_equal 'a.', F.make_path_canonical('abc\\..\\a.')
131
+ assert_equal 'a.', F.make_path_canonical('a.')
132
+ assert_equal 'a.', F.make_path_canonical('.\\a.')
133
+ assert_equal 'a.', F.make_path_canonical('.\\.\\.\\.\\a.')
134
+ assert_equal 'a.', F.make_path_canonical('abc\\..\\a.')
133
135
 
134
- assert_equal 'a..', F.make_path_canonical('a..')
135
- assert_equal 'a..', F.make_path_canonical('.\\a..')
136
- assert_equal 'a..', F.make_path_canonical('.\\.\\.\\.\\a..')
137
- assert_equal 'a..', F.make_path_canonical('abc\\..\\a..')
136
+ assert_equal 'a..', F.make_path_canonical('a..')
137
+ assert_equal 'a..', F.make_path_canonical('.\\a..')
138
+ assert_equal 'a..', F.make_path_canonical('.\\.\\.\\.\\a..')
139
+ assert_equal 'a..', F.make_path_canonical('abc\\..\\a..')
138
140
 
139
- assert_equal 'a...', F.make_path_canonical('a...')
140
- assert_equal 'a...', F.make_path_canonical('.\\a...')
141
- assert_equal 'a...', F.make_path_canonical('.\\.\\.\\.\\a...')
142
- assert_equal 'a...', F.make_path_canonical('abc\\..\\a...')
143
- end
144
- end
141
+ assert_equal 'a...', F.make_path_canonical('a...')
142
+ assert_equal 'a...', F.make_path_canonical('.\\a...')
143
+ assert_equal 'a...', F.make_path_canonical('.\\.\\.\\.\\a...')
144
+ assert_equal 'a...', F.make_path_canonical('abc\\..\\a...')
145
+ end
146
+ end
145
147
 
146
- def test_one_dots_directory
148
+ def test_one_dots_directory
147
149
 
148
- assert_equal 'abc', F.make_path_canonical('./abc')
150
+ assert_equal 'abc', F.make_path_canonical('./abc')
149
151
 
150
- assert_equal 'abc', F.make_path_canonical('././abc')
151
- assert_equal 'abc', F.make_path_canonical('././/abc')
152
- assert_equal 'abc', F.make_path_canonical('././//////////////////abc')
152
+ assert_equal 'abc', F.make_path_canonical('././abc')
153
+ assert_equal 'abc', F.make_path_canonical('././/abc')
154
+ assert_equal 'abc', F.make_path_canonical('././//////////////////abc')
153
155
 
154
- assert_equal 'abc', F.make_path_canonical('./././././././././abc')
156
+ assert_equal 'abc', F.make_path_canonical('./././././././././abc')
155
157
 
156
- assert_equal 'abc/', F.make_path_canonical('abc/./')
158
+ assert_equal 'abc/', F.make_path_canonical('abc/./')
157
159
 
158
- assert_equal 'abc/', F.make_path_canonical('./abc/./')
160
+ assert_equal 'abc/', F.make_path_canonical('./abc/./')
159
161
 
160
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
162
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
161
163
 
162
- assert_equal 'abc', F.make_path_canonical('.\\abc')
164
+ assert_equal 'abc', F.make_path_canonical('.\\abc')
163
165
 
164
- assert_equal 'abc', F.make_path_canonical('.\\.\\abc')
166
+ assert_equal 'abc', F.make_path_canonical('.\\.\\abc')
165
167
 
166
- assert_equal 'abc', F.make_path_canonical('.\\.\\.\\.\\.\\.\\.\\.\\.\\abc')
168
+ assert_equal 'abc', F.make_path_canonical('.\\.\\.\\.\\.\\.\\.\\.\\.\\abc')
167
169
 
168
- assert_equal 'abc\\', F.make_path_canonical('abc/./', make_slashes_canonical: true)
170
+ assert_equal 'abc\\', F.make_path_canonical('abc/./', make_slashes_canonical: true)
169
171
 
170
- assert_equal 'abc\\', F.make_path_canonical('abc\\.\\')
172
+ assert_equal 'abc\\', F.make_path_canonical('abc\\.\\')
171
173
 
172
- assert_equal 'abc\\', F.make_path_canonical('.\\abc\\.\\')
174
+ assert_equal 'abc\\', F.make_path_canonical('.\\abc\\.\\')
173
175
 
174
- assert_equal 'abc\\', F.make_path_canonical('./abc/./', make_slashes_canonical: true)
175
- end
176
- end
176
+ assert_equal 'abc\\', F.make_path_canonical('./abc/./', make_slashes_canonical: true)
177
+ end
178
+ end
177
179
 
178
- def test_two_dots_directories
180
+ def test_two_dots_directories
179
181
 
180
- assert_equal '../', F.make_path_canonical('../')
182
+ assert_equal '../', F.make_path_canonical('../')
181
183
 
182
- assert_equal '../abc', F.make_path_canonical('../abc')
184
+ assert_equal '../abc', F.make_path_canonical('../abc')
183
185
 
184
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
186
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
185
187
 
186
- assert_equal '.\\', F.make_path_canonical('abc/..')
187
- else
188
+ assert_equal '.\\', F.make_path_canonical('abc/..')
189
+ else
188
190
 
189
- assert_equal './', F.make_path_canonical('abc/..')
190
- end
191
+ assert_equal './', F.make_path_canonical('abc/..')
192
+ end
191
193
 
192
- assert_equal './', F.make_path_canonical('abc/../')
194
+ assert_equal './', F.make_path_canonical('abc/../')
193
195
 
194
- assert_equal 'def', F.make_path_canonical('abc/../def')
196
+ assert_equal 'def', F.make_path_canonical('abc/../def')
195
197
 
196
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
198
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
197
199
 
198
- assert_equal '.\\', F.make_path_canonical('abc/../def/..')
199
- else
200
+ assert_equal '.\\', F.make_path_canonical('abc/../def/..')
201
+ else
200
202
 
201
- assert_equal './', F.make_path_canonical('abc/../def/..')
202
- end
203
+ assert_equal './', F.make_path_canonical('abc/../def/..')
204
+ end
203
205
 
204
- assert_equal './', F.make_path_canonical('abc/../def/../')
206
+ assert_equal './', F.make_path_canonical('abc/../def/../')
205
207
 
206
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
208
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
207
209
 
208
- assert_equal '..\\', F.make_path_canonical('..\\')
210
+ assert_equal '..\\', F.make_path_canonical('..\\')
209
211
 
210
- assert_equal '..\\abc', F.make_path_canonical('..\\abc')
212
+ assert_equal '..\\abc', F.make_path_canonical('..\\abc')
211
213
 
212
- assert_equal '.\\', F.make_path_canonical('abc\\..')
214
+ assert_equal '.\\', F.make_path_canonical('abc\\..')
213
215
 
214
- assert_equal '.\\', F.make_path_canonical('abc\\..\\')
216
+ assert_equal '.\\', F.make_path_canonical('abc\\..\\')
215
217
 
216
- assert_equal 'def', F.make_path_canonical('abc\\..\\def')
217
- assert_equal 'def', F.make_path_canonical('abc\\\\..\\def')
218
+ assert_equal 'def', F.make_path_canonical('abc\\..\\def')
219
+ assert_equal 'def', F.make_path_canonical('abc\\\\..\\def')
218
220
 
219
- assert_equal '.\\', F.make_path_canonical('abc\\..\\def\\..')
221
+ assert_equal '.\\', F.make_path_canonical('abc\\..\\def\\..')
220
222
 
221
- assert_equal '.\\', F.make_path_canonical('abc\\..\\def\\..\\')
222
- assert_equal '.\\', F.make_path_canonical('abc\\\\..\\def\\..\\')
223
- assert_equal '.\\', F.make_path_canonical('abc\\..\\\\def\\..\\')
224
- end
225
- end
223
+ assert_equal '.\\', F.make_path_canonical('abc\\..\\def\\..\\')
224
+ assert_equal '.\\', F.make_path_canonical('abc\\\\..\\def\\..\\')
225
+ assert_equal '.\\', F.make_path_canonical('abc\\..\\\\def\\..\\')
226
+ end
227
+ end
226
228
  end
227
229
 
228
230
 
231
+ # ############################## end of file ############################# #
232
+
@@ -7,16 +7,16 @@ this_dir = File.expand_path(File.dirname(__FILE__))
7
7
  # all tc_*rb in current directory
8
8
  Dir[File.join(this_dir, 'tc_*rb')].each do |file|
9
9
 
10
- $stderr.puts "requiring file '#{file}'" if $DEBUG
10
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
11
11
 
12
- require file
12
+ require file
13
13
  end
14
14
 
15
15
  # all ts_*rb in immediate sub-directories
16
16
  Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
17
17
 
18
- $stderr.puts "requiring file '#{file}'" if $DEBUG
18
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
19
19
 
20
- require file
20
+ require file
21
21
  end
22
22
 
@@ -6,60 +6,64 @@ require 'libpath/util/unix'
6
6
 
7
7
  require 'test/unit'
8
8
 
9
+
9
10
  class Test_LibPath_Util_Unix_combine_paths < Test::Unit::TestCase
10
11
 
11
- F = ::LibPath::Util::Unix
12
+ F = ::LibPath::Util::Unix
12
13
 
13
- def test_no_arguments
14
+ def test_no_arguments
14
15
 
15
- assert_equal '', F.combine_paths()
16
- end
16
+ assert_equal '', F.combine_paths()
17
+ end
17
18
 
18
- def test_single_argument
19
+ def test_single_argument
19
20
 
20
- assert_equal ' ', F.combine_paths(' ')
21
- assert_equal 'a', F.combine_paths('a')
22
- assert_equal 'abcdef/ghi/jkl.mno', F.combine_paths('abcdef/ghi/jkl.mno')
23
- assert_equal '/', F.combine_paths('/')
24
- end
21
+ assert_equal ' ', F.combine_paths(' ')
22
+ assert_equal 'a', F.combine_paths('a')
23
+ assert_equal 'abcdef/ghi/jkl.mno', F.combine_paths('abcdef/ghi/jkl.mno')
24
+ assert_equal '/', F.combine_paths('/')
25
+ end
25
26
 
26
- def test_relative_cases
27
+ def test_relative_cases
27
28
 
28
- assert_equal 'a/b/c/d', F.combine_paths('a', 'b', 'c/d')
29
- assert_equal 'a/b/c/d', F.combine_paths('a', 'b/', 'c/d')
29
+ assert_equal 'a/b/c/d', F.combine_paths('a', 'b', 'c/d')
30
+ assert_equal 'a/b/c/d', F.combine_paths('a', 'b/', 'c/d')
30
31
 
31
- assert_equal 'a/b', F.combine_paths('', 'a', '', '', 'b')
32
+ assert_equal 'a/b', F.combine_paths('', 'a', '', '', 'b')
32
33
 
33
- assert_equal 'a/ /b', F.combine_paths('', 'a', '', ' ', 'b')
34
- end
34
+ assert_equal 'a/ /b', F.combine_paths('', 'a', '', ' ', 'b')
35
+ end
35
36
 
36
- def test_tail_absolute_cases
37
+ def test_tail_absolute_cases
37
38
 
38
- assert_equal '/', F.combine_paths('a', '/')
39
+ assert_equal '/', F.combine_paths('a', '/')
39
40
 
40
- assert_equal '/', F.combine_paths('a/b/c/d', '/')
41
+ assert_equal '/', F.combine_paths('a/b/c/d', '/')
41
42
 
42
- assert_equal '/', F.combine_paths('a', 'b', '/')
43
- end
43
+ assert_equal '/', F.combine_paths('a', 'b', '/')
44
+ end
44
45
 
45
- def test_dots
46
+ def test_dots
46
47
 
47
- assert_equal 'a/.', F.combine_paths('a', '.')
48
- assert_equal 'a', F.combine_paths('a', '.', elide_single_dots: true)
48
+ assert_equal 'a/.', F.combine_paths('a', '.')
49
+ assert_equal 'a', F.combine_paths('a', '.', elide_single_dots: true)
49
50
 
50
- assert_equal 'a/b', F.combine_paths('a', '.', 'b', elide_single_dots: true)
51
- assert_equal 'a/b', F.combine_paths('a', './', 'b', elide_single_dots: true)
52
- assert_equal '/./b', F.combine_paths('a', '/.', 'b', elide_single_dots: true)
53
- end
51
+ assert_equal 'a/b', F.combine_paths('a', '.', 'b', elide_single_dots: true)
52
+ assert_equal 'a/b', F.combine_paths('a', './', 'b', elide_single_dots: true)
53
+ assert_equal '/./b', F.combine_paths('a', '/.', 'b', elide_single_dots: true)
54
+ end
54
55
 
55
- def test_embedded_absolute_cases
56
+ def test_embedded_absolute_cases
56
57
 
57
- assert_equal '/a/b/c/d', F.combine_paths('x/y/z', 'z', '/a', 'b', 'c/d')
58
- end
58
+ assert_equal '/a/b/c/d', F.combine_paths('x/y/z', 'z', '/a', 'b', 'c/d')
59
+ end
59
60
 
60
- def test_multiple_embedded_absolute_cases
61
+ def test_multiple_embedded_absolute_cases
61
62
 
62
- assert_equal '/a/b/c/d', F.combine_paths('x/y/z', '/z', '/a', 'b', 'c/d')
63
- end
63
+ assert_equal '/a/b/c/d', F.combine_paths('x/y/z', '/z', '/a', 'b', 'c/d')
64
+ end
64
65
  end
65
66
 
67
+
68
+ # ############################## end of file ############################# #
69
+