Skip to content

Commit 4fed165

Browse files
committed
fix cannot import from Base warnings and tests
1 parent e9c3c9f commit 4fed165

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

src/LegacyStrings.jl

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,22 @@ import Compat:
4747
codeunit,
4848
ncodeunits
4949

50-
if isdefined(Base, :lcfirst)
51-
import Base: lcfirst
52-
end
5350

54-
if isdefined(Base, :next)
51+
if VERSION <= v"0.7-"
52+
import Base: lcfirst
5553
import Base: next
56-
end
57-
58-
if isdefined(Base, :rsearch)
5954
import Base: rsearch
60-
end
61-
62-
if isdefined(Base, :search)
6355
import Base: search
64-
end
65-
66-
if isdefined(Base, :ucfirst)
6756
import Base: ucfirst
68-
end
69-
70-
if isdefined(Base, :iterate)
71-
import Base: iterate
72-
end
73-
74-
if isdefined(Base, :UnicodeError)
7557
import Base: UnicodeError
76-
else
77-
include("unicodeerror.jl")
78-
end
79-
80-
if isdefined(Base, :DirectIndexString)
8158
using Base: DirectIndexString
8259
else
60+
import Base: iterate
61+
include("unicodeerror.jl")
8362
include("directindex.jl")
8463
end
8564

65+
8666
struct ASCIIString <: DirectIndexString
8767
data::Vector{UInt8}
8868
ASCIIString(data::String) = new(Vector{UInt8}(codeunits(data)))

test/runtests.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ using Compat: view, String
66
using LegacyStrings
77
using LegacyStrings: ASCIIString, UTF8String # override Compat's version
88
import LegacyStrings:
9-
ascii,
109
checkstring,
1110
UnicodeError,
1211
UTF_ERR_SHORT
@@ -208,13 +207,13 @@ let ch = 0x10000
208207
end
209208

210209
let str = UTF8String(b"this is a test\xed\x80")
211-
@test next(str, 15) == ('\ufffd', 16)
210+
@test iterate(str, 15) == ('\ufffd', 16)
212211
@test_throws BoundsError getindex(str, 0:3)
213212
@test_throws BoundsError getindex(str, 17:18)
214213
@test_throws BoundsError getindex(str, 2:17)
215214
@test_throws UnicodeError getindex(str, 16:17)
216215
# @test string(Char(0x110000)) == "\ufffd"
217-
sa = SubString{ASCIIString}(ascii("This is a silly test"), 1, 14)
216+
sa = SubString{ASCIIString}(LegacyStrings.ascii("This is a silly test"), 1, 14)
218217
s8 = convert(SubString{UTF8String}, sa)
219218
@test typeof(s8) == SubString{UTF8String}
220219
@test s8 == "This is a sill"
@@ -283,7 +282,7 @@ function tstcvt(strUTF8::UTF8String, strUTF16::UTF16String, strUTF32::UTF32Strin
283282
end
284283

285284
# Create some ASCII, UTF8, UTF16, and UTF32 strings
286-
strAscii = ascii("abcdefgh")
285+
strAscii = LegacyStrings.ascii("abcdefgh")
287286
strA_UTF8 = utf8(("abcdefgh\uff")[1:8])
288287
strL_UTF8 = utf8("abcdef\uff\uff")
289288
str2_UTF8 = utf8("abcd\uff\uff\u7ff\u7ff")
@@ -464,7 +463,7 @@ end
464463
@test reverse(utf32("abcd \uff\u7ff\u7fff\U7ffff")) == utf32("\U7ffff\u7fff\u7ff\uff dcba")
465464

466465
# Test pointer() functions
467-
let str = ascii("this ")
466+
let str = LegacyStrings.ascii("this ")
468467
u8 = utf8(str)
469468
u16 = utf16(str)
470469
u32 = utf32(str)
@@ -545,8 +544,8 @@ let
545544

546545
@test lastindex(srep) == 7
547546

548-
@test next(srep, 3) == ('β',5)
549-
@test next(srep, 7) == ('β',9)
547+
@test iterate(srep, 3) == ('β',5)
548+
@test iterate(srep, 7) == ('β',9)
550549

551550
@test srep[7] == 'β'
552551
@static if VERSION < v"0.7.0-DEV.2924"

0 commit comments

Comments
 (0)