Ai
21 Star 49 Fork 0

Gitee 极速下载/julia-language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/JuliaLang/julia
克隆/下载
filesystem.jl 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
# 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
@testset "Base.Filesystem docstrings" begin
undoc = Docs.undocumented_names(Base.Filesystem)
@test_broken isempty(undoc)
@test undoc == [:File, :Filesystem, :cptree, :futime, :sendfile, :unlink]
end
@testset "write return type" begin
@test Base.return_types(write, (Base.Filesystem.File, UInt8)) == [Int]
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/julia-language.git
git@gitee.com:mirrors/julia-language.git
mirrors
julia-language
julia-language
master

搜索帮助