@@ -3,7 +3,7 @@ use lib <t/spec/packages/>;
3
3
use Test ;
4
4
use Test ::Util;
5
5
6
- plan 33 ;
6
+ plan 34 ;
7
7
8
8
# L<S32::IO/IO::Path>
9
9
@@ -293,3 +293,48 @@ subtest 'combiners on "/" do not interfere with absolute path detection' => {
293
293
plan + @ Path-Types ;
294
294
is-deeply . is-absolute , True , . perl for @ Path-Types . map : *. new : " /\x [ 308] " ;
295
295
}
296
+
297
+ subtest ' .parts attribute' => {
298
+ plan 5 + 6 * @ Path-Types ;
299
+
300
+ sub check-parts ($ in , $ desc , * % parts ) {
301
+ subtest ' parts match' => {
302
+ plan 1 + % parts ;
303
+ is-deeply $ in . WHAT , Map , ' parts is a Map' ;
304
+ is-deeply $ in {$ _ }, % parts {$ _ }, " $ _ is correct" for % parts . keys ;
305
+ }
306
+ }
307
+
308
+ for @ Path-Types {
309
+ check-parts . new (' foo' ). parts , " foo { . perl } " ,
310
+ : basename<foo >, : dirname<. >, : volume(' ' );
311
+
312
+ check-parts . new (' ./foo' ). parts , " ./foo { . perl } " ,
313
+ : basename<foo >, : dirname<. >, : volume(' ' );
314
+
315
+ check-parts . new (' bar/foo' ). parts , " bar/foo { . perl } " ,
316
+ : basename<foo >, : dirname<bar >, : volume(' ' );
317
+
318
+ check-parts . new (' /bar/foo' ). parts , " /bar/foo { . perl } " ,
319
+ : basename<foo >, : dirname</bar >, : volume(' ' );
320
+
321
+ my $ p = . new (' /' ). parts ;
322
+ check-parts $ p , " / { . perl } " , : dirname</ >, : volume(' ' );
323
+ cmp-ok $ p <basename >, ' eq' , <\ / >. any , " / { . perl } (basename)" ;
324
+ }
325
+
326
+ check-parts IO ::Path::Win32. new (' C:foo' ). parts , " C:foo" ,
327
+ : basename<foo >,: dirname<. >,: volume<C: >;
328
+
329
+ check-parts IO ::Path::Win32. new (' C:./foo' ). parts , " C:./foo" ,
330
+ : basename<foo >,: dirname<. >,: volume<C: >;
331
+
332
+ check-parts IO ::Path::Win32. new (' C:bar/foo' ). parts , " C:bar/foo" ,
333
+ : basename<foo >,: dirname<bar >,: volume<C: >;
334
+
335
+ check-parts IO ::Path::Win32. new (' C:/bar/foo' ). parts , " C:/bar/foo" ,
336
+ : basename<foo >,: dirname</bar >,: volume<C: >;
337
+
338
+ check-parts IO ::Path::Win32. new (' C:/' ). parts , " C:/" ,
339
+ : basename(「 \」 ),: dirname</ >,: volume<C: >;
340
+ }
0 commit comments