Revision d215d914ee388efb0737135d81dcc581e0016f8e authored by Keno Fischer on 15 July 2023, 17:01:26 UTC, committed by GitHub on 15 July 2023, 17:01:26 UTC
Fixes the case from #50518, but we actually have two test cases in the
tests that also hit this (e.g. this one:
```
f40964(xs::Int...=1; k = 2) = (xs, k)
```
), but just happened not to hit the bad codegen path. #50556, once
merged would have complained on those definitions as well, without this
fix.
2 parent s 191256e + c272236
Raw File
filesystem.jl
# This file is a part of Julia. License is MIT: https://julialang.org/license

mktempdir() do dir

  # Create test file
  filename = joinpath(dir, "file.txt")
  text = "123456"
  write(filename, text)

  # test filesystem truncate (shorten)
  file = Base.Filesystem.open(filename, Base.Filesystem.JL_O_RDWR)
  Base.Filesystem.truncate(file, 2)
  text = text[1:2]
  @test length(read(file)) == 2
  close(file)

  # test filesystem truncate (lengthen)
  file = Base.Filesystem.open(filename, Base.Filesystem.JL_O_RDWR)
  Base.Filesystem.truncate(file, 20)
  @test length(read(file)) == 20
  close(file)

  # test filesystem futime
  file = Base.Filesystem.open(filename, Base.Filesystem.JL_O_RDWR)
  Base.Filesystem.futime(file, 1.0, 2.0)
  @test Base.Filesystem.stat(file).mtime == 2.0
  close(file)

  # test filesystem readbytes!
  file = Base.Filesystem.open(filename, Base.Filesystem.JL_O_RDWR)
  res = ones(UInt8, 80)
  Base.Filesystem.readbytes!(file, res)
  @test res == UInt8[text..., (i > 20 for i in (length(text) + 1):length(res))...]
  close(file)

end

import Base.Filesystem: S_IRUSR, S_IRGRP, S_IROTH
@testset "types of permission mask constants" begin
  @test S_IRUSR & ~S_IRGRP == S_IRUSR
  @test typeof(S_IRUSR) == typeof(S_IRGRP) == typeof(S_IROTH)
end
back to top