@@ -86,193 +86,193 @@ fn main() {
86
86
87
87
// all recursive entities
88
88
assert_eq ! ( glob_vec( "r/**" ) , vec!(
89
- abs_path ( "r/another" ) ,
90
- abs_path ( "r/another/a.md" ) ,
91
- abs_path ( "r/current_dir.md" ) ,
92
- abs_path ( "r/one" ) ,
93
- abs_path ( "r/one/a.md" ) ,
94
- abs_path ( "r/one/another" ) ,
95
- abs_path ( "r/one/another/a.md" ) ,
96
- abs_path ( "r/three" ) ,
97
- abs_path ( "r/three/c.md" ) ,
98
- abs_path ( "r/two" ) ,
99
- abs_path ( "r/two/b.md" ) ) ) ;
89
+ Path :: new ( "r/another" ) ,
90
+ Path :: new ( "r/another/a.md" ) ,
91
+ Path :: new ( "r/current_dir.md" ) ,
92
+ Path :: new ( "r/one" ) ,
93
+ Path :: new ( "r/one/a.md" ) ,
94
+ Path :: new ( "r/one/another" ) ,
95
+ Path :: new ( "r/one/another/a.md" ) ,
96
+ Path :: new ( "r/three" ) ,
97
+ Path :: new ( "r/three/c.md" ) ,
98
+ Path :: new ( "r/two" ) ,
99
+ Path :: new ( "r/two/b.md" ) ) ) ;
100
100
101
101
// collapse consecutive recursive patterns
102
102
assert_eq ! ( glob_vec( "r/**/**" ) , vec!(
103
- abs_path ( "r/another" ) ,
104
- abs_path ( "r/another/a.md" ) ,
105
- abs_path ( "r/current_dir.md" ) ,
106
- abs_path ( "r/one" ) ,
107
- abs_path ( "r/one/a.md" ) ,
108
- abs_path ( "r/one/another" ) ,
109
- abs_path ( "r/one/another/a.md" ) ,
110
- abs_path ( "r/three" ) ,
111
- abs_path ( "r/three/c.md" ) ,
112
- abs_path ( "r/two" ) ,
113
- abs_path ( "r/two/b.md" ) ) ) ;
103
+ Path :: new ( "r/another" ) ,
104
+ Path :: new ( "r/another/a.md" ) ,
105
+ Path :: new ( "r/current_dir.md" ) ,
106
+ Path :: new ( "r/one" ) ,
107
+ Path :: new ( "r/one/a.md" ) ,
108
+ Path :: new ( "r/one/another" ) ,
109
+ Path :: new ( "r/one/another/a.md" ) ,
110
+ Path :: new ( "r/three" ) ,
111
+ Path :: new ( "r/three/c.md" ) ,
112
+ Path :: new ( "r/two" ) ,
113
+ Path :: new ( "r/two/b.md" ) ) ) ;
114
114
115
115
// followed by a wildcard
116
116
assert_eq ! ( glob_vec( "r/**/*.md" ) , vec!(
117
- abs_path ( "r/another/a.md" ) ,
118
- abs_path ( "r/current_dir.md" ) ,
119
- abs_path ( "r/one/a.md" ) ,
120
- abs_path ( "r/one/another/a.md" ) ,
121
- abs_path ( "r/three/c.md" ) ,
122
- abs_path ( "r/two/b.md" ) ) ) ;
117
+ Path :: new ( "r/another/a.md" ) ,
118
+ Path :: new ( "r/current_dir.md" ) ,
119
+ Path :: new ( "r/one/a.md" ) ,
120
+ Path :: new ( "r/one/another/a.md" ) ,
121
+ Path :: new ( "r/three/c.md" ) ,
122
+ Path :: new ( "r/two/b.md" ) ) ) ;
123
123
124
124
// followed by a precise pattern
125
125
assert_eq ! ( glob_vec( "r/one/**/a.md" ) , vec!(
126
- abs_path ( "r/one/a.md" ) ,
127
- abs_path ( "r/one/another/a.md" ) ) ) ;
126
+ Path :: new ( "r/one/a.md" ) ,
127
+ Path :: new ( "r/one/another/a.md" ) ) ) ;
128
128
129
129
// followed by another recursive pattern
130
130
// collapses consecutive recursives into one
131
131
assert_eq ! ( glob_vec( "r/one/**/**/a.md" ) , vec!(
132
- abs_path ( "r/one/a.md" ) ,
133
- abs_path ( "r/one/another/a.md" ) ) ) ;
132
+ Path :: new ( "r/one/a.md" ) ,
133
+ Path :: new ( "r/one/another/a.md" ) ) ) ;
134
134
135
135
// followed by two precise patterns
136
136
assert_eq ! ( glob_vec( "r/**/another/a.md" ) , vec!(
137
- abs_path ( "r/another/a.md" ) ,
138
- abs_path ( "r/one/another/a.md" ) ) ) ;
137
+ Path :: new ( "r/another/a.md" ) ,
138
+ Path :: new ( "r/one/another/a.md" ) ) ) ;
139
139
140
140
assert_eq ! ( glob_vec( "" ) , Vec :: new( ) ) ;
141
- assert_eq ! ( glob_vec( "." ) , vec!( os :: getcwd ( ) . unwrap ( ) ) ) ;
142
- assert_eq ! ( glob_vec( ".." ) , vec!( os :: getcwd ( ) . unwrap ( ) . join ( ".." ) ) ) ;
141
+ assert_eq ! ( glob_vec( "." ) , vec!( Path :: new ( "." ) ) ) ;
142
+ assert_eq ! ( glob_vec( ".." ) , vec!( Path :: new ( ".." ) ) ) ;
143
143
144
- assert_eq ! ( glob_vec( "aaa" ) , vec!( abs_path ( "aaa" ) ) ) ;
145
- assert_eq ! ( glob_vec( "aaa/" ) , vec!( abs_path ( "aaa" ) ) ) ;
144
+ assert_eq ! ( glob_vec( "aaa" ) , vec!( Path :: new ( "aaa" ) ) ) ;
145
+ assert_eq ! ( glob_vec( "aaa/" ) , vec!( Path :: new ( "aaa" ) ) ) ;
146
146
assert_eq ! ( glob_vec( "a" ) , Vec :: new( ) ) ;
147
147
assert_eq ! ( glob_vec( "aa" ) , Vec :: new( ) ) ;
148
148
assert_eq ! ( glob_vec( "aaaa" ) , Vec :: new( ) ) ;
149
149
150
- assert_eq ! ( glob_vec( "aaa/apple" ) , vec!( abs_path ( "aaa/apple" ) ) ) ;
150
+ assert_eq ! ( glob_vec( "aaa/apple" ) , vec!( Path :: new ( "aaa/apple" ) ) ) ;
151
151
assert_eq ! ( glob_vec( "aaa/apple/nope" ) , Vec :: new( ) ) ;
152
152
153
153
// windows should support both / and \ as directory separators
154
154
if os:: consts:: FAMILY == "windows" {
155
- assert_eq ! ( glob_vec( "aaa\\ apple" ) , vec!( abs_path ( "aaa/apple" ) ) ) ;
155
+ assert_eq ! ( glob_vec( "aaa\\ apple" ) , vec!( Path :: new ( "aaa/apple" ) ) ) ;
156
156
}
157
157
158
158
assert_eq ! ( glob_vec( "???/" ) , vec!(
159
- abs_path ( "aaa" ) ,
160
- abs_path ( "bbb" ) ,
161
- abs_path ( "ccc" ) ,
162
- abs_path ( "xyz" ) ) ) ;
159
+ Path :: new ( "aaa" ) ,
160
+ Path :: new ( "bbb" ) ,
161
+ Path :: new ( "ccc" ) ,
162
+ Path :: new ( "xyz" ) ) ) ;
163
163
164
164
assert_eq ! ( glob_vec( "aaa/tomato/tom?to.txt" ) , vec!(
165
- abs_path ( "aaa/tomato/tomato.txt" ) ,
166
- abs_path ( "aaa/tomato/tomoto.txt" ) ) ) ;
165
+ Path :: new ( "aaa/tomato/tomato.txt" ) ,
166
+ Path :: new ( "aaa/tomato/tomoto.txt" ) ) ) ;
167
167
168
168
assert_eq ! ( glob_vec( "xyz/?" ) , vec!(
169
- abs_path ( "xyz/x" ) ,
170
- abs_path ( "xyz/y" ) ,
171
- abs_path ( "xyz/z" ) ) ) ;
172
-
173
- assert_eq ! ( glob_vec( "a*" ) , vec!( abs_path ( "aaa" ) ) ) ;
174
- assert_eq ! ( glob_vec( "*a*" ) , vec!( abs_path ( "aaa" ) ) ) ;
175
- assert_eq ! ( glob_vec( "a*a" ) , vec!( abs_path ( "aaa" ) ) ) ;
176
- assert_eq ! ( glob_vec( "aaa*" ) , vec!( abs_path ( "aaa" ) ) ) ;
177
- assert_eq ! ( glob_vec( "*aaa" ) , vec!( abs_path ( "aaa" ) ) ) ;
178
- assert_eq ! ( glob_vec( "*aaa*" ) , vec!( abs_path ( "aaa" ) ) ) ;
179
- assert_eq ! ( glob_vec( "*a*a*a*" ) , vec!( abs_path ( "aaa" ) ) ) ;
180
- assert_eq ! ( glob_vec( "aaa*/" ) , vec!( abs_path ( "aaa" ) ) ) ;
169
+ Path :: new ( "xyz/x" ) ,
170
+ Path :: new ( "xyz/y" ) ,
171
+ Path :: new ( "xyz/z" ) ) ) ;
172
+
173
+ assert_eq ! ( glob_vec( "a*" ) , vec!( Path :: new ( "aaa" ) ) ) ;
174
+ assert_eq ! ( glob_vec( "*a*" ) , vec!( Path :: new ( "aaa" ) ) ) ;
175
+ assert_eq ! ( glob_vec( "a*a" ) , vec!( Path :: new ( "aaa" ) ) ) ;
176
+ assert_eq ! ( glob_vec( "aaa*" ) , vec!( Path :: new ( "aaa" ) ) ) ;
177
+ assert_eq ! ( glob_vec( "*aaa" ) , vec!( Path :: new ( "aaa" ) ) ) ;
178
+ assert_eq ! ( glob_vec( "*aaa*" ) , vec!( Path :: new ( "aaa" ) ) ) ;
179
+ assert_eq ! ( glob_vec( "*a*a*a*" ) , vec!( Path :: new ( "aaa" ) ) ) ;
180
+ assert_eq ! ( glob_vec( "aaa*/" ) , vec!( Path :: new ( "aaa" ) ) ) ;
181
181
182
182
assert_eq ! ( glob_vec( "aaa/*" ) , vec!(
183
- abs_path ( "aaa/apple" ) ,
184
- abs_path ( "aaa/orange" ) ,
185
- abs_path ( "aaa/tomato" ) ) ) ;
183
+ Path :: new ( "aaa/apple" ) ,
184
+ Path :: new ( "aaa/orange" ) ,
185
+ Path :: new ( "aaa/tomato" ) ) ) ;
186
186
187
187
assert_eq ! ( glob_vec( "aaa/*a*" ) , vec!(
188
- abs_path ( "aaa/apple" ) ,
189
- abs_path ( "aaa/orange" ) ,
190
- abs_path ( "aaa/tomato" ) ) ) ;
188
+ Path :: new ( "aaa/apple" ) ,
189
+ Path :: new ( "aaa/orange" ) ,
190
+ Path :: new ( "aaa/tomato" ) ) ) ;
191
191
192
192
assert_eq ! ( glob_vec( "*/*/*.txt" ) , vec!(
193
- abs_path ( "aaa/tomato/tomato.txt" ) ,
194
- abs_path ( "aaa/tomato/tomoto.txt" ) ) ) ;
193
+ Path :: new ( "aaa/tomato/tomato.txt" ) ,
194
+ Path :: new ( "aaa/tomato/tomoto.txt" ) ) ) ;
195
195
196
196
assert_eq ! ( glob_vec( "*/*/t[aob]m?to[.]t[!y]t" ) , vec!(
197
- abs_path ( "aaa/tomato/tomato.txt" ) ,
198
- abs_path ( "aaa/tomato/tomoto.txt" ) ) ) ;
197
+ Path :: new ( "aaa/tomato/tomato.txt" ) ,
198
+ Path :: new ( "aaa/tomato/tomoto.txt" ) ) ) ;
199
199
200
- assert_eq ! ( glob_vec( "./aaa" ) , vec!( abs_path ( "aaa" ) ) ) ;
200
+ assert_eq ! ( glob_vec( "./aaa" ) , vec!( Path :: new ( "aaa" ) ) ) ;
201
201
assert_eq ! ( glob_vec( "./*" ) , glob_vec( "*" ) ) ;
202
- assert_eq ! ( glob_vec( "*/.." ) . pop( ) . unwrap( ) , abs_path ( "." ) ) ;
203
- assert_eq ! ( glob_vec( "aaa/../bbb" ) , vec!( abs_path ( "bbb" ) ) ) ;
202
+ assert_eq ! ( glob_vec( "*/.." ) . pop( ) . unwrap( ) , Path :: new ( "." ) ) ;
203
+ assert_eq ! ( glob_vec( "aaa/../bbb" ) , vec!( Path :: new ( "bbb" ) ) ) ;
204
204
assert_eq ! ( glob_vec( "nonexistent/../bbb" ) , Vec :: new( ) ) ;
205
205
assert_eq ! ( glob_vec( "aaa/tomato/tomato.txt/.." ) , Vec :: new( ) ) ;
206
206
207
207
assert_eq ! ( glob_vec( "aaa/tomato/tomato.txt/" ) , Vec :: new( ) ) ;
208
208
209
- assert_eq ! ( glob_vec( "aa[a]" ) , vec!( abs_path ( "aaa" ) ) ) ;
210
- assert_eq ! ( glob_vec( "aa[abc]" ) , vec!( abs_path ( "aaa" ) ) ) ;
211
- assert_eq ! ( glob_vec( "a[bca]a" ) , vec!( abs_path ( "aaa" ) ) ) ;
209
+ assert_eq ! ( glob_vec( "aa[a]" ) , vec!( Path :: new ( "aaa" ) ) ) ;
210
+ assert_eq ! ( glob_vec( "aa[abc]" ) , vec!( Path :: new ( "aaa" ) ) ) ;
211
+ assert_eq ! ( glob_vec( "a[bca]a" ) , vec!( Path :: new ( "aaa" ) ) ) ;
212
212
assert_eq ! ( glob_vec( "aa[b]" ) , Vec :: new( ) ) ;
213
213
assert_eq ! ( glob_vec( "aa[xyz]" ) , Vec :: new( ) ) ;
214
214
assert_eq ! ( glob_vec( "aa[]]" ) , Vec :: new( ) ) ;
215
215
216
- assert_eq ! ( glob_vec( "aa[!b]" ) , vec!( abs_path ( "aaa" ) ) ) ;
217
- assert_eq ! ( glob_vec( "aa[!bcd]" ) , vec!( abs_path ( "aaa" ) ) ) ;
218
- assert_eq ! ( glob_vec( "a[!bcd]a" ) , vec!( abs_path ( "aaa" ) ) ) ;
216
+ assert_eq ! ( glob_vec( "aa[!b]" ) , vec!( Path :: new ( "aaa" ) ) ) ;
217
+ assert_eq ! ( glob_vec( "aa[!bcd]" ) , vec!( Path :: new ( "aaa" ) ) ) ;
218
+ assert_eq ! ( glob_vec( "a[!bcd]a" ) , vec!( Path :: new ( "aaa" ) ) ) ;
219
219
assert_eq ! ( glob_vec( "aa[!a]" ) , Vec :: new( ) ) ;
220
220
assert_eq ! ( glob_vec( "aa[!abc]" ) , Vec :: new( ) ) ;
221
221
222
- assert_eq ! ( glob_vec( "bbb/specials/[[]" ) , vec!( abs_path ( "bbb/specials/[" ) ) ) ;
223
- assert_eq ! ( glob_vec( "bbb/specials/!" ) , vec!( abs_path ( "bbb/specials/!" ) ) ) ;
224
- assert_eq ! ( glob_vec( "bbb/specials/[]]" ) , vec!( abs_path ( "bbb/specials/]" ) ) ) ;
222
+ assert_eq ! ( glob_vec( "bbb/specials/[[]" ) , vec!( Path :: new ( "bbb/specials/[" ) ) ) ;
223
+ assert_eq ! ( glob_vec( "bbb/specials/!" ) , vec!( Path :: new ( "bbb/specials/!" ) ) ) ;
224
+ assert_eq ! ( glob_vec( "bbb/specials/[]]" ) , vec!( Path :: new ( "bbb/specials/]" ) ) ) ;
225
225
226
226
if os:: consts:: FAMILY != "windows" {
227
- assert_eq ! ( glob_vec( "bbb/specials/[*]" ) , vec!( abs_path ( "bbb/specials/*" ) ) ) ;
228
- assert_eq ! ( glob_vec( "bbb/specials/[?]" ) , vec!( abs_path ( "bbb/specials/?" ) ) ) ;
227
+ assert_eq ! ( glob_vec( "bbb/specials/[*]" ) , vec!( Path :: new ( "bbb/specials/*" ) ) ) ;
228
+ assert_eq ! ( glob_vec( "bbb/specials/[?]" ) , vec!( Path :: new ( "bbb/specials/?" ) ) ) ;
229
229
}
230
230
231
231
if os:: consts:: FAMILY == "windows" {
232
232
233
233
assert_eq ! ( glob_vec( "bbb/specials/[![]" ) , vec!(
234
- abs_path ( "bbb/specials/!" ) ,
235
- abs_path ( "bbb/specials/]" ) ) ) ;
234
+ Path :: new ( "bbb/specials/!" ) ,
235
+ Path :: new ( "bbb/specials/]" ) ) ) ;
236
236
237
237
assert_eq ! ( glob_vec( "bbb/specials/[!]]" ) , vec!(
238
- abs_path ( "bbb/specials/!" ) ,
239
- abs_path ( "bbb/specials/[" ) ) ) ;
238
+ Path :: new ( "bbb/specials/!" ) ,
239
+ Path :: new ( "bbb/specials/[" ) ) ) ;
240
240
241
241
assert_eq ! ( glob_vec( "bbb/specials/[!!]" ) , vec!(
242
- abs_path ( "bbb/specials/[" ) ,
243
- abs_path ( "bbb/specials/]" ) ) ) ;
242
+ Path :: new ( "bbb/specials/[" ) ,
243
+ Path :: new ( "bbb/specials/]" ) ) ) ;
244
244
245
245
} else {
246
246
247
247
assert_eq ! ( glob_vec( "bbb/specials/[![]" ) , vec!(
248
- abs_path ( "bbb/specials/!" ) ,
249
- abs_path ( "bbb/specials/*" ) ,
250
- abs_path ( "bbb/specials/?" ) ,
251
- abs_path ( "bbb/specials/]" ) ) ) ;
248
+ Path :: new ( "bbb/specials/!" ) ,
249
+ Path :: new ( "bbb/specials/*" ) ,
250
+ Path :: new ( "bbb/specials/?" ) ,
251
+ Path :: new ( "bbb/specials/]" ) ) ) ;
252
252
253
253
assert_eq ! ( glob_vec( "bbb/specials/[!]]" ) , vec!(
254
- abs_path ( "bbb/specials/!" ) ,
255
- abs_path ( "bbb/specials/*" ) ,
256
- abs_path ( "bbb/specials/?" ) ,
257
- abs_path ( "bbb/specials/[" ) ) ) ;
254
+ Path :: new ( "bbb/specials/!" ) ,
255
+ Path :: new ( "bbb/specials/*" ) ,
256
+ Path :: new ( "bbb/specials/?" ) ,
257
+ Path :: new ( "bbb/specials/[" ) ) ) ;
258
258
259
259
assert_eq ! ( glob_vec( "bbb/specials/[!!]" ) , vec!(
260
- abs_path ( "bbb/specials/*" ) ,
261
- abs_path ( "bbb/specials/?" ) ,
262
- abs_path ( "bbb/specials/[" ) ,
263
- abs_path ( "bbb/specials/]" ) ) ) ;
260
+ Path :: new ( "bbb/specials/*" ) ,
261
+ Path :: new ( "bbb/specials/?" ) ,
262
+ Path :: new ( "bbb/specials/[" ) ,
263
+ Path :: new ( "bbb/specials/]" ) ) ) ;
264
264
265
265
assert_eq ! ( glob_vec( "bbb/specials/[!*]" ) , vec!(
266
- abs_path ( "bbb/specials/!" ) ,
267
- abs_path ( "bbb/specials/?" ) ,
268
- abs_path ( "bbb/specials/[" ) ,
269
- abs_path ( "bbb/specials/]" ) ) ) ;
266
+ Path :: new ( "bbb/specials/!" ) ,
267
+ Path :: new ( "bbb/specials/?" ) ,
268
+ Path :: new ( "bbb/specials/[" ) ,
269
+ Path :: new ( "bbb/specials/]" ) ) ) ;
270
270
271
271
assert_eq ! ( glob_vec( "bbb/specials/[!?]" ) , vec!(
272
- abs_path ( "bbb/specials/!" ) ,
273
- abs_path ( "bbb/specials/*" ) ,
274
- abs_path ( "bbb/specials/[" ) ,
275
- abs_path ( "bbb/specials/]" ) ) ) ;
272
+ Path :: new ( "bbb/specials/!" ) ,
273
+ Path :: new ( "bbb/specials/*" ) ,
274
+ Path :: new ( "bbb/specials/[" ) ,
275
+ Path :: new ( "bbb/specials/]" ) ) ) ;
276
276
277
277
}
278
278
}
0 commit comments