Skip to content

Commit

Permalink
Merge ee0d51f into 3460054
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelraz committed Apr 30, 2019
2 parents 3460054 + ee0d51f commit b34bcb6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ValueSymbols.jl
Expand Up @@ -13,6 +13,7 @@ Base.convert(::Type{String}, vsym ::ValueSymbol) =
String(convert(Symbol,vsym))

Base.promote_rule(::Type{ValueSymbol}, ::Type{Symbol}) = ValueSymbol
Base.promote_rule(::Type{Symbol}, ::Type{ValueSymbol}) = ValueSymbol

# Output
Base.show(io::IO, vsym::ValueSymbol) = show(io, convert(Symbol, vsym))
Expand Down
27 changes: 26 additions & 1 deletion test/runtests.jl
Expand Up @@ -32,6 +32,8 @@ vsyms = map(ValueSymbol, syms)
@test vsyms[1] == ValueSymbol(:car)
@test vsyms[2] != ValueSymbol(:car)
@test vsyms[3] != vsyms[2]
@test syms[1] != vsyms[1].ptr
@test syms[2] != vsyms[1].ptr

# ValueSymbol and Symbol are different types, so comparing them via
# `===` is always false
Expand All @@ -49,7 +51,13 @@ vsyms = map(ValueSymbol, syms)

@test vsyms[1] <= syms[1]
@test vsyms[1] > syms[2]
@test vsyms[1] <vsyms[3]
@test vsyms[1] < vsyms[3]

@test vsyms[1] < syms[3]
@test vsyms[2] < syms[3]
@test vsyms[1] <= syms[1]
@test vsyms[2] <= syms[3]

end

@testset "Buffer" begin
Expand All @@ -62,4 +70,21 @@ vsyms = map(ValueSymbol, syms)
end
end

@testset "Promotion" begin
for i in syms, j in vsyms
@test promote_rule(typeof(i), typeof(j)) == promote_rule(typeof(j), typeof(i)) == ValueSymbol
end
end

@testset "Serialization" begin

ser1 = Serializer(stdin)
@test_broken 1 == 2

ser2 = Serializer(stdout)
@test 4 == Serialization.serialize(ser2, vsyms[1]) # outputs :car4
@test 5 == Serialization.serialize(ser2, vsyms[2]) # outputs :boat4
@test 6 == Serialization.serialize(ser2, vsyms[3]) # output :plane4
end

end

0 comments on commit b34bcb6

Please sign in to comment.