Skip to content

Commit

Permalink
Get things working on v0.5 (#212)
Browse files Browse the repository at this point in the history
- Export complement if not available in Base
- Adjust exception type that change between 0.4 and 0.5
- primes was moved to the Primes package
  • Loading branch information
ranjanan authored and Keno committed Jul 27, 2016
1 parent ccc1e2f commit 06792b4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/int_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import Base: similar, copy, copy!, eltype, push!, pop!, delete!, shift!,
setdiff, setdiff!, symdiff, symdiff!, in, start, next, done,
last, length, show, hash, issubset, ==, <=, <, unsafe_getindex,
unsafe_setindex!, findnextnot, first
# These names will be removed from Base in the future:
import Base: complement, complement!
if !isdefined(Base, :complement)
export complement, complement!
else
import Base: complement, complement!
end

type IntSet
bits::BitVector
Expand Down
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Compat 0.7.16
Primes 0.1.1
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using Base.Test
using DataStructures
const IntSet = DataStructures.IntSet
import Compat: String
using Primes

tests = ["int_set",
"deque",
Expand Down
7 changes: 6 additions & 1 deletion test/test_circular_buffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ using Base.Test
cb = CircularBuffer{Int}(5)
@test length(cb) == 0
@test capacity(cb) == 5
@test_throws ArgumentError first(cb)
# throws ArgumentError on v0.4 and BoundsError on v0.5 (diverged at 0.5.0-dev+5230)
if VERSION >= v"0.5.0-dev+5230"
@test_throws BoundsError first(cb)
else
@test_throws ArgumentError first(cb)
end
@test isempty(cb) == true
@test isfull(cb) == false

Expand Down
12 changes: 9 additions & 3 deletions test/test_multi_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ d = MultiDict{Char,Int}()

@test_throws KeyError d['c'] == 1
insert!(d, 'c', 1)
@test collect(keys(d)) == ['c', 'a']
@test collect(values(d)) == Array{Int,1}[[1],[1,2,3]]

# order changed from v0.4 to v0.5
@test collect(keys(d)) == ['c', 'a'] || collect(keys(d)) == ['a', 'c']
@test collect(values(d)) == Array{Int,1}[[1],[1,2,3]] || collect(values(d)) == Array{Int,1}[[1,2,3], [1]]

@test get(d, 'a', 0) == [1,2,3]
@test get(d, 'b', 0) == 0
Expand All @@ -45,7 +47,11 @@ insert!(d, 'c', 1)
@test copy(d) == d
@test similar(d) == MultiDict{Char,Int}()

@test [kv for kv in d] == [Pair('c', [1]), Pair('a', [1,2,3])]
# order changed from v0.4 to v0.5
let dict = [kv for kv in d]
@test dict == [Pair('c', [1]), Pair('a', [1,2,3])] ||
dict == [Pair('a', [1,2,3]), Pair('c', [1])]
end

@test in(('c', 1), d)
@test in(('a', 1), d)
Expand Down
6 changes: 4 additions & 2 deletions test/test_ordered_dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ let
@test get_KeyError
end

_d = OrderedDict([("a", 0)])
@test isa([k for k in filter(x->length(x)==1, collect(keys(_d)))], Vector{Any})
let _d = OrderedDict([("a", 0)])
v = [k for k in filter(x->length(x)==1, collect(keys(_d)))]
@test isa(v, Vector{String}) || isa(v, Vector{ASCIIString})
end

let d = OrderedDict(((1, 2), (3, 4))),
d2 = OrderedDict([(1, 2), (3, 4)]),
Expand Down

0 comments on commit 06792b4

Please sign in to comment.