Skip to content

Commit

Permalink
test set Name
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Nov 22, 2020
1 parent 12a08c4 commit 21b57bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/name.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@

abstract type AbstractName end

struct NoName <: AbstractName end
struct Name{X} <: AbstractName end
Name(name::Symbol) = Name{name}()

Base.Symbol(::Name{X}) where X = X
Base.string(::Name{X}) where X = string(X)

struct NoName <: AbstractName end

Base.string(::NoName) = ""
Base.Symbol(::Name{X}) where X = X
Base.Symbol(::NoName) = Symbol("")
2 changes: 2 additions & 0 deletions test/set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ ds = DimDataset(da2, DimArray(2a2, dimz2, :test3))

@testset " Array fields" begin
@test name(set(da2, :newname)) == :newname
@test name(set(da2, Name(:newname))) == Name{:newname}()
@test name(set(da2, NoName())) == NoName()
@test metadata(set(da2, ArrayMetadata(Dict(:testa => "test")))).val == Dict(:testa => "test")
@test parent(set(da2, fill(9, 3, 4))) == fill(9, 3, 4)
# A differently sized array can't be set
Expand Down

0 comments on commit 21b57bd

Please sign in to comment.