@@ -191,6 +191,19 @@ describe Path do
191
191
assert_paths(" C:\\ " , " ." , " C:\\ " , & .parent)
192
192
assert_paths(" C:/foo" , " C:" , " C:/" , & .parent)
193
193
assert_paths(" C:\\ foo" , " ." , " C:\\ " , & .parent)
194
+ assert_paths(" \\\\ ." , " ." , " \\\\ ." , & .parent)
195
+ assert_paths(" \\ /?" , " \\ " , " \\ /?" , & .parent)
196
+ assert_paths(" //." , " /" , " //." , & .parent)
197
+ assert_paths(" //./" , " /" , " //./" , & .parent)
198
+ assert_paths(" //.\\ " , " /" , " //.\\ " , & .parent)
199
+ assert_paths(" //./foo" , " //." , " //./" , & .parent)
200
+ assert_paths(" //.\\ foo" , " /" , " //.\\ " , & .parent)
201
+ assert_paths(" //?/" , " /" , " //?/" , & .parent)
202
+ assert_paths(" //?\\ " , " /" , " //?\\ " , & .parent)
203
+ assert_paths(" //?/foo" , " //?" , " //?/" , & .parent)
204
+ assert_paths(" //?\\ foo" , " /" , " //?\\ " , & .parent)
205
+ assert_paths(" \\\\ ?/" , " ." , " \\\\ ?/" , & .parent)
206
+ assert_paths(" \\\\ ?\\ " , " ." , " \\\\ ?\\ " , & .parent)
194
207
assert_paths(" /foo/C:/bar" , " /foo/C:" , " /foo/C:" , & .parent)
195
208
assert_paths(" //some/share" , " //some" , " //some/share" , & .parent)
196
209
assert_paths(" //some/share/" , " //some" , " //some/share/" , & .parent)
@@ -241,6 +254,19 @@ describe Path do
241
254
assert_paths(" C:\\ folder" , [" ." ], [" C:\\ " ], & .parents)
242
255
assert_paths(" C:\\\\ folder" , [" ." ], [" C:\\\\ " ], & .parents)
243
256
assert_paths(" C:\\ ." , [" ." ], [" C:\\ " ], & .parents)
257
+ assert_paths(" \\\\ ." , [" ." ], [] of String , & .parents)
258
+ assert_paths(" \\ /?" , [" ." , " \\ " ], [] of String , & .parents)
259
+ assert_paths(" //." , [" //" ], [] of String , & .parents)
260
+ assert_paths(" //./" , [" //" ], [] of String , & .parents)
261
+ assert_paths(" //.\\ " , [" //" ], [] of String , & .parents)
262
+ assert_paths(" //./foo" , [" //" , " //." ], [" //./" ], & .parents)
263
+ assert_paths(" //.\\ foo" , [" //" ], [" //.\\ " ], & .parents)
264
+ assert_paths(" //?/" , [" //" ], [] of String , & .parents)
265
+ assert_paths(" //?\\ " , [" //" ], [] of String , & .parents)
266
+ assert_paths(" //?/foo" , [" //" , " //?" ], [" //?/" ], & .parents)
267
+ assert_paths(" //?\\ foo" , [" //" ], [" //?\\ " ], & .parents)
268
+ assert_paths(" \\\\ ?/" , [" ." ], [] of String , & .parents)
269
+ assert_paths(" \\\\ ?\\ " , [" ." ], [] of String , & .parents)
244
270
assert_paths(" //some/share" , [" //" , " //some" ], [] of String , & .parents)
245
271
assert_paths(" //some/share/" , [" //" , " //some" ], [] of String , & .parents)
246
272
assert_paths(" //some/share/a" , [" //" , " //some" , " //some/share" ], [" //some/share/" ], & .parents)
@@ -264,6 +290,21 @@ describe Path do
264
290
assert_paths_raw(" C:" , " ." , " C:" , & .dirname)
265
291
assert_paths_raw(" C:/" , " ." , " C:/" , & .dirname)
266
292
assert_paths_raw(" C:\\ " , " ." , " C:\\ " , & .dirname)
293
+ assert_paths_raw(" C:/foo" , " C:" , " C:/" , & .dirname)
294
+ assert_paths_raw(" C:\\ foo" , " ." , " C:\\ " , & .dirname)
295
+ assert_paths_raw(" \\\\ ." , " ." , " \\\\ ." , & .dirname)
296
+ assert_paths_raw(" \\ /?" , " \\ " , " \\ /?" , & .dirname)
297
+ assert_paths_raw(" //." , " /" , " //." , & .dirname)
298
+ assert_paths_raw(" //./" , " /" , " //./" , & .dirname)
299
+ assert_paths_raw(" //.\\ " , " /" , " //.\\ " , & .dirname)
300
+ assert_paths_raw(" //./foo" , " //." , " //./" , & .dirname)
301
+ assert_paths_raw(" //.\\ foo" , " /" , " //.\\ " , & .dirname)
302
+ assert_paths_raw(" //?/" , " /" , " //?/" , & .dirname)
303
+ assert_paths_raw(" //?\\ " , " /" , " //?\\ " , & .dirname)
304
+ assert_paths_raw(" //?/foo" , " //?" , " //?/" , & .dirname)
305
+ assert_paths_raw(" //?\\ foo" , " /" , " //?\\ " , & .dirname)
306
+ assert_paths_raw(" \\\\ ?/" , " ." , " \\\\ ?/" , & .dirname)
307
+ assert_paths_raw(" \\\\ ?\\ " , " ." , " \\\\ ?\\ " , & .dirname)
267
308
assert_paths_raw(" //some/share" , " //some" , " //some/share" , & .dirname)
268
309
assert_paths_raw(" //some/share/" , " //some" , " //some/share/" , & .dirname)
269
310
assert_paths_raw(" //some/share/a" , " //some/share" , " //some/share/" , & .dirname)
@@ -355,6 +396,14 @@ describe Path do
355
396
it_iterates_parts(" C:\\ folder" , [" C:\\ folder" ], [" C:\\ " , " folder" ])
356
397
it_iterates_parts(" C:\\\\ folder" , [" C:\\\\ folder" ], [" C:\\\\ " , " folder" ])
357
398
it_iterates_parts(" C:\\ ." , [" C:\\ ." ], [" C:\\ " , " ." ])
399
+ it_iterates_parts(" //." , [" //" , " ." ], [" //." ])
400
+ it_iterates_parts(" //?" , [" //" , " ?" ], [" //?" ])
401
+ it_iterates_parts(" \\\\ .\\ " , [" \\\\ .\\ " ], [" \\\\ .\\ " ])
402
+ it_iterates_parts(" \\\\ ?\\ " , [" \\\\ ?\\ " ], [" \\\\ ?\\ " ])
403
+ it_iterates_parts(" \\\\ .\\ foo" , [" \\\\ .\\ foo" ], [" \\\\ .\\ " , " foo" ])
404
+ it_iterates_parts(" \\\\ ?\\ foo" , [" \\\\ ?\\ foo" ], [" \\\\ ?\\ " , " foo" ])
405
+ it_iterates_parts(" \\\\ .\\ foo\\ bar" , [" \\\\ .\\ foo\\ bar" ], [" \\\\ .\\ " , " foo" , " bar" ])
406
+ it_iterates_parts(" \\\\ ?\\ foo\\ bar" , [" \\\\ ?\\ foo\\ bar" ], [" \\\\ ?\\ " , " foo" , " bar" ])
358
407
end
359
408
360
409
describe " #extension" do
@@ -386,6 +435,7 @@ describe Path do
386
435
assert_paths_raw(" .\\ foo" , false , & .absolute?)
387
436
assert_paths_raw(" ~\\ foo" , false , & .absolute?)
388
437
assert_paths_raw(" C:" , false , & .absolute?)
438
+ assert_paths_raw(" C:foo" , false , & .absolute?)
389
439
390
440
assert_paths_raw(" C:\\ foo" , false , true , & .absolute?)
391
441
assert_paths_raw(" C:/foo/bar" , false , true , & .absolute?)
@@ -398,6 +448,13 @@ describe Path do
398
448
assert_paths_raw(" \\\\ some\\ share" , false , false , & .absolute?)
399
449
assert_paths_raw(" //some/share/" , true , true , & .absolute?)
400
450
assert_paths_raw(" \\\\ some\\ share\\ " , false , true , & .absolute?)
451
+
452
+ assert_paths_raw(" //." , true , false , & .absolute?)
453
+ assert_paths_raw(" \\\\ ?" , false , false , & .absolute?)
454
+ assert_paths_raw(" //./foo" , true , true , & .absolute?)
455
+ assert_paths_raw(" \\\\ .\\ foo" , false , true , & .absolute?)
456
+ assert_paths_raw(" //?/foo" , true , true , & .absolute?)
457
+ assert_paths_raw(" \\\\ ?\\ foo" , false , true , & .absolute?)
401
458
end
402
459
403
460
describe " #drive" do
@@ -416,6 +473,12 @@ describe Path do
416
473
assert_paths(" \\\\ some\\ share\\ foo" , nil , " \\\\ some\\ share" , & .drive)
417
474
assert_paths(" \\\\\\ not-a\\ share" , nil , nil , & .drive)
418
475
assert_paths(" \\\\ not-a\\\\ share" , nil , nil , & .drive)
476
+ assert_paths(" \\\\ ?\\ " , nil , " \\\\ ?" , & .drive)
477
+ assert_paths(" \\\\ .\\ " , nil , " \\\\ ." , & .drive)
478
+ assert_paths(" //?/" , nil , " //?" , & .drive)
479
+ assert_paths(" //./" , nil , " //." , & .drive)
480
+ assert_paths(" //?" , nil , " //?" , & .drive)
481
+ assert_paths(" //." , nil , " //." , & .drive)
419
482
420
483
assert_paths(" \\\\ some$\\ share\\ " , nil , " \\\\ some$\\ share" , & .drive)
421
484
assert_paths(" \\\\ %10%20\\ share\\ " , nil , " \\\\ %10%20\\ share" , & .drive)
@@ -435,6 +498,12 @@ describe Path do
435
498
assert_paths(" \\\\ some\\ share" , nil , & .root)
436
499
assert_paths(" //some/share/" , " /" , " /" , & .root)
437
500
assert_paths(" \\\\ some\\ share\\ " , nil , " \\ " , & .root)
501
+ assert_paths(" \\\\ ?\\ " , nil , " \\ " , & .root)
502
+ assert_paths(" \\\\ .\\ " , nil , " \\ " , & .root)
503
+ assert_paths(" //?/" , " /" , " /" , & .root)
504
+ assert_paths(" //./" , " /" , " /" , & .root)
505
+ assert_paths(" //?" , " /" , nil , & .root)
506
+ assert_paths(" //." , " /" , nil , & .root)
438
507
end
439
508
440
509
describe " #anchor" do
@@ -447,6 +516,12 @@ describe Path do
447
516
assert_paths(" //some/share/" , " /" , " //some/share/" , & .anchor)
448
517
assert_paths(" \\\\ some\\ share" , nil , " \\\\ some\\ share" , & .anchor)
449
518
assert_paths(" \\\\ some\\ share\\ " , nil , " \\\\ some\\ share\\ " , & .anchor)
519
+ assert_paths(" \\\\ ?\\ " , nil , " \\\\ ?\\ " , & .anchor)
520
+ assert_paths(" \\\\ .\\ " , nil , " \\\\ .\\ " , & .anchor)
521
+ assert_paths(" //?/" , " /" , " //?/" , & .anchor)
522
+ assert_paths(" //./" , " /" , " //./" , & .anchor)
523
+ assert_paths(" //?" , " /" , " //?" , & .anchor)
524
+ assert_paths(" //." , " /" , " //." , & .anchor)
450
525
end
451
526
452
527
describe " #normalize" do
@@ -566,6 +641,14 @@ describe Path do
566
641
it_normalizes_path(" C:\\ foo" , " C:\\ foo" )
567
642
it_normalizes_path(" C:/foo" , " C:/foo" , " C:\\ foo" )
568
643
end
644
+
645
+ describe " windows local device paths" do
646
+ it_normalizes_path(" \\\\ .\\ C:\\ ..\\ D:\\ foo\\ .\\ bar" , windows: " \\\\ .\\ D:\\ foo\\ bar" )
647
+ it_normalizes_path(" //./c:/" , " /c:" , windows: " \\\\ .\\ c:\\ " )
648
+ it_normalizes_path(" //?/c:" , " /?/c:" , windows: " \\\\ ?\\ c:" )
649
+ it_normalizes_path(" \\ /.\\ c:/\\ " , windows: " \\\\ .\\ c:\\ " )
650
+ it_normalizes_path(" \\\\ ?\\ c:\\ " )
651
+ end
569
652
end
570
653
571
654
describe " #join" do
0 commit comments