Skip to content

Commit

Permalink
Fix file.touch. (#3529)
Browse files Browse the repository at this point in the history
Co-authored-by: Romain Beauxis <toots@rastageeks.org>
  • Loading branch information
smimram and toots committed Nov 16, 2023
1 parent f08c061 commit 525b36b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.2.3 (unreleased)

Fixed:

- Fixed `file.touch` (#3529)

---

# 2.2.2 (2023-11-02)

New:
Expand Down
10 changes: 6 additions & 4 deletions src/libs/file.liq
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ def replaces file.write(~data, ~perms=0o644, ~append=false, path) =
def rec write() =
s = getter.get(data) ?? ""
cb(s)
if getter.is_constant(data) then
cb("")
elsif s != "" then
write()
if
s == ""
then
()
elsif getter.is_constant(data) then cb("")
elsif s != "" then write()
end
end
write()
Expand Down
26 changes: 14 additions & 12 deletions tests/language/file.liq
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ def f() =
targetdir = path.concat(tmpdir2, path.basename(tmpdir))
test.equals(file.exists(path.concat(targetdir, "test-src-file")), true)

non_existent = path.concat(tmpdir, "non-existent")
dst_file2 = path.concat(tmpdir2, "another_dst")
non_existent = path.concat(tmpdir, "non-existent")
dst_file2 = path.concat(tmpdir2, "another_dst")

try
file.copy(non_existent, dst_file2)
test.fail()
catch e : [error.file] do
()
end
try
file.copy(non_existent, dst_file2)
test.fail()
catch e : [error.file] do
()
end

dst_file3 = path.concat(tmpdir, "test-dst-file3")
file.move(src_file, dst_file3)
dst_file3 = path.concat(tmpdir, "test-dst-file3")
file.move(src_file, dst_file3)
test.equals(file.exists(dst_file3), true)

test.equals(file.exists(dst_file3), true)
file.touch("test-dst-file4")
test.equals(file.exists("test-dst-file4"), true)

test.pass()
test.pass()
end

test.check(f)

0 comments on commit 525b36b

Please sign in to comment.