Skip to content

Commit

Permalink
Merge pull request #6 from cite-architecture/dev
Browse files Browse the repository at this point in the history
Correct type inheritance
  • Loading branch information
neelsmith authored Jun 4, 2021
2 parents 66497a7 + 98c4295 commit 4631077
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CitableBase"
uuid = "d6f014bd-995c-41bd-9893-703339864534"
authors = ["Neel Smith <[email protected]>"]
version = "1.2.1"
version = "1.2.2"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
4 changes: 2 additions & 2 deletions src/versions.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Catch-all function for `dropversion` method.
$(SIGNATURES)
"""
function dropversion(u::Urn)
function dropversion(u::T) where {T <: Urn}
msg = string("dropversion not implemented for ", typeof(u))
@warn(msg)
nothing
Expand All @@ -10,7 +10,7 @@ end
"""Catch-all function for `addversion` method.
$(SIGNATURES)
"""
function addversion(u::Urn, s::AbstractString)
function addversion(u::T, s::AbstractString) where {T <: Urn}
msg = string("addversion not implemented for ", typeof(u))
@warn(msg)
nothing
Expand Down
17 changes: 17 additions & 0 deletions test/test_functiondefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ end
u = FakeUrn("urn:fake:id.subid")
@test isnothing(dropversion(u))
@test isnothing(addversion(u, "versionid"))
end



@testset "Test ovveride validurn" begin
struct FakeUrn <: Urn
urn::AbstractString
end
function dropversion(u::FakeUrn)
"Success"
end
function addversion(u::FakeUrn, s)
"Success adding $s"
end
u = FakeUrn("urn:fake:id.subid")
@test dropversion(u) == "Success"
@test addversion(u, "versionid") == "Success adding versionid"
end

0 comments on commit 4631077

Please sign in to comment.