Pastey join_path and filesys test fixes
- Posted by gbonvehi
Feb 25, 2013
# HG changeset patch
# User Guillermo Bonvehi
# Date 1361847186 10800
# Node ID e1ef4ade29b7132967ecf38334ad055e38d27239
# Parent ead752a7c641f303f36c99458cff64ba0810d064
std/filesys.e: Fix join_path adding an incorrect SLASH when the first parameter didn't end in
":" but included it. Added "join_path #3" test
t_filesys.e: Fix using ProgramFiles as canonical test, use CommonProgramFiles instead.
diff -r ead752a7c641 -r e1ef4ade29b7 include/std/filesys.e
--- a/include/std/filesys.e Mon Feb 25 07:09:14 2013 -0500
+++ b/include/std/filesys.e Mon Feb 25 23:53:06 2013 -0300
@@ -1984,7 +1984,7 @@
if length(elem) and elem[1] != SLASH then
ifdef WINDOWS then
- if elem[$] != ':' then
+ if i > 1 or match(":",elem) = 0 then
elem = SLASH & elem
end if
elsedef
diff -r ead752a7c641 -r e1ef4ade29b7 tests/t_filesys.e
--- a/tests/t_filesys.e Mon Feb 25 07:09:14 2013 -0500
+++ b/tests/t_filesys.e Mon Feb 25 23:53:06 2013 -0300
@@ -191,12 +191,12 @@
ifdef WINDOWS then
- object program_files = getenv("ProgramFiles")
+ object common_program_files = getenv("COMMONPROGRAMFILES")
- if sequence(program_files) then
- sequence fbpf = filebase(program_files)
+ if sequence(common_program_files) then
+ sequence fbpf = filebase(common_program_files)
sequence shortened = upper(fbpf[1..6]) & "~1"
- test_equal( "canonical_path() #12", shortened, filebase(canonical_path(program_files,,TO_SHORT)))
+ test_equal( "canonical_path() #12:", shortened, filebase(canonical_path(common_program_files,,TO_SHORT)))
end if
end ifdef
@@ -335,6 +335,8 @@
test_equal("join_path #1", "\\Users\\john\\hello.txt", join_path({ "Users", "\\john\\", "hello.txt" }))
test_equal("split_path #2", { "C:", "Users", "john", "hello.txt" }, split_path("C:\\Users\\john\\hello.txt"))
test_equal("join_path #2", "C:\\Users\\john\\hello.txt", join_path({ "C:", "Users", "\\john\\", "hello.txt" }))
+
+ test_equal("join_path #3", "C:\\Users\\john\\hello.txt", join_path({ "C:\\Users", "\\john\\", "hello.txt" }))
elsedef
test_equal("split_path #1", { "usr", "home", "john", "hello.txt"},
split_path("/usr/home/john/hello.txt"))