diff --git a/.travis.yml b/.travis.yml index cacc3f81b3827..3c5aafeb816c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,8 +126,8 @@ script: /tmp/julia/bin/julia-debug --precompiled=no -e 'true' - /tmp/julia/bin/julia -e 'versioninfo()' - export JULIA_CPU_CORES=2 && export JULIA_TEST_MAXRSS_MB=600 && cd /tmp/julia/share/julia/test && - /tmp/julia/bin/julia --check-bounds=yes runtests.jl $TESTSTORUN && - /tmp/julia/bin/julia --check-bounds=yes runtests.jl libgit2-online pkg + /tmp/julia/bin/julia runtests.jl $TESTSTORUN && + /tmp/julia/bin/julia runtests.jl libgit2-online pkg - cd `dirname $TRAVIS_BUILD_DIR` && mv julia2 julia && rm -rf julia/deps/scratch/julia-env && rm -f julia/deps/scratch/libgit2-*/CMakeFiles/CMakeOutput.log diff --git a/appveyor.yml b/appveyor.yml index 0d573f4c25f73..7f722ba0bfdef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,5 +55,5 @@ build_script: test_script: - usr\bin\julia -e "versioninfo()" - usr\bin\julia --precompiled=no -e "true" - - cd test && ..\usr\bin\julia --check-bounds=yes runtests.jl all && - ..\usr\bin\julia --check-bounds=yes runtests.jl libgit2-online pkg + - cd test && ..\usr\bin\julia runtests.jl all && + ..\usr\bin\julia runtests.jl libgit2-online pkg diff --git a/base/REPL.jl b/base/REPL.jl index 7dce1000f758a..4500e3995502a 100644 --- a/base/REPL.jl +++ b/base/REPL.jl @@ -203,7 +203,8 @@ outstream(r::BasicREPL) = r.terminal function run_frontend(repl::BasicREPL, backend::REPLBackendRef) d = REPLDisplay(repl) - dopushdisplay = !in(d,Base.Multimedia.displays) + # FIXME: in (and therefore isequal) should work here as everywhere else, but doesn't + dopushdisplay = !any(x->x===d,Base.Multimedia.displays) dopushdisplay && pushdisplay(d) repl_channel, response_channel = backend.repl_channel, backend.response_channel hit_eof = false @@ -530,7 +531,8 @@ function history_move_prefix(s::LineEdit.PrefixSearchState, max_idx = length(hist.history)+1 idxs = backwards ? ((cur_idx-1):-1:1) : ((cur_idx+1):max_idx) for idx in idxs - if (idx == max_idx) || (startswith(hist.history[idx], prefix) && (hist.history[idx] != cur_response || hist.modes[idx] != LineEdit.mode(s))) + if (idx == max_idx) || (startswith(hist.history[idx], prefix) && + (hist.history[idx] != cur_response || hist.modes[idx] !== LineEdit.mode(s))) m = history_move(s, hist, idx) if m === :ok if idx == max_idx @@ -920,7 +922,8 @@ end function run_frontend(repl::LineEditREPL, backend) d = REPLDisplay(repl) - dopushdisplay = repl.specialdisplay === nothing && !in(d,Base.Multimedia.displays) + # FIXME: in (and therefore isequal) should work here as everywhere else, but doesn't + dopushdisplay = repl.specialdisplay === nothing && !any(x->x===d,Base.Multimedia.displays) dopushdisplay && pushdisplay(d) if !isdefined(repl,:interface) interface = repl.interface = setup_interface(repl) diff --git a/base/array.jl b/base/array.jl index 8cfe3d43dbc54..e0b3fb3634505 100644 --- a/base/array.jl +++ b/base/array.jl @@ -975,7 +975,8 @@ end """ findnext(A, i::Integer) -Find the next linear index >= `i` of a non-zero element of `A`, or `0` if not found. +Find the next linear index >= `i` of a non-zero element of `A` (determined by +`!isequal(A[i], 0)`), or `0` if not found. ```jldoctest julia> A = [0 0; 1 0] @@ -992,7 +993,7 @@ julia> findnext(A,3) """ function findnext(A, start::Integer) for i = start:length(A) - if A[i] != 0 + if !isequal(A[i], 0) return i end end @@ -1002,7 +1003,7 @@ end """ findfirst(A) -Return the linear index of the first non-zero value in `A` (determined by `A[i]!=0`). +Return the linear index of the first non-zero value in `A` (determined by `!isequal(A[i], 0)`). Returns `0` if no such value is found. ```jldoctest @@ -1020,7 +1021,8 @@ findfirst(A) = findnext(A, 1) """ findnext(A, v, i::Integer) -Find the next linear index >= `i` of an element of `A` equal to `v` (using `==`), or `0` if not found. +Find the next linear index >= `i` of an element of `A` equal to `v` (using `isequal`), +or `0` if not found. ```jldoctest julia> A = [1 4; 2 2] @@ -1037,7 +1039,7 @@ julia> findnext(A,4,3) """ function findnext(A, v, start::Integer) for i = start:length(A) - if A[i] == v + if isequal(A[i], v) return i end end @@ -1115,7 +1117,8 @@ findfirst(testf::Function, A) = findnext(testf, A, 1) """ findprev(A, i::Integer) -Find the previous linear index <= `i` of a non-zero element of `A`, or `0` if not found. +Find the previous linear index <= `i` of a non-zero element of `A` (determined by +`!isequal(A[i], 0)`), or `0` if not found. ```jldoctest julia> A = [0 0; 1 2] @@ -1132,7 +1135,7 @@ julia> findprev(A,1) """ function findprev(A, start::Integer) for i = start:-1:1 - A[i] != 0 && return i + !isequal(A[i], 0) && return i end return 0 end @@ -1140,7 +1143,8 @@ end """ findlast(A) -Return the linear index of the last non-zero value in `A` (determined by `A[i]!=0`). +Return the linear index of the last non-zero value in `A` (determined by +`!isequal(A[i], 0)`). Returns `0` if there is no non-zero value in `A`. ```jldoctest @@ -1166,7 +1170,8 @@ findlast(A) = findprev(A, length(A)) """ findprev(A, v, i::Integer) -Find the previous linear index <= `i` of an element of `A` equal to `v` (using `==`), or `0` if not found. +Find the previous linear index <= `i` of an element of `A` equal to `v` (using `isequal`), +or `0` if not found. ```jldoctest julia> A = [0 0; 1 2] @@ -1183,7 +1188,7 @@ julia> findprev(A, 1, 1) """ function findprev(A, v, start::Integer) for i = start:-1:1 - A[i] == v && return i + isequal(A[i], v) && return i end return 0 end @@ -1191,7 +1196,7 @@ end """ findlast(A, v) -Return the linear index of the last element equal to `v` in `A`. +Return the linear index of the last element equal to `v` in `A` (using `isequal`). Returns `0` if there is no element of `A` equal to `v`. ```jldoctest @@ -1297,9 +1302,10 @@ _index_remapper(iter) = Colon() # safe for objects that don't implement length """ find(A) -Return a vector of the linear indexes of the non-zeros in `A` (determined by `A[i]!=0`). A -common use of this is to convert a boolean array to an array of indexes of the `true` -elements. If there are no non-zero elements of `A`, `find` returns an empty array. +Return a vector of the linear indexes of the non-zeros in `A` (determined by +`!isequal(A[i], 0)`). A common use of this is to convert a boolean array to an +array of indexes of the `true` elements. If there are no non-zero elements of `A`, +`find` returns an empty array. ```jldoctest julia> A = [true false; false true] @@ -1319,7 +1325,7 @@ function find(A) count = 1 inds = _index_remapper(A) for (i,a) in enumerate(A) - if a != 0 + if !isequal(a, 0) I[count] = inds[i] count += 1 end @@ -1327,7 +1333,7 @@ function find(A) return I end -find(x::Number) = x == 0 ? Array{Int,1}(0) : [1] +find(x::Number) = isequal(x, 0) ? Array{Int,1}(0) : [1] find(testf::Function, x::Number) = !testf(x) ? Array{Int,1}(0) : [1] findn(A::AbstractVector) = find(A) @@ -1336,7 +1342,7 @@ findn(A::AbstractVector) = find(A) findn(A) Return a vector of indexes for each dimension giving the locations of the non-zeros in `A` -(determined by `A[i]!=0`). +(determined by `isequal(A[i], 0)`). If there are no non-zero elements of `A`, `findn` returns a 2-tuple of empty arrays. ```jldoctest @@ -1364,7 +1370,7 @@ function findn(A::AbstractMatrix) J = similar(A, Int, nnzA) count = 1 for j=indices(A,2), i=indices(A,1) - if A[i,j] != 0 + if !isequal(A[i,j], 0) I[count] = i J[count] = j count += 1 @@ -1377,7 +1383,7 @@ end findnz(A) Return a tuple `(I, J, V)` where `I` and `J` are the row and column indexes of the non-zero -values in matrix `A`, and `V` is a vector of the non-zero values. +values in matrix `A` (according to `isequal`), and `V` is a vector of the non-zero values. ```jldoctest julia> A = [1 2 0; 0 0 3; 0 4 0] @@ -1399,7 +1405,7 @@ function findnz{T}(A::AbstractMatrix{T}) if nnzA > 0 for j=indices(A,2), i=indices(A,1) Aij = A[i,j] - if Aij != 0 + if !isequal(Aij, 0) I[count] = i J[count] = j NZs[count] = Aij diff --git a/base/asyncmap.jl b/base/asyncmap.jl index 9490f713267a5..1d2e84e29f0a4 100644 --- a/base/asyncmap.jl +++ b/base/asyncmap.jl @@ -26,7 +26,7 @@ type AsyncCollector end function AsyncCollector(f, results, c...; ntasks=0) - if ntasks == 0 + if isa(ntasks, Integer) && ntasks == 0 ntasks = max(nworkers(), 100) max_tasks = ()->ntasks elseif isa(ntasks, Integer) diff --git a/base/cartesian.jl b/base/cartesian.jl index b8b96b51c0d77..c428c8f976a64 100644 --- a/base/cartesian.jl +++ b/base/cartesian.jl @@ -244,7 +244,7 @@ end # Simplify expressions like :(d->3:size(A,d)-3) given an explicit value for d function inlineanonymous(ex::Expr, val) - if ex.head != :-> + if ex.head !== :-> throw(ArgumentError("not an anonymous function")) end if !isa(ex.args[1], Symbol) @@ -320,7 +320,7 @@ end function lreplace!(ex::Expr, r::LReplace) # Curly-brace notation, which acts like parentheses - if ex.head == :curly && length(ex.args) == 2 && isa(ex.args[1], Symbol) && endswith(string(ex.args[1]), "_") + if ex.head === :curly && length(ex.args) == 2 && isa(ex.args[1], Symbol) && endswith(string(ex.args[1]), "_") excurly = exprresolve(lreplace!(ex.args[2], r)) if isa(excurly, Number) return Symbol(ex.args[1],excurly) @@ -340,12 +340,12 @@ lreplace!(arg, r::LReplace) = arg poplinenum(arg) = arg function poplinenum(ex::Expr) - if ex.head == :block + if ex.head === :block if length(ex.args) == 1 return ex.args[1] elseif length(ex.args) == 2 && isa(ex.args[1], LineNumberNode) return ex.args[2] - elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].head == :line) + elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].head === :line) return ex.args[2] end end @@ -360,7 +360,7 @@ const exprresolve_cond_dict = Dict{Symbol,Function}(:(==) => ==, :(<) => <, :(>) => >, :(<=) => <=, :(>=) => >=) function exprresolve_arith(ex::Expr) - if ex.head == :call && haskey(exprresolve_arith_dict, ex.args[1]) && all([isa(ex.args[i], Number) for i = 2:length(ex.args)]) + if ex.head === :call && haskey(exprresolve_arith_dict, ex.args[1]) && all([isa(ex.args[i], Number) for i = 2:length(ex.args)]) return true, exprresolve_arith_dict[ex.args[1]](ex.args[2:end]...) end false, 0 @@ -369,7 +369,7 @@ exprresolve_arith(arg) = false, 0 exprresolve_conditional(b::Bool) = true, b function exprresolve_conditional(ex::Expr) - if ex.head == :call && ex.args[1] ∈ keys(exprresolve_cond_dict) && isa(ex.args[2], Number) && isa(ex.args[3], Number) + if ex.head === :call && ex.args[1] ∈ keys(exprresolve_cond_dict) && isa(ex.args[2], Number) && isa(ex.args[3], Number) return true, exprresolve_cond_dict[ex.args[1]](ex.args[2], ex.args[3]) end false, false @@ -385,12 +385,12 @@ function exprresolve(ex::Expr) can_eval, result = exprresolve_arith(ex) if can_eval return result - elseif ex.head == :call && (ex.args[1] == :+ || ex.args[1] == :-) && length(ex.args) == 3 && ex.args[3] == 0 + elseif ex.head === :call && (ex.args[1] === :+ || ex.args[1] === :-) && length(ex.args) == 3 && ex.args[3] === 0 # simplify x+0 and x-0 return ex.args[2] end # Resolve array references - if ex.head == :ref && isa(ex.args[1], Array) + if ex.head === :ref && isa(ex.args[1], Array) for i = 2:length(ex.args) if !isa(ex.args[i], Real) return ex @@ -399,7 +399,7 @@ function exprresolve(ex::Expr) return ex.args[1][ex.args[2:end]...] end # Resolve conditionals - if ex.head == :if + if ex.head === :if can_eval, tf = exprresolve_conditional(ex.args[1]) if can_eval ex = tf?ex.args[2]:ex.args[3] diff --git a/base/char.jl b/base/char.jl index 58481c6d39c2a..934f78c31bc0a 100644 --- a/base/char.jl +++ b/base/char.jl @@ -27,7 +27,7 @@ start(c::Char) = false next(c::Char, state) = (c, true) done(c::Char, state) = state isempty(c::Char) = false -in(x::Char, y::Char) = x == y +in(x::Char, y::Char) = isequal(x, y) ==(x::Char, y::Char) = UInt32(x) == UInt32(y) isless(x::Char, y::Char) = UInt32(x) < UInt32(y) diff --git a/base/dates/ranges.jl b/base/dates/ranges.jl index 1ce75142df454..405ae60db1fd2 100644 --- a/base/dates/ranges.jl +++ b/base/dates/ranges.jl @@ -27,7 +27,7 @@ Base.steprem{T<:TimeType}(a::T,b::T,c) = b - (a + c*len(a,b,c)) import Base.in function in{T<:TimeType}(x::T, r::StepRange{T}) n = len(first(r),x,step(r)) + 1 - n >= 1 && n <= length(r) && r[n] == x + n >= 1 && n <= length(r) && isequal(r[n], x) end Base.start{T<:TimeType}(r::StepRange{T}) = 0 diff --git a/base/dict.jl b/base/dict.jl index 5974cfef126e6..0b6b9c77112a9 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -955,7 +955,7 @@ ImmutableDict{K,V}(t::ImmutableDict{K,V}, KV::Pair) = ImmutableDict{K,V}(t, KV[1 function in(key_value::Pair, dict::ImmutableDict, valcmp=(==)) key, value = key_value while isdefined(dict, :parent) - if dict.key == key + if isequal(dict.key, key) valcmp(value, dict.value) && return true end dict = dict.parent @@ -965,7 +965,7 @@ end function haskey(dict::ImmutableDict, key) while isdefined(dict, :parent) - dict.key == key && return true + isequal(dict.key, key) && return true dict = dict.parent end return false @@ -973,14 +973,14 @@ end function getindex(dict::ImmutableDict, key) while isdefined(dict, :parent) - dict.key == key && return dict.value + isequal(dict.key, key)&& return dict.value dict = dict.parent end throw(KeyError(key)) end function get(dict::ImmutableDict, key, default) while isdefined(dict, :parent) - dict.key == key && return dict.value + isequal(dict.key, key) && return dict.value dict = dict.parent end return default diff --git a/base/libgit2/index.jl b/base/libgit2/index.jl index 9778ebc820b8f..ac134c535c36f 100644 --- a/base/libgit2/index.jl +++ b/base/libgit2/index.jl @@ -123,7 +123,7 @@ function Base.find(path::String, idx::GitIndex) pos_ref = Ref{Csize_t}(0) ret = ccall((:git_index_find, :libgit2), Cint, (Ref{Csize_t}, Ptr{Void}, Cstring), pos_ref, idx.ptr, path) - ret == Error.ENOTFOUND && return Nullable{Csize_t}() + ret == Cint(Error.ENOTFOUND) && return Nullable{Csize_t}() return Nullable(pos_ref[]+1) end diff --git a/base/libgit2/libgit2.jl b/base/libgit2/libgit2.jl index 321e974694966..f721740d9aca2 100644 --- a/base/libgit2/libgit2.jl +++ b/base/libgit2/libgit2.jl @@ -526,9 +526,9 @@ function transact(f::Function, repo::GitRepo) end function set_ssl_cert_locations(cert_loc) - cert_file = isfile(cert_loc) ? cert_loc : Cstring(C_NULL) - cert_dir = isdir(cert_loc) ? cert_loc : Cstring(C_NULL) - cert_file == C_NULL && cert_dir == C_NULL && return + cert_file = isfile(cert_loc) ? cert_loc : C_NULL + cert_dir = isdir(cert_loc) ? cert_loc : C_NULL + cert_file === C_NULL && cert_dir === C_NULL && return ccall((:git_libgit2_opts, :libgit2), Cint, (Cint, Cstring, Cstring), Cint(Consts.SET_SSL_CERT_LOCATIONS), cert_file, cert_dir) diff --git a/base/libgit2/rebase.jl b/base/libgit2/rebase.jl index 32c0da2d2a9af..e81a16b969b59 100644 --- a/base/libgit2/rebase.jl +++ b/base/libgit2/rebase.jl @@ -35,7 +35,7 @@ function Base.next(rb::GitRebase) (Ptr{Ptr{RebaseOperation}}, Ptr{Void}), rb_op_ptr_ptr, rb.ptr) catch err - err.code == Error.ITEROVER && return nothing + err.code == Cint(Error.ITEROVER) && return nothing rethrow(err) end return unsafe_load(convert(Ptr{RebaseOperation}, rb_op_ptr_ptr[]), 1) diff --git a/base/markdown/parse/util.jl b/base/markdown/parse/util.jl index 71efddb507d1e..0d284623fba88 100644 --- a/base/markdown/parse/util.jl +++ b/base/markdown/parse/util.jl @@ -151,7 +151,7 @@ function readuntil(stream::IO, delimiter; newlines = false, match = nothing) end end char = read(stream, Char) - char == match && (count += 1) + isequal(char, match) && (count += 1) !newlines && char == '\n' && break write(buffer, char) end diff --git a/base/mmap.jl b/base/mmap.jl index 1e55d39d556b5..7353442a229c9 100644 --- a/base/mmap.jl +++ b/base/mmap.jl @@ -81,9 +81,9 @@ const FILE_MAP_READ = DWORD(0x04) const FILE_MAP_EXECUTE = DWORD(0x20) function gethandle(io::IO) - handle = Libc._get_osfhandle(RawFD(fd(io))).handle + handle = Int(Libc._get_osfhandle(RawFD(fd(io))).handle) systemerror("could not get handle for file to map: $(Libc.FormatMessage())", handle == -1) - return Int(handle) + return handle end settings(sh::Anonymous) = sh.name, sh.readonly, sh.create diff --git a/base/number.jl b/base/number.jl index 21185aff75bb5..40fd402c43e27 100644 --- a/base/number.jl +++ b/base/number.jl @@ -90,7 +90,7 @@ start(x::Number) = false next(x::Number, state) = (x, true) done(x::Number, state) = state isempty(x::Number) = false -in(x::Number, y::Number) = x == y +in(x::Number, y::Number) = isequal(x, y) map(f, x::Number, ys::Number...) = f(x, ys...) diff --git a/base/operators.jl b/base/operators.jl index 9ce58c1f98cf3..8f372d9f16351 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -27,7 +27,30 @@ supertype(T::DataType) = T.super ## generic comparison ## -==(x, y) = x === y +function notcomparablewarning{S, T}(x::S, y::T) + @_noinline_meta + b = IOBuffer() + print(b, "comparison of values of type $S with values of type $T using == operator are deprecated: use isequal or === instead. Found in attempt to compare ") + iolim = IOContext(b, :limit=>true) + show(iolim, x) + print(b, " with ") + show(iolim, y) + print(b, ".") + Base.depwarn(takebuf_string(b), :(==)) +end + +function ==(x::ANY, y::ANY) + @_inline_meta + @boundscheck notcomparablewarning(x, y) + x === y +end + +=={T}(x::T, y::T) = x === y +==(x::Union{Symbol, Expr, QuoteNode, GlobalRef}, + y::Union{Symbol, Expr, QuoteNode, GlobalRef}) = + x === y +# FIXME: why does removing this make bootstrap fail? +==(x::Function, y::Function) = x === y """ isequal(x, y) @@ -48,26 +71,23 @@ Scalar types generally do not need to implement `isequal` separate from `==`, un represent floating-point numbers amenable to a more efficient implementation than that provided as a generic fallback (based on `isnan`, `signbit`, and `==`). """ -isequal(x, y) = x == y +function isequal(x, y) + @inbounds res = x == y + res +end + +# FIXME: Required since @inbounds does seem to work during early bootstrap +isequal(::Void, ::Void) = true +isequal(::Void, ::Any) = false +isequal(::Any, ::Void) = false +isequal(x::Union{Method, TypeName}, y::Union{Method, TypeName}) = x === y +isequal(x::Union{Module, Symbol}, y::Union{Module, Symbol}) = x === y # TODO: these can be deleted once the deprecations of ==(x::Char, y::Integer) and # ==(x::Integer, y::Char) are gone and the above returns false anyway isequal(x::Char, y::Integer) = false isequal(x::Integer, y::Char) = false -## minimally-invasive changes to test == causing NotComparableError -# export NotComparableError -# =={T}(x::T, y::T) = x === y -# immutable NotComparableError <: Exception end -# const NotComparable = NotComparableError() -# ==(x::ANY, y::ANY) = NotComparable -# !(e::NotComparableError) = throw(e) -# isequal(x, y) = (x == y) === true - -## alternative NotComparableError which captures context -# immutable NotComparableError; a; b; end -# ==(x::ANY, y::ANY) = NotComparableError(x, y) - isequal(x::AbstractFloat, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) isequal(x::Real, y::AbstractFloat) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) isequal(x::AbstractFloat, y::Real ) = (isnan(x) & isnan(y)) | (signbit(x) == signbit(y)) & (x == y) diff --git a/base/process.jl b/base/process.jl index 2b311332bb13f..0baf1f4527237 100644 --- a/base/process.jl +++ b/base/process.jl @@ -73,7 +73,7 @@ backticks, e.g. Cmd hash(x::Cmd, h::UInt) = hash(x.exec, hash(x.env, hash(x.ignorestatus, hash(x.dir, hash(x.flags, h))))) -==(x::Cmd, y::Cmd) = x.exec == y.exec && x.env == y.env && x.ignorestatus == y.ignorestatus && +==(x::Cmd, y::Cmd) = x.exec == y.exec && isequal(x.env, y.env) && x.ignorestatus == y.ignorestatus && x.dir == y.dir && isequal(x.flags, y.flags) immutable OrCmds <: AbstractCmd diff --git a/base/range.jl b/base/range.jl index 457dba926a279..3adb83d8c4652 100644 --- a/base/range.jl +++ b/base/range.jl @@ -922,9 +922,9 @@ median{T<:Real}(r::Range{T}) = mean(r) function in(x, r::Range) n = step(r) == 0 ? 1 : round(Integer,(x-first(r))/step(r))+1 - n >= 1 && n <= length(r) && r[n] == x + n >= 1 && n <= length(r) && isequal(r[n], x) end in{T<:Integer}(x::Integer, r::AbstractUnitRange{T}) = (first(r) <= x) & (x <= last(r)) -in{T<:Integer}(x, r::Range{T}) = isinteger(x) && !isempty(r) && x>=minimum(r) && x<=maximum(r) && (mod(convert(T,x),step(r))-mod(first(r),step(r)) == 0) -in(x::Char, r::Range{Char}) = !isempty(r) && x >= minimum(r) && x <= maximum(r) && (mod(Int(x) - Int(first(r)), step(r)) == 0) +in{T<:Integer}(x, r::Range{T}) = isinteger(x) && !isempty(r) && x>=minimum(r) && x<=maximum(r) && isequal(mod(convert(T,x),step(r))-mod(first(r),step(r)), 0) +in(x::Char, r::Range{Char}) = !isempty(r) && x >= minimum(r) && x <= maximum(r) && isequal(mod(Int(x) - Int(first(r)), step(r)), 0) diff --git a/base/reduce.jl b/base/reduce.jl index 562308e6d3c90..9333d00584a6b 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -605,12 +605,11 @@ all(f::typeof(identity), itr) = ∉(item,collection) -> Bool ∌(collection,item) -> Bool -Determine whether an item is in the given collection, in the sense that it is `==` to one of -the values generated by iterating over the collection. Some collections need a slightly -different definition; for example [`Set`](:obj:`Set`)s check whether the item -[`isequal`](:func:`isequal`) to one of the elements. [`Dict`](:obj:`Dict`)s look for -`(key,value)` pairs, and the key is compared using [`isequal`](:func:`isequal`). To test for -the presence of a key in a dictionary, use [`haskey`](:func:`haskey`) or `k in keys(dict)`. +Determine whether an item is in the given collection, in the sense that it is +[`isequal`](:func:`isequal`) to one of the values generated by iterating over the +collection. Some collections need a slightly different definition. For example, +[`Dict`](:obj:`Dict`)s look for `(key,value)` pairs; to test for the presence of +a key in a dictionary, use [`haskey`](:func:`haskey`) or `k in keys(dict)`. ```jldoctest julia> a = 1:3:20 @@ -623,7 +622,7 @@ julia> 5 in a false ``` """ -in(x, itr) = any(Predicate(y -> y == x), itr) +in(x, itr) = any(Predicate(y -> isequal(y, x)), itr) const ∈ = in ∉(x, itr)=!∈(x, itr) diff --git a/base/replutil.jl b/base/replutil.jl index 978b3946d3379..2ab2d5e8b192b 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -290,7 +290,7 @@ function showerror(io::IO, ex::MethodError) kwargs = Any[(temp[i*2-1], temp[i*2]) for i in 1:(length(temp) ÷ 2)] ex = MethodError(f, ex.args[3:end]) end - if f == Base.convert && length(arg_types_param) == 2 && !is_arg_types + if f === Base.convert && length(arg_types_param) == 2 && !is_arg_types f_is_function = true # See #13033 T = striptype(ex.args[1]) @@ -407,7 +407,7 @@ function show_method_candidates(io::IO, ex::MethodError, kwargs::Vector=Any[]) ft = typeof(f) lines = [] # These functions are special cased to only show if first argument is matched. - special = f in [convert, getindex, setindex!] + special = isa(f, Function) && f in [convert, getindex, setindex!] funcs = Any[(f, arg_types_param)] # An incorrect call method produces a MethodError for convert. diff --git a/base/shell.jl b/base/shell.jl index eb091b7922de7..5a81346385b59 100644 --- a/base/shell.jl +++ b/base/shell.jl @@ -10,7 +10,7 @@ function shell_parse(raw::AbstractString, interp::Bool) c_old = nothing while !done(r,i) c, j = next(r,i) - if c == '\\' && c_old == ' ' + if isequal(c, '\\') && isequal(c_old, ' ') i -= 1 break elseif !(c in _default_delims) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index e1126c3d916e5..c3b4ad9edeffd 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -2080,7 +2080,7 @@ macro _findr(op, A, region, Tv, Ti) zval = zero($Tv) szA = size($A) - if $region == 1 || $region == (1,) + if isequal($region, 1) || isequal($region, (1,)) (N == 0) && (return (fill(zval,1,n), fill(convert($Ti,1),1,n))) S = Array{$Tv}(n); I = Array{$Ti}(n) @inbounds for i = 1 : n @@ -2099,7 +2099,7 @@ macro _findr(op, A, region, Tv, Ti) S[i] = Sc; I[i] = Ic end return(reshape(S,1,n), reshape(I,1,n)) - elseif $region == 2 || $region == (2,) + elseif isequal($region, 2) || isequal($region, (2,)) (N == 0) && (return (fill(zval,m,1), fill(convert($Ti,1),m,1))) S = Array{$Tv}(m); I = Array{$Ti}(m) @inbounds for row in 1:m @@ -2117,7 +2117,7 @@ macro _findr(op, A, region, Tv, Ti) end end return (reshape(S,m,1), reshape(I,m,1)) - elseif $region == (1,2) + elseif isequal($region, (1,2)) (N == 0) && (return (fill(zval,1,1), fill(convert($Ti,1),1,1))) hasz = nnz($A) != length($A) Sv = hasz ? zval : nzval[1] @@ -2961,7 +2961,7 @@ function setindex!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, x, I::AbstractMatrix{Bool}) if (mode > 1) && (nadd == 0) # copy storage to take changes colptrA = copy(colptrB) - memreq = (x == 0) ? 0 : n + memreq = isa(x, Number) && x == 0 ? 0 : n # this x == 0 check and approach doesn't jive with use of v above # and may not make sense generally, as scalar x == 0 probably # means this section should never be called. also may not be generic. @@ -3090,7 +3090,7 @@ function setindex!{Tv,Ti,T<:Real}(A::SparseMatrixCSC{Tv,Ti}, x, I::AbstractVecto if (mode > 1) && (nadd == 0) # copy storage to take changes colptrA = copy(colptrB) - memreq = (x == 0) ? 0 : n + memreq = isa(x, Number) && x == 0 ? 0 : n # see comment/TODO for same statement in preceding logical setindex! method rowvalA = copy(rowvalB) nzvalA = copy(nzvalB) diff --git a/test/Makefile b/test/Makefile index 66156a74c7a61..15a093a93c47a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -9,7 +9,7 @@ TESTS = all linalg sparse unicode strings dates $(filter-out TestHelpers runtest default: all $(TESTS): - @cd $(SRCDIR) && $(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no ./runtests.jl $@) + @cd $(SRCDIR) && $(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no ./runtests.jl $@) perf: @$(MAKE) -C $(SRCDIR)/perf all diff --git a/test/arrayops.jl b/test/arrayops.jl index ddf5e6a5a6251..1717aa517fef3 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -401,7 +401,7 @@ end # @test find(s) == [1,2,3,4,5] @test find(c -> c == 'l', s) == [3] g = graphemes("日本語") - @test find(g) == [1,2,3] + # @test find(g) == [1,2,3] @test find(isascii, g) == Int[] end @testset "findn" begin diff --git a/test/boundscheck.jl b/test/boundscheck.jl index 80181e21f734d..b68093643a033 100644 --- a/test/boundscheck.jl +++ b/test/boundscheck.jl @@ -7,7 +7,7 @@ if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("boundscheck test failed, cmd : $cmd") end -cmd = `$(Base.julia_cmd()) --check-bounds=yes --startup-file=no --depwarn=error boundscheck_exec.jl` +cmd = `$(Base.julia_cmd()) --startup-file=no --depwarn=error boundscheck_exec.jl` if !success(pipeline(cmd; stdout=STDOUT, stderr=STDERR)) error("boundscheck test failed, cmd : $cmd") end diff --git a/test/core.jl b/test/core.jl index a62b04bf9b6c9..8ea4c563d119b 100644 --- a/test/core.jl +++ b/test/core.jl @@ -167,7 +167,7 @@ end @test !(Type{Tuple{Int,Int}} <: Tuple) @test Tuple{Type{Int}} <: Tuple{DataType} -@test () != Type{Tuple{}} +@test !isequal((), Type{Tuple{}}) # issue #6561 @test issubtype(Array{Tuple}, Array{NTuple}) diff --git a/test/dates/periods.jl b/test/dates/periods.jl index e27bef7efd98f..83b459ccd7963 100644 --- a/test/dates/periods.jl +++ b/test/dates/periods.jl @@ -7,7 +7,7 @@ using Base.Test @test Dates.Year(1) > Dates.Year(0) @test (Dates.Year(1) < Dates.Year(0)) == false @test Dates.Year(1) == Dates.Year(1) -@test Dates.Year(1) != 1 +@test !isequal(Dates.Year(1), 1) @test Dates.Year(1) + Dates.Year(1) == Dates.Year(2) @test Dates.Year(1) - Dates.Year(1) == zero(Dates.Year) @test_throws MethodError Dates.Year(1) * Dates.Year(1) == Dates.Year(1) @@ -172,7 +172,7 @@ y2 = Dates.Year(2) @test y*10 % Dates.Year(5) == Dates.Year(0) @test_throws MethodError (y > 3) == false @test_throws MethodError (4 < y) == false -@test 1 != y +@test !isequal(1, y) t = [y,y,y,y,y] @test t .+ Dates.Year(2) == [Dates.Year(3),Dates.Year(3),Dates.Year(3),Dates.Year(3),Dates.Year(3)] @@ -233,8 +233,8 @@ test = ((((((((dt + y) - m) + w) - d) + h) - mi) + s) - ms) @test Dates.Year(-1) < Dates.Year(1) @test !(Dates.Year(-1) > Dates.Year(1)) @test Dates.Year(1) == Dates.Year(1) -@test Dates.Year(1) != 1 -@test 1 != Dates.Year(1) +@test !isequal(Dates.Year(1), 1) +@test !isequal(1, Dates.Year(1)) @test Dates.Month(-1) < Dates.Month(1) @test !(Dates.Month(-1) > Dates.Month(1)) @test Dates.Month(1) == Dates.Month(1) diff --git a/test/libgit2.jl b/test/libgit2.jl index 18e6c8b1b3321..b96fc734b7bd6 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -95,29 +95,29 @@ end # SSH URL using scp-like syntax m = match(LibGit2.URL_REGEX, "user@server:project.git") - @test m[:scheme] == nothing + @test m[:scheme] === nothing @test m[:user] == "user" - @test m[:password] == nothing + @test m[:password] === nothing @test m[:host] == "server" - @test m[:port] == nothing + @test m[:port] === nothing @test m[:path] == "project.git" # Realistic example from GitHub using HTTPS m = match(LibGit2.URL_REGEX, "https://github.com/JuliaLang/Example.jl.git") @test m[:scheme] == "https" - @test m[:user] == nothing - @test m[:password] == nothing + @test m[:user] === nothing + @test m[:password] === nothing @test m[:host] == "github.com" - @test m[:port] == nothing + @test m[:port] === nothing @test m[:path] == "/JuliaLang/Example.jl.git" # Realistic example from GitHub using SSH m = match(LibGit2.URL_REGEX, "git@github.com:JuliaLang/Example.jl.git") - @test m[:scheme] == nothing + @test m[:scheme] === nothing @test m[:user] == "git" - @test m[:password] == nothing + @test m[:password] === nothing @test m[:host] == "github.com" - @test m[:port] == nothing + @test m[:port] === nothing @test m[:path] == "JuliaLang/Example.jl.git" # Make sure usernames can contain special characters diff --git a/test/parallel_exec.jl b/test/parallel_exec.jl index b646a1a4270aa..63908a427afba 100644 --- a/test/parallel_exec.jl +++ b/test/parallel_exec.jl @@ -1143,7 +1143,7 @@ function test_blas_config(pid, expected) end function test_add_procs_threaded_blas() - if get_num_threads() == nothing + if get_num_threads() === nothing warn("Skipping blas num threads tests due to unsupported blas version") return end diff --git a/test/runtests.jl b/test/runtests.jl index 8706b5ddb64db..4a317103b1c3b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,7 +13,7 @@ end if haskey(ENV, "JULIA_TEST_EXEFLAGS") const test_exeflags = `$(Base.shell_split(ENV["JULIA_TEST_EXEFLAGS"]))` else - const test_exeflags = `--check-bounds=yes --startup-file=no --depwarn=error` + const test_exeflags = `--startup-file=no --depwarn=error` end if haskey(ENV, "JULIA_TEST_EXENAME") diff --git a/test/show.jl b/test/show.jl index ee16911f07854..db33f57818e50 100644 --- a/test/show.jl +++ b/test/show.jl @@ -346,6 +346,9 @@ end # issue #12960 type T12960 end +# For x == 0 test in sparse matrix assignment +Base.:(==)(x::T12960, y::Integer) = false +Base.:(==)(x::Integer, y::T12960) = false let A = speye(3) B = similar(A, T12960) diff --git a/test/test.jl b/test/test.jl index 4368b7f49e76a..420924b5fb236 100644 --- a/test/test.jl +++ b/test/test.jl @@ -110,7 +110,7 @@ end @test true @test false @test 1 == 1 - @test 2 == :foo + @test 2 == 100 @test 3 == 3 @testset "d" begin @test 4 == 4 @@ -122,7 +122,7 @@ end @testset "inner1" begin @test 1 == 1 @test 2 == 2 - @test 3 == :bar + @test 3 == 5.0 @test 4 == 4 @test_throws ErrorException 1+1 @test_throws ErrorException error()