Skip to content

Commit

Permalink
[Base] Stop pirating Base.seek
Browse files Browse the repository at this point in the history
  • Loading branch information
tkemmer committed Oct 20, 2022
1 parent f7c15a3 commit 1ce37aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/src/intern/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_cos
_dot
_norm
_seek
_sign
cathetus
ddot
Expand All @@ -26,7 +27,6 @@
pluseye!
props
reverseindex
seek
unpack
vertexnormals
```
1 change: 0 additions & 1 deletion src/NESSie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ __precompile__()

module NESSie

import Base: seek
import LinearAlgebra.BLAS: gemv!, gemv, axpy!, gemm

using Distances: euclidean
Expand Down
4 changes: 2 additions & 2 deletions src/base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ end

# =========================================================================================
"""
seek(
_seek(
fh ::IOStream,
prefix ::String,
skiptheline::Bool = true
Expand All @@ -242,7 +242,7 @@ is no such line, the stream handle will be set to EOF.
# Return type
`Void`
"""
function seek(fh::IOStream, prefix::String, skiptheline::Bool=true)
function _seek(fh::IOStream, prefix::String, skiptheline::Bool=true)
m = -1
found = false
while !eof(fh)
Expand Down
40 changes: 20 additions & 20 deletions test/base/util.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NESSie: _cos, _dot, _norm, eye!, pluseye!, isdegenerate, seek, reverseindex, unpack,
using NESSie: _cos, _dot, _norm, _seek, eye!, pluseye!, isdegenerate, reverseindex, unpack,
vertexnormals, distance
using LinearAlgebra: , norm

Expand Down Expand Up @@ -46,6 +46,25 @@ end
end
end

@testset "_seek" begin
fname, fh = mktemp()
write(fh, "Lorem\nipsum\ndolor\nsit\namet.\n")
seekstart(fh)
_seek(fh, "Foo")
@test eof(fh)
seekstart(fh)
_seek(fh, "Foo", false)
@test eof(fh)
seekstart(fh)
_seek(fh, "dolor")
@test readline(fh) == "sit"
seekstart(fh)
_seek(fh, "dolor", false)
@test readline(fh) == "dolor"
close(fh)
rm(fname)
end

@testset "distance" begin
for T in testtypes
elem = Triangle(T[0, 0, 0], T[0, 1, 0], T[0, 0, 1])
Expand Down Expand Up @@ -141,25 +160,6 @@ end
end
end

@testset "seek" begin
fname, fh = mktemp()
write(fh, "Lorem\nipsum\ndolor\nsit\namet.\n")
seekstart(fh)
seek(fh, "Foo")
@test eof(fh)
seekstart(fh)
seek(fh, "Foo", false)
@test eof(fh)
seekstart(fh)
seek(fh, "dolor")
@test readline(fh) == "sit"
seekstart(fh)
seek(fh, "dolor", false)
@test readline(fh) == "dolor"
close(fh)
rm(fname)
end

@testset "reverseindex" begin
for T in testtypes
v1 = T[1, 2, 3]
Expand Down

0 comments on commit 1ce37aa

Please # to comment.