diff --git a/base/LineEdit.jl b/base/LineEdit.jl index 8b3ae98afcb0a..af954fb9de767 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -834,7 +834,7 @@ function keymap{D<:Dict}(keymaps::Array{D}) end const escape_defaults = merge!( - {char(i) => nothing for i=[1:26, 28:31]}, # Ignore control characters by default + {char(i) => nothing for i=vcat(1:26, 28:31)}, # Ignore control characters by default { # And ignore other escape sequences by default "\e*" => nothing, "\e[*" => nothing, diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 204ca57796005..2804574b4251a 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -6,7 +6,7 @@ typealias AbstractVecOrMat{T} Union(AbstractVector{T}, AbstractMatrix{T}) ## Basic functions ## -vect() = Array(None, 0) +vect() = Array(Void, 0) vect{T}(X::T...) = T[ X[i] for i=1:length(X) ] const _oldstyle_array_vcat_ = true @@ -23,7 +23,7 @@ if _oldstyle_array_vcat_ before = "a,b,..." after = "a;b;..." end - warn_once("[$before] concatenation is deprecated; use [$after] instead") + warn("[$before] concatenation is deprecated; use [$after] instead") end function vect(A::AbstractArray...) oldstyle_vcat_warning(length(A)) diff --git a/base/array.jl b/base/array.jl index 2f59a623d8be2..5f60ffc9d4fab 100644 --- a/base/array.jl +++ b/base/array.jl @@ -128,12 +128,12 @@ getindex(T::(Type...)) = Array(T,0) if _oldstyle_array_vcat_ # T[a:b] and T[a:s:b] also contruct typed ranges function getindex{T<:Number}(::Type{T}, r::Range) - warn_once("T[a:b] concatenation is deprecated; use T[a:b;] instead") + warn("T[a:b] concatenation is deprecated; use T[a:b;] instead") copy!(Array(T,length(r)), r) end function getindex{T<:Number}(::Type{T}, r1::Range, rs::Range...) - warn_once("T[a:b,...] concatenation is deprecated; use T[a:b;...] instead") + warn("T[a:b,...] concatenation is deprecated; use T[a:b;...] instead") a = Array(T,length(r1)+sum(length,rs)) o = 1 copy!(a, o, r1) diff --git a/base/dates/periods.jl b/base/dates/periods.jl index 72a689c4e1224..693b23be5ca8f 100644 --- a/base/dates/periods.jl +++ b/base/dates/periods.jl @@ -48,8 +48,8 @@ Base.isless(x::Period,y::Period) = throw(ArgumentError("Can't compare $(typeof(x #Period Arithmetic: import Base.div, Base.mod, Base.gcd, Base.lcm -let vec_ops = [:.+,:.-,:.*,:.%,:div] - for op in [:+,:-,:*,:%,:mod,:gcd,:lcm,vec_ops] +let vec_ops = Symbol[:.+, :.-, :.*, :.%, :div] + for op in [:+; :-; :*; :%; :mod; :gcd; :lcm; vec_ops] @eval begin #Period-Period ($op){P<:Period}(x::P,y::P) = P(($op)(value(x),value(y))) @@ -101,7 +101,7 @@ function Base.string(x::CompoundPeriod) for p in x.periods s *= ", " * string(p) end - return s[3:end] + return s[3:end;] end Base.show(io::IO,x::CompoundPeriod) = print(io,string(x)) # E.g. Year(1) + Day(1) @@ -148,4 +148,4 @@ days(c::Week) = 7*value(c) days(c::Year) = 365.2425*value(c) days(c::Month) = 30.436875*value(c) -Day{T<:FixedPeriod}(c::T) = Day(days(c)) \ No newline at end of file +Day{T<:FixedPeriod}(c::T) = Day(days(c)) diff --git a/test/bigint.jl b/test/bigint.jl index 21ea4f1d22237..1133e5d335c81 100644 --- a/test/bigint.jl +++ b/test/bigint.jl @@ -33,7 +33,7 @@ ee = typemax(Int64) @test string(d) == "-246913578024691357802469135780" @test string(a) == "123456789012345678901234567890" -for i = -10:10, j = [-10:-1;1:10] +for i = -10:10, j = [-10:-1; 1:10] @test div(BigInt(i), BigInt(j)) == div(i,j) @test fld(BigInt(i), BigInt(j)) == fld(i,j) @test mod(BigInt(i), BigInt(j)) == mod(i,j) diff --git a/test/dates/accessors.jl b/test/dates/accessors.jl index 85f7f01251ce5..3d441d45e7a0f 100644 --- a/test/dates/accessors.jl +++ b/test/dates/accessors.jl @@ -189,4 +189,4 @@ dr = [a,a,a,a,a,a,a,a,a,a] @test Dates.hour(dr) == repmat([0],10) @test Dates.minute(dr) == repmat([0],10) @test Dates.second(dr) == repmat([0],10) -@test Dates.millisecond(dr) == repmat([0],10) \ No newline at end of file +@test Dates.millisecond(dr) == repmat([0],10) diff --git a/test/dates/adjusters.jl b/test/dates/adjusters.jl index 00b93e7df7ba0..4dcdae83eaa52 100644 --- a/test/dates/adjusters.jl +++ b/test/dates/adjusters.jl @@ -442,4 +442,4 @@ end) == 251 dt += Dates.Day(1) end return sum == 15 -end) == 15 # On average, there's one of those months every year \ No newline at end of file +end) == 15 # On average, there's one of those months every year diff --git a/test/dates/arithmetic.jl b/test/dates/arithmetic.jl index 127df38f0df35..4663a24db55c2 100644 --- a/test/dates/arithmetic.jl +++ b/test/dates/arithmetic.jl @@ -327,4 +327,4 @@ dt2 = dt + Dates.Year(1) @test Dates.hour(dt2) == 12 @test Dates.minute(dt2) == 30 @test Dates.second(dt2) == 45 -@test Dates.millisecond(dt2) == 500 \ No newline at end of file +@test Dates.millisecond(dt2) == 500 diff --git a/test/dates/conversions.jl b/test/dates/conversions.jl index d5b138f1f86f5..bb6750172ac4f 100644 --- a/test/dates/conversions.jl +++ b/test/dates/conversions.jl @@ -43,4 +43,4 @@ @test typeof(Dates.now()) <: Dates.DateTime @test typeof(Dates.today()) <: Dates.Date -@test typeof(Dates.now(Dates.UTC)) <: Dates.DateTime \ No newline at end of file +@test typeof(Dates.now(Dates.UTC)) <: Dates.DateTime diff --git a/test/dates/io.jl b/test/dates/io.jl index e9b441078933b..7f3c73ccd2586 100644 --- a/test/dates/io.jl +++ b/test/dates/io.jl @@ -256,7 +256,7 @@ f = "y m d" # Vectorized dr = ["2000-01-01","2000-01-02","2000-01-03","2000-01-04","2000-01-05" ,"2000-01-06","2000-01-07","2000-01-08","2000-01-09","2000-01-10"] -dr2 = [Dates.Date(2000):Dates.Date(2000,1,10)] +dr2 = [Dates.Date(2000):Dates.Date(2000,1,10);] @test Dates.Date(dr) == dr2 @test Dates.Date(dr,"yyyy-mm-dd") == dr2 @test Dates.DateTime(dr) == Dates.DateTime(dr2) diff --git a/test/dates/ranges.jl b/test/dates/ranges.jl index cd23202d7e97f..465f235b5aba8 100644 --- a/test/dates/ranges.jl +++ b/test/dates/ranges.jl @@ -18,7 +18,7 @@ function test_all_combos() @test_throws ErrorException maximum(dr) @test_throws BoundsError dr[1] @test findin(dr,dr) == Int64[] - @test [dr] == T[] + @test [dr;] == T[] @test isempty(reverse(dr)) @test length(reverse(dr)) == 0 @test first(reverse(dr)) == f1-one(l1 - f1) @@ -47,8 +47,8 @@ function test_all_combos() if len < 10000 dr1 = [i for i in dr] @test length(dr1) == len - @test findin(dr,dr) == [1:len] - @test length([dr]) == len + @test findin(dr,dr) == [1:len;] + @test length([dr;]) == len end @test !isempty(reverse(dr)) @test length(reverse(dr)) == len @@ -70,7 +70,7 @@ function test_all_combos() @test_throws ErrorException maximum(dr) @test_throws BoundsError dr[1] @test findin(dr,dr) == Int64[] - @test [dr] == T[] + @test [dr;] == T[] @test isempty(reverse(dr)) @test length(reverse(dr)) == 0 @test first(reverse(dr)) == l1+one(l1 - f1) @@ -99,8 +99,8 @@ function test_all_combos() if len < 10000 dr1 = [i for i in dr] @test length(dr1) == len - @test findin(dr,dr) == [1:len] - @test length([dr]) == len + @test findin(dr,dr) == [1:len;] + @test length([dr;]) == len end @test !isempty(reverse(dr)) @test length(reverse(dr)) == len @@ -123,7 +123,7 @@ function test_all_combos() @test_throws ErrorException maximum(dr) @test_throws BoundsError dr[1] @test findin(dr,dr) == Int64[] - @test [dr] == T[] + @test [dr;] == T[] @test isempty(reverse(dr)) @test length(reverse(dr)) == 0 @test first(reverse(dr)) == f1-one(l1 - f1) @@ -152,8 +152,8 @@ function test_all_combos() if len < 10000 dr1 = [i for i in dr] @test length(dr1) == len - @test findin(dr,dr) == [1:len] - @test length([dr]) == len + @test findin(dr,dr) == [1:len;] + @test length([dr;]) == len end @test !isempty(reverse(dr)) @test length(reverse(dr)) == len @@ -175,7 +175,7 @@ function test_all_combos() @test_throws ErrorException maximum(dr) @test_throws BoundsError dr[1] @test findin(dr,dr) == Int64[] - @test [dr] == T[] + @test [dr;] == T[] @test isempty(reverse(dr)) @test length(reverse(dr)) == 0 @test first(reverse(dr)) == l1+one(l1 - f1) @@ -204,8 +204,8 @@ function test_all_combos() if len < 10000 dr1 = [i for i in dr] @test length(dr1) == len - @test findin(dr,dr) == [1:len] - @test length([dr]) == len + @test findin(dr,dr) == [1:len;] + @test length([dr;]) == len end @test !isempty(reverse(dr)) @test length(reverse(dr)) == len @@ -256,7 +256,7 @@ drs2 = map(x->Dates.Date(first(x)):step(x):Dates.Date(last(x)),drs) @test map(length,drs) == map(x->size(x)[1],drs) @test map(length,drs) == map(x->length(Dates.Date(first(x)):step(x):Dates.Date(last(x))),drs) @test map(length,drs) == map(x->length(reverse(x)),drs) -@test all(map(x->findin(x,x)==[1:length(x)],drs[1:4])) +@test all(map(x->findin(x,x)==[1:length(x);],drs[1:4])) @test isempty(dr2) @test all(map(x->reverse(x) == range(last(x), -step(x), length(x)),drs)) @test all(map(x->minimum(x) == (step(x) < zero(step(x)) ? last(x) : first(x)),drs[4:end])) @@ -270,8 +270,8 @@ end) @test_throws MethodError dr + 1 a = Dates.DateTime(2013,1,1) b = Dates.DateTime(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.DateTime,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1))] -@test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1))] +@test map!(x->x+Dates.Day(1),Array(Dates.DateTime,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] @test a in dr @@ -334,7 +334,7 @@ drs = {dr,dr1,dr2,dr3,dr4,dr5,dr6,dr7,dr8,dr9,dr10, dr11,dr12,dr13,dr14,dr15,dr16,dr17,dr18,dr19,dr20} @test map(length,drs) == map(x->size(x)[1],drs) -@test all(map(x->findin(x,x)==[1:length(x)],drs[1:4])) +@test all(map(x->findin(x,x) == [1:length(x);], drs[1:4])) @test isempty(dr2) @test all(map(x->reverse(x) == last(x):-step(x):first(x),drs)) @test all(map(x->minimum(x) == (step(x) < zero(step(x)) ? last(x) : first(x)),drs[4:end])) @@ -348,8 +348,8 @@ end) @test_throws MethodError dr + 1 a = Dates.Date(2013,1,1) b = Dates.Date(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.Date,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1))] -@test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1))] +@test map!(x->x+Dates.Day(1),Array(Dates.Date,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] @test a in dr @@ -400,9 +400,9 @@ b = Dates.Date(2013,2,1) c = Dates.Date(2013,6,1) @test length(a:Dates.Month(1):c) == 6 -@test [a:Dates.Month(1):c] == [a + Dates.Month(1)*i for i in 0:5] -@test [a:Dates.Month(2):Dates.Date(2013,1,2)] == [a] -@test [c:Dates.Month(-1):a] == reverse([a:Dates.Month(1):c]) +@test [a:Dates.Month(1):c;] == [a + Dates.Month(1)*i for i in 0:5] +@test [a:Dates.Month(2):Dates.Date(2013,1,2);] == [a] +@test [c:Dates.Month(-1):a;] == reverse([a:Dates.Month(1):c;]) @test length(range(Date(2000),366)) == 366 function testlengths(n) @@ -490,4 +490,4 @@ testmonthranges2(100000) # Issue 5 lastdaysofmonth = [Dates.Date(2014,i,Dates.daysinmonth(2014,i)) for i=1:12] -@test [Date(2014,1,31):Dates.Month(1):Date(2015)] == lastdaysofmonth \ No newline at end of file +@test [Date(2014,1,31):Dates.Month(1):Date(2015);] == lastdaysofmonth diff --git a/test/perf/sparse/perf.jl b/test/perf/sparse/perf.jl index 5b05a02a5692a..dd4222f221faa 100644 --- a/test/perf/sparse/perf.jl +++ b/test/perf/sparse/perf.jl @@ -122,7 +122,7 @@ end intinds = nothing logicalinds = nothing # needs to be generated for a specific matrix size. rangeinds = 121:237 -orderedinds = [rangeinds] +orderedinds = [rangeinds;] disorderedinds = orderedinds[randperm(length(orderedinds))] inds = [(intinds, "integers"), (logicalinds, "logical array"), (rangeinds, "a range"), diff --git a/test/random.jl b/test/random.jl index 9e9970f208172..884c197691696 100644 --- a/test/random.jl +++ b/test/random.jl @@ -20,7 +20,7 @@ srand(0); rand(); x = rand(384); @test rand(MersenneTwister(5294967296)) == 0.3498809918210497 # Test array filling, Issue #7643 -@test rand(MersenneTwister(0), 1) == [0.8236475079774124] +@test rand(MersenneTwister(0), 1) == Float64[0.8236475079774124] A = zeros(2, 2) rand!(MersenneTwister(0), A) @test A == [0.8236475079774124 0.16456579813368521; diff --git a/test/ranges.jl b/test/ranges.jl index a4cca99940d9b..d6ed551f5bb1e 100644 --- a/test/ranges.jl +++ b/test/ranges.jl @@ -359,8 +359,8 @@ end # mean/median for f in (mean, median) for n = 2:5 - @test f(2:n) == f([2:n]) - @test_approx_eq f(2:0.1:n) f([2:0.1:n]) + @test f(2:n) == f([2:n;]) + @test_approx_eq f(2:0.1:n) f([2:0.1:n;]) end end diff --git a/test/strings.jl b/test/strings.jl index 5c5437ab7ad83..a25a448d91690 100644 --- a/test/strings.jl +++ b/test/strings.jl @@ -497,18 +497,18 @@ end @test isequal(split("foo,bar,baz", ','), ["foo","bar","baz"]) @test isequal(split("foo,bar,baz", ","), ["foo","bar","baz"]) @test isequal(split("foo,bar,baz", r","), ["foo","bar","baz"]) -@test isequal(split("foo,bar,baz", ',', 0), ["foo","bar","baz"]) -@test isequal(split("foo,bar,baz", ',', 1), ["foo,bar,baz"]) -@test isequal(split("foo,bar,baz", ',', 2), ["foo","bar,baz"]) -@test isequal(split("foo,bar,baz", ',', 3), ["foo","bar","baz"]) +@test isequal(split("foo,bar,baz", ','; limit=0), ["foo","bar","baz"]) +@test isequal(split("foo,bar,baz", ','; limit=1), ["foo,bar,baz"]) +@test isequal(split("foo,bar,baz", ','; limit=2), ["foo","bar,baz"]) +@test isequal(split("foo,bar,baz", ','; limit=3), ["foo","bar","baz"]) @test isequal(split("foo,bar", "o,b"), ["fo","ar"]) @test isequal(split("", ','), [""]) @test isequal(split(",", ','), ["",""]) @test isequal(split(",,", ','), ["","",""]) -@test isequal(split("", ',', false), []) -@test isequal(split(",", ',', false), []) -@test isequal(split(",,", ',', false), []) +@test isequal(split("", ',' ; keep=false), []) +@test isequal(split(",", ',' ; keep=false), []) +@test isequal(split(",,", ','; keep=false), []) @test isequal(split("a b c"), ["a","b","c"]) @test isequal(split("a b \t c\n"), ["a","b","c"]) @@ -516,39 +516,39 @@ end @test isequal(rsplit("foo,bar,baz", 'x'), ["foo,bar,baz"]) @test isequal(rsplit("foo,bar,baz", ','), ["foo","bar","baz"]) @test isequal(rsplit("foo,bar,baz", ","), ["foo","bar","baz"]) -@test isequal(rsplit("foo,bar,baz", ',', 0), ["foo","bar","baz"]) -@test isequal(rsplit("foo,bar,baz", ',', 1), ["foo,bar,baz"]) -@test isequal(rsplit("foo,bar,baz", ',', 2), ["foo,bar","baz"]) -@test isequal(rsplit("foo,bar,baz", ',', 3), ["foo","bar","baz"]) +@test isequal(rsplit("foo,bar,baz", ','; limit=0), ["foo","bar","baz"]) +@test isequal(rsplit("foo,bar,baz", ','; limit=1), ["foo,bar,baz"]) +@test isequal(rsplit("foo,bar,baz", ','; limit=2), ["foo,bar","baz"]) +@test isequal(rsplit("foo,bar,baz", ','; limit=3), ["foo","bar","baz"]) @test isequal(rsplit("foo,bar", "o,b"), ["fo","ar"]) @test isequal(rsplit("", ','), [""]) @test isequal(rsplit(",", ','), ["",""]) @test isequal(rsplit(",,", ','), ["","",""]) -@test isequal(rsplit(",,", ',', 2), [",",""]) -@test isequal(rsplit("", ',', false), []) -@test isequal(rsplit(",", ',', false), []) -@test isequal(rsplit(",,", ',', false), []) +@test isequal(rsplit(",,", ','; limit=2), [",",""]) +@test isequal(rsplit("", ',' ; keep=false), []) +@test isequal(rsplit(",", ',' ; keep=false), []) +@test isequal(rsplit(",,", ','; keep=false), []) #@test isequal(rsplit("a b c"), ["a","b","c"]) #@test isequal(rsplit("a b \t c\n"), ["a","b","c"]) let str = "a.:.ba..:..cba.:.:.dcba.:." @test isequal(split(str, ".:."), ["a","ba.",".cba",":.dcba",""]) -@test isequal(split(str, ".:.", false), ["a","ba.",".cba",":.dcba"]) +@test isequal(split(str, ".:."; keep=false), ["a","ba.",".cba",":.dcba"]) @test isequal(split(str, ".:."), ["a","ba.",".cba",":.dcba",""]) @test isequal(split(str, r"\.(:\.)+"), ["a","ba.",".cba","dcba",""]) -@test isequal(split(str, r"\.(:\.)+", false), ["a","ba.",".cba","dcba"]) +@test isequal(split(str, r"\.(:\.)+"; keep=false), ["a","ba.",".cba","dcba"]) @test isequal(split(str, r"\.+:\.+"), ["a","ba","cba",":.dcba",""]) -@test isequal(split(str, r"\.+:\.+", false), ["a","ba","cba",":.dcba"]) +@test isequal(split(str, r"\.+:\.+"; keep=false), ["a","ba","cba",":.dcba"]) @test isequal(rsplit(str, ".:."), ["a","ba.",".cba.:","dcba",""]) -@test isequal(rsplit(str, ".:.", false), ["a","ba.",".cba.:","dcba"]) -@test isequal(rsplit(str, ".:.", 2), ["a.:.ba..:..cba.:.:.dcba", ""]) -@test isequal(rsplit(str, ".:.", 3), ["a.:.ba..:..cba.:", "dcba", ""]) -@test isequal(rsplit(str, ".:.", 4), ["a.:.ba.", ".cba.:", "dcba", ""]) -@test isequal(rsplit(str, ".:.", 5), ["a", "ba.", ".cba.:", "dcba", ""]) -@test isequal(rsplit(str, ".:.", 6), ["a", "ba.", ".cba.:", "dcba", ""]) +@test isequal(rsplit(str, ".:."; keep=false), ["a","ba.",".cba.:","dcba"]) +@test isequal(rsplit(str, ".:."; limit=2), ["a.:.ba..:..cba.:.:.dcba", ""]) +@test isequal(rsplit(str, ".:."; limit=3), ["a.:.ba..:..cba.:", "dcba", ""]) +@test isequal(rsplit(str, ".:."; limit=4), ["a.:.ba.", ".cba.:", "dcba", ""]) +@test isequal(rsplit(str, ".:."; limit=5), ["a", "ba.", ".cba.:", "dcba", ""]) +@test isequal(rsplit(str, ".:."; limit=6), ["a", "ba.", ".cba.:", "dcba", ""]) end # zero-width splits @@ -749,7 +749,7 @@ arr = ["a","b","c"] # string iteration, and issue #1454 str = "é" -str_a = [str...] +str_a = vcat(str...) @test length(str_a)==1 @test str_a[1] == str[1] @@ -895,6 +895,14 @@ bin_val = hex2bytes("07bf") @test (@sprintf "%s" "tést") == "tést" # reasonably complex @test (@sprintf "Test: %s%c%C%c%#-.0f." "t" 65 66 67 -42) == "Test: tABC-42.." +#test simple splatting +@test (@sprintf "%d%d" [1 2]...) == "12" +# combo +@test (@sprintf "%f %d %d %f" 1.0 [3 4]... 5) == "1.000000 3 4 5.000000" +# multi +@test (@sprintf "%s %f %9.5f %d %d %d %d%d%d%d" [1:6;]... [7,8,9,10]...) == "1 2.000000 3.00000 4 5 6 78910" +# comprehension +@test (@sprintf "%s %s %s %d %d %d %f %f %f" {10^x+y for x=1:3,y=1:3 }...) == "11 101 1001 12 102 1002 13.000000 103.000000 1003.000000" # issue #4183 @test split(SubString(ascii("x"), 2, 0), "y") == String[""] @@ -1097,3 +1105,143 @@ let @test srep[7] == 'β' @test_throws BoundsError srep[8] end + +#issue #5939 uft8proc/libmojibake character predicates +let + alower=['a', 'd', 'j', 'y', 'z'] + ulower=['α', 'β', 'γ', 'δ', 'ф', 'я'] + for c in vcat(alower,ulower) + @test islower(c) == true + @test isupper(c) == false + @test isdigit(c) == false + @test isnumber(c) == false + end + + aupper=['A', 'D', 'J', 'Y', 'Z'] + uupper= ['Δ', 'Γ', 'Π', 'Ψ', 'Dž', 'Ж', 'Д'] + + for c in vcat(aupper,uupper) + @test islower(c) == false + @test isupper(c) == true + @test isdigit(c) == false + @test isnumber(c) == false + end + + nocase=['א','ﺵ'] + alphas=vcat(alower,ulower,aupper,uupper,nocase) + + for c in alphas + @test isalpha(c) == true + @test isnumber(c) == false + end + + + anumber=['0', '1', '5', '9'] + unumber=['٣', '٥', '٨', '¹', 'ⅳ' ] + + for c in anumber + @test isdigit(c) == true + @test isnumber(c) == true + end + for c in unumber + @test isdigit(c) == false + @test isnumber(c) == true + end + + alnums=vcat(alphas,anumber,unumber) + for c in alnums + @test isalnum(c) == true + @test ispunct(c) == false + end + + asymbol = ['(',')', '~', '$' ] + usymbol = ['∪', '∩', '⊂', '⊃', '√', '€', '¥', '↰', '△', '§'] + + apunct =['.',',',';',':','&'] + upunct =['‡', '؟', '჻' ] + + for c in vcat(apunct,upunct) + @test ispunct(c) == true + @test isalnum(c) == false + end + + for c in vcat(alnums,asymbol,usymbol,apunct,upunct) + @test isprint(c) == true + @test isgraph(c) == true + @test isspace(c) == false + @test iscntrl(c) == false + end + + NBSP = char(0x0000A0) + ENSPACE = char(0x002002) + EMSPACE = char(0x002003) + THINSPACE = char(0x002009) + ZWSPACE = char(0x002060) + + uspace = [ENSPACE, EMSPACE, THINSPACE] + aspace = [' '] + acntrl_space = ['\t', '\n', '\v', '\f', '\r'] + for c in vcat(aspace,uspace) + @test isspace(c) == true + @test isprint(c) == true + @test isgraph(c) == false + end + + for c in vcat(acntrl_space) + @test isspace(c) == true + @test isprint(c) == false + @test isgraph(c) == false + end + + @test isspace(ZWSPACE) == false # zero-width space + + acontrol = [ char(0x001c), char(0x001d), char(0x001e), char(0x001f)] + latincontrol = [ char(0x0080), char(0x0085) ] + ucontrol = [ char(0x200E), char(0x202E) ] + + for c in vcat(acontrol, acntrl_space, latincontrol) + @test iscntrl(c) == true + @test isalnum(c) == false + @test isprint(c) == false + @test isgraph(c) == false + end + + for c in ucontrol #non-latin1 controls + if c!=char(0x0085) + @test iscntrl(c) == false + @test isspace(c) == false + @test isalnum(c) == false + @test isprint(c) == false + @test isgraph(c) == false + end + end + +end + +@test isspace(" \t \n \r ")==true +@test isgraph(" \t \n \r ")==false +@test isprint(" \t \n \r ")==false +@test isalpha(" \t \n \r ")==false +@test isnumber(" \t \n \r ")==false +@test ispunct(" \t \n \r ")==false + +@test isspace("ΣβΣβ")==false +@test isalpha("ΣβΣβ")==true +@test isgraph("ΣβΣβ")==true +@test isprint("ΣβΣβ")==true +@test isupper("ΣβΣβ")==false +@test islower("ΣβΣβ")==false +@test isnumber("ΣβΣβ")==false +@test iscntrl("ΣβΣβ")==false +@test ispunct("ΣβΣβ")==false + +@test isnumber("23435")==true +@test isdigit("23435")==true +@test isalnum("23435")==true +@test isalpha("23435")==false +@test iscntrl( string(char(0x0080))) == true +@test ispunct( "‡؟჻") ==true + +# This caused JuliaLang/JSON.jl#82 +@test first('\x00':'\x7f') === '\x00' +@test last('\x00':'\x7f') === '\x7f'