Skip to content

Commit

Permalink
Bugfix #18073
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeach24 committed Aug 18, 2016
1 parent 0350e57 commit 7cade48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ any(f::Predicate, itr) = mapreduce_sc_impl(f, |, itr)
any(f::typeof(identity), itr) =
eltype(itr) <: Bool ?
mapreduce_sc_impl(f, |, itr) :
reduce(or_bool_only, itr)
reduce(or_bool_only, false, itr)

"""
all(p, itr) -> Bool
Expand All @@ -474,7 +474,7 @@ all(f::Predicate, itr) = mapreduce_sc_impl(f, &, itr)
all(f::typeof(identity), itr) =
eltype(itr) <: Bool ?
mapreduce_sc_impl(f, &, itr) :
reduce(and_bool_only, itr)
reduce(and_bool_only, true, itr)

## in & contains

Expand Down
4 changes: 4 additions & 0 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)

# any & all

@test any([]) == false
@test any(Bool[]) == false
@test any([true]) == true
@test any([false, false]) == false
Expand All @@ -183,6 +184,7 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)
@test any([true, false, true]) == true
@test any([false, false, false]) == false

@test all([]) == true
@test all(Bool[]) == true
@test all([true]) == true
@test all([false, false]) == false
Expand All @@ -193,11 +195,13 @@ prod2(itr) = invoke(prod, Tuple{Any}, itr)
@test all([true, false, true]) == false
@test all([false, false, false]) == false

@test any(x->x>0, []) == false
@test any(x->x>0, Int[]) == false
@test any(x->x>0, [-3]) == false
@test any(x->x>0, [4]) == true
@test any(x->x>0, [-3, 4, 5]) == true

@test all(x->x>0, []) == true
@test all(x->x>0, Int[]) == true
@test all(x->x>0, [-3]) == false
@test all(x->x>0, [4]) == true
Expand Down

0 comments on commit 7cade48

Please sign in to comment.