Skip to content

Commit

Permalink
Merge pull request #61 from Herb-AI/resolve-ambiguity
Browse files Browse the repository at this point in the history
Resolve ambiguity in `in(::StateStack, ::Any)` method
  • Loading branch information
ReubenJ authored Jul 5, 2024
2 parents 137ab66 + b207190 commit 9f199f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "HerbConstraints"
uuid = "1fa96474-3206-4513-b4fa-23913f296dfc"
authors = ["Jaap de Jong <[email protected]>"]
version = "0.2.1"
version = "0.2.2"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
2 changes: 1 addition & 1 deletion src/solver/uniform_solver/state_stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ end
Checks whether the `value` is in the `stack`.
"""
function Base.in(stack::StateStack, value)::Bool
function Base.in(stack::StateStack{T}, value::T)::Bool where T
return value stack.vec[1:size(stack)]
end
22 changes: 22 additions & 0 deletions test/test_state_stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@
@test size(stack) == 0
end

@testset "membership" begin
sm = HerbConstraints.StateManager()
stack = HerbConstraints.StateStack{Int}(sm)
push!(stack, 10)
push!(stack, 20)
push!(stack, 30)
@test in(stack, 10)
@test in(stack, 20)
@test in(stack, 30)
@test !in(stack, 40)

sm = HerbConstraints.StateManager()
stack = HerbConstraints.StateStack{String}(sm)
push!(stack, "A")
push!(stack, "B")
push!(stack, "C")
@test in(stack, "A")
@test in(stack, "B")
@test in(stack, "C")
@test !in(stack, "D")
end

@testset "from vector" begin
sm = HerbConstraints.StateManager()
stack = HerbConstraints.StateStack{Int}(sm, [10, 20, 30])
Expand Down

2 comments on commit 9f199f4

@ReubenJ
Copy link
Member Author

@ReubenJ ReubenJ commented on 9f199f4 Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/110502

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.2 -m "<description of version>" 9f199f467cc4fb45b74a3a60f9f597cd1058fc21
git push origin v0.2.2

Please sign in to comment.