From 3e8d7b9346cbb2d90e482175bdff054f62227161 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Tue, 8 Oct 2019 16:55:28 +0200 Subject: [PATCH] Drop compat code for `codeunits` from #474 --- README.md | 4 +--- src/Compat.jl | 7 ------- test/old.jl | 3 +++ test/runtests.jl | 2 -- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 52bc729e1..758b2cdc3 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,7 @@ Currently, the `@compat` macro supports the following syntaxes: * `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized as the second ([#24605]). -* `codeunits(s)` returns an array-like view of the `UInt8` code units of - a string and `ncodeunits(s)` returns the number of code units ([#25241]). - `codeunit(s)` returns the type of the code units of `s` ([#24999]). +* `codeunit(s)` returns the type of the code units of `s` ([#24999]). * `thisind(s, i)` returns the character index for codeunit `i` ([#24414]). diff --git a/src/Compat.jl b/src/Compat.jl index 3f68730ed..4992957b1 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -71,13 +71,6 @@ end end end -@static if !isdefined(Base, :codeunits) - codeunits(s::String) = Vector{UInt8}(s) - ncodeunits(s::Union{String,SubString{String}}) = sizeof(s) - codeunits(s::SubString{String}) = view(codeunits(s.string),1+s.offset:s.offset+sizeof(s)) - export codeunits, ncodeunits -end - @static if !isdefined(Base, :nameof) nameof(m::Module) = Base.module_name(m) nameof(f::Function) = Base.function_name(f) diff --git a/test/old.jl b/test/old.jl index fbee8e9f1..82064ef89 100644 --- a/test/old.jl +++ b/test/old.jl @@ -656,3 +656,6 @@ end @test parentmodule(sin, Tuple{Int}) == Base.Math @test parentmodule(Int) == Core @test parentmodule(Array) == Core + +@test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) +@test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) diff --git a/test/runtests.jl b/test/runtests.jl index f2ad83dea..3df00218a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -80,8 +80,6 @@ let A = [1] @test x == 1 end -@test codeunits("foo") == [0x66,0x6f,0x6f] == codeunits(SubString("fooαβγ",1,3)) -@test ncodeunits("αβγ") == 6 == ncodeunits(SubString("fooαβγ",4,8)) @test codeunit("foo") == codeunit(SubString("fooαβγ",1,3)) == UInt8 # 0.7.0-DEV.3539