@@ -443,6 +443,36 @@ define test test-subdirectory-locator ()
443
443
$microsoft-subdirectory-tests)
444
444
end test;
445
445
446
+ define test test-file-locator ()
447
+ // file-locator calls make(<file-locator>) which calls
448
+ // make(<native-file-locator>) passing `dir` (below) as the directory, which
449
+ // crashes if passed a locator for another platform. That's why this code
450
+ // doesn't attempt to test both Microsoft locators and POSIX locators on all
451
+ // platforms and instead branches based on $os-name. This could be fixed if
452
+ // we want to but I don't think it's a goal of the locators code be able to
453
+ // use all platform-specific locator types on all platforms, even if it does
454
+ // work for some of the other locators tests. --cgay
455
+ let posix-args
456
+ = #[#["/a/b/" , #["c" ], "/a/b/c" ],
457
+ #["/a/b/" , #["c" , "d" ], "/a/b/c/d" ],
458
+ #["/a/b/" , #["c" , "d" , "e" ], "/a/b/c/d/e" ]];
459
+ let windows-args
460
+ = #[#["c:\\ a\\ b\\ " , #["c" ], "c:\\ a\\ b\\ c" ],
461
+ #["c:\\ a\\ b\\ " , #["c" , "d" ], "c:\\ a\\ b\\ c\\ d" ],
462
+ #["\\\\ a\\ b\\ " , #["c" , "d" , "e" ], "\\\\ a\\ b\\ c\\ d\\ e" ]];
463
+ for (args in if ($os-name == # "win32" )
464
+ windows-args
465
+ else
466
+ posix-args
467
+ end )
468
+ let dir = as (<directory-locator>, args[0 ]);
469
+ let names = args[1 ];
470
+ let want = as (<file-locator>, args[2 ]);
471
+ check-equal(format-to-string("file-locator(%=, %=) = %=" , dir, names, want),
472
+ want, apply (file-locator, dir, names));
473
+ end ;
474
+ end test;
475
+
446
476
define constant $relative-tests
447
477
= #[#["a" , "a" , "a" ],
448
478
#["a" , "b" , "a" ],
@@ -603,6 +633,7 @@ define suite more-locators-test-suite ()
603
633
test test-string-as-locator;
604
634
test test-simplify-locator;
605
635
test test-subdirectory-locator;
636
+ test test-file-locator;
606
637
test test-relative-locator;
607
638
test test-merge-locators;
608
639
test test-resolve-locator;
0 commit comments