From 6b45b6e1c9807bd687d61cc8d92fbcf61d566dcc Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 5 Jun 2019 14:54:16 -0400 Subject: [PATCH] misc tests for keytype, valtype and some find* functions (#32229) --- test/abstractarray.jl | 4 ++-- test/arrayops.jl | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test/abstractarray.jl b/test/abstractarray.jl index f801d9982176d..9ef96a3211b2a 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -865,8 +865,8 @@ for A in (rand(2), rand(2,3)) end @test Array(values(A)) == A - @test keytype(A) == eltype(keys(A)) - @test valtype(A) == eltype(values(A)) + @test keytype(A) == keytype(typeof(A)) == eltype(keys(A)) + @test valtype(A) == valtype(typeof(A)) == eltype(values(A)) end # nextind and prevind diff --git a/test/arrayops.jl b/test/arrayops.jl index 4e989217cc5c3..797bc498dd31e 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -381,6 +381,14 @@ end @test findall(in([1, 2]), 2) == [1] @test findall(in([1, 2]), 3) == [] + + @test sort(findall(Dict(1=>false, 2=>true, 3=>true))) == [2, 3] + + @test findall(true) == [1] + @test findall(false) == Int[] + + @test findall(isodd, 1) == [1] + @test findall(isodd, 2) == Int[] end @testset "setindex! return type" begin rt = Base.return_types(setindex!, Tuple{Array{Int32, 3}, Vector{UInt8}, Vector{Int}, Int16, UnitRange{Int}}) @@ -526,6 +534,7 @@ end @test findfirst(!iszero, a) == 2 @test findfirst(a.==0) == 1 @test findfirst(a.==5) == nothing + @test findfirst(Dict(1=>false, 2=>true)) == 2 @test findfirst(isequal(3), [1,2,4,1,2,3,4]) == 6 @test findfirst(!isequal(1), [1,2,4,1,2,3,4]) == 2 @test findfirst(isodd, [2,4,6,3,9,2,0]) == 4