Skip to content

Commit

Permalink
fix set
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 14, 2023
1 parent 47a5609 commit fab1adc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
30 changes: 15 additions & 15 deletions BaseInterfaces/src/BaseInterfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ include("set.jl")
include("array.jl")

# Some example interface delarations.
@implements IterationInterface{(:reverse,:indexing,)} UnitRange
@implements IterationInterface{(:reverse,:indexing,)} StepRange
@implements IterationInterface{(:reverse,:indexing,)} Array
@implements IterationInterface{(:reverse,)} Base.Generator
@implements IterationInterface{(:reverse,:indexing,)} Tuple

@implements SetInterface Set
@implements ArrayInterface Base.LogicalIndex # No getindex
@implements ArrayInterface{(:getindex,)} UnitRange
@implements ArrayInterface{(:getindex,)} StepRange
@implements ArrayInterface{(:getindex,:setindex,)} Array
@implements ArrayInterface{(:getindex,:setindex,)} SubArray
@implements ArrayInterface{(:getindex,:setindex,)} PermutedDimsArray
@implements ArrayInterface{(:getindex,:setindex,)} Base.ReshapedArray

@implements DictInterface{(:setindex,)} Dict
@implements DictInterface{(:setindex,)} IdDict
Expand All @@ -26,13 +26,13 @@ include("array.jl")
@implements DictInterface Base.ImmutableDict
@implements DictInterface Base.Pairs

# Some example interface delarations.
@implements ArrayInterface Base.LogicalIndex # No getindex
@implements ArrayInterface{(:getindex,)} UnitRange
@implements ArrayInterface{(:getindex,)} StepRange
@implements ArrayInterface{(:getindex,:setindex,)} Array
@implements ArrayInterface{(:getindex,:setindex,)} SubArray
@implements ArrayInterface{(:getindex,:setindex,)} PermutedDimsArray
@implements ArrayInterface{(:getindex,:setindex,)} Base.ReshapedArray
@implements IterationInterface{(:reverse,:indexing,)} UnitRange
@implements IterationInterface{(:reverse,:indexing,)} StepRange
@implements IterationInterface{(:reverse,:indexing,)} Array
@implements IterationInterface{(:reverse,)} Base.Generator
@implements IterationInterface{(:reverse,:indexing,)} Tuple

@implements SetInterface Set
@implements SetInterface BitSet

end
1 change: 1 addition & 0 deletions BaseInterfaces/src/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Requirements for AbstractSet subtypes:

mandatory = (
type = s -> s isa AbstractSet,
eltype = "elements eltype of set `s` are subtypes of `eltype(s)`" => s -> typeof(first(iterate(s))) <: eltype(s),
length = "set defines length and test object has length larger than zero" => s -> length(s) isa Int && length(s) > 0,
iteration = "follows the IterationInterface" => x -> Interfaces.test(IterationInterface, x),
Expand Down
1 change: 1 addition & 0 deletions BaseInterfaces/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ end

@testset "SetInterface" begin
@test Interfaces.test(SetInterface, Set, [Set((1, 2))])
@test Interfaces.test(SetInterface, BitSet, [BitSet((1, 2))])
end

0 comments on commit fab1adc

Please sign in to comment.