Skip to content

Commit 2f19dc2

Browse files
authored
Merge pull request #36 from crstnbr/fix
Fix import from Base warnings on Julia 1.0
2 parents e8fb929 + 0ff52db commit 2f19dc2

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

src/LegacyStrings.jl

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,17 @@ import Base:
2525
convert,
2626
getindex,
2727
isvalid,
28-
lcfirst,
2928
length,
3029
lowercase,
3130
map,
32-
next,
3331
nextind,
3432
pointer,
3533
prevind,
3634
reverse,
3735
reverseind,
38-
rsearch,
39-
search,
4036
show,
4137
sizeof,
4238
string,
43-
ucfirst,
4439
unsafe_convert,
4540
uppercase,
4641
write
@@ -52,22 +47,22 @@ import Compat:
5247
codeunit,
5348
ncodeunits
5449

55-
if isdefined(Base, :iterate)
56-
import Base: iterate
57-
end
5850

59-
if isdefined(Base, :UnicodeError)
51+
if VERSION < v"0.7-"
52+
import Base: lcfirst
53+
import Base: next
54+
import Base: rsearch
55+
import Base: search
56+
import Base: ucfirst
6057
import Base: UnicodeError
61-
else
62-
include("unicodeerror.jl")
63-
end
64-
65-
if isdefined(Base, :DirectIndexString)
6658
using Base: DirectIndexString
6759
else
60+
import Base: iterate
61+
include("unicodeerror.jl")
6862
include("directindex.jl")
6963
end
7064

65+
7166
struct ASCIIString <: DirectIndexString
7267
data::Vector{UInt8}
7368
ASCIIString(data::String) = new(Vector{UInt8}(codeunits(data)))

test/runtests.jl

Lines changed: 15 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,17 @@ 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+
@static if VERSION < v"0.7-"
211+
@test next(str, 15) == ('\ufffd', 16)
212+
else
213+
@test iterate(str, 15) == ('\ufffd', 16)
214+
end
212215
@test_throws BoundsError getindex(str, 0:3)
213216
@test_throws BoundsError getindex(str, 17:18)
214217
@test_throws BoundsError getindex(str, 2:17)
215218
@test_throws UnicodeError getindex(str, 16:17)
216219
# @test string(Char(0x110000)) == "\ufffd"
217-
sa = SubString{ASCIIString}(ascii("This is a silly test"), 1, 14)
220+
sa = SubString{ASCIIString}(LegacyStrings.ascii("This is a silly test"), 1, 14)
218221
s8 = convert(SubString{UTF8String}, sa)
219222
@test typeof(s8) == SubString{UTF8String}
220223
@test s8 == "This is a sill"
@@ -283,7 +286,7 @@ function tstcvt(strUTF8::UTF8String, strUTF16::UTF16String, strUTF32::UTF32Strin
283286
end
284287

285288
# Create some ASCII, UTF8, UTF16, and UTF32 strings
286-
strAscii = ascii("abcdefgh")
289+
strAscii = LegacyStrings.ascii("abcdefgh")
287290
strA_UTF8 = utf8(("abcdefgh\uff")[1:8])
288291
strL_UTF8 = utf8("abcdef\uff\uff")
289292
str2_UTF8 = utf8("abcd\uff\uff\u7ff\u7ff")
@@ -464,7 +467,7 @@ end
464467
@test reverse(utf32("abcd \uff\u7ff\u7fff\U7ffff")) == utf32("\U7ffff\u7fff\u7ff\uff dcba")
465468

466469
# Test pointer() functions
467-
let str = ascii("this ")
470+
let str = LegacyStrings.ascii("this ")
468471
u8 = utf8(str)
469472
u16 = utf16(str)
470473
u32 = utf32(str)
@@ -545,8 +548,13 @@ let
545548

546549
@test lastindex(srep) == 7
547550

548-
@test next(srep, 3) == ('β',5)
549-
@test next(srep, 7) == ('β',9)
551+
@static if VERSION < v"0.7-"
552+
@test next(srep, 3) == ('β',5)
553+
@test next(srep, 7) == ('β',9)
554+
else
555+
@test iterate(srep, 3) == ('β',5)
556+
@test iterate(srep, 7) == ('β',9)
557+
end
550558

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

0 commit comments

Comments
 (0)