From 2309198af1521659a6b1d3cae7722eb7f5ed3df2 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Thu, 5 May 2016 12:47:40 -0400 Subject: [PATCH] reinstate "useless" String() inner constructor (#16212) --- base/boot.jl | 2 ++ test/strings/basic.jl | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/base/boot.jl b/base/boot.jl index 92adfcbe58901..cb8b6795c478f 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -220,6 +220,8 @@ abstract DirectIndexString <: AbstractString immutable String <: AbstractString data::Array{UInt8,1} + # required to make String("foo") work (#15120): + String(d::Array{UInt8,1}) = new(d) end include(fname::String) = ccall(:jl_load_, Any, (Any,), fname) diff --git a/test/strings/basic.jl b/test/strings/basic.jl index efda879c33527..2a6a3660f376a 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -1,5 +1,9 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license +# constructors +@test String([0x61,0x62,0x63,0x21]) == "abc!" +@test String("abc!") == "abc!" + # {starts,ends}with @test startswith("abcd", 'a') @test startswith("abcd", "a")