-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document interactive stuff, add a few tests
- Loading branch information
1 parent
47c9a62
commit eaeebb7
Showing
6 changed files
with
122 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
notnothingtype(::Type{T}) where T = T | ||
notnothingtype(::Type{Union{T, Nothing}}) where T = T | ||
|
||
@testset "Interactive mode" begin | ||
@testset "convert_input has all required methods" begin | ||
Fs = mapreduce(union!, PT.concretes(PT.Plugin); init=Set()) do T | ||
map(notnothingtype, fieldtypes(T)) | ||
end | ||
foreach(Fs) do F | ||
@test hasmethod(PT.convert_input, Tuple{Type{Template}, Type{F}, AbstractString}) | ||
end | ||
end | ||
|
||
@testset "input_tips" begin | ||
@test isempty(PT.input_tips(Int)) | ||
@test PT.input_tips(Vector{String}) == ["comma-delimited"] | ||
@test PT.input_tips(Union{Vector{String}, Nothing}) == | ||
["empty for nothing", "comma-delimited"] | ||
@test PT.input_tips(Union{String, Nothing}) == ["empty for nothing"] | ||
@test PT.input_tips(Union{Vector{Secret}, Nothing}) == | ||
["empty for nothing", "comma-delimited", "name only"] | ||
end | ||
|
||
@testset "Interactive name/type pair collection" begin | ||
name = gensym() | ||
@eval begin | ||
struct $name <: PT.Plugin | ||
x::Int | ||
y::String | ||
end | ||
|
||
@test PT.interactive_pairs($name) == [:x => Int, :y => String] | ||
|
||
PT.not_customizable(::Type{$name}) = (:x,) | ||
@test PT.interactive_pairs($name) == [:y => String] | ||
|
||
PT.extra_customizable(::Type{$name}) = (:y => Float64, :z => Int) | ||
@test PT.interactive_pairs($name) == [:y => Float64, :z => Int] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters