-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_def.jl
41 lines (35 loc) · 949 Bytes
/
test_def.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module TestDef
using Test
using InitialValues: Init, hasinitialvalue, isknown
module CleanNameSpace
using InitialValues: @def, @disambiguate
add(x, y) = x + y
got(x) = string("Got: ", repr(x))
@def add got(x)
@disambiguate add Missing
end
@testset "CleanNameSpace" begin
add = CleanNameSpace.add
@test !isdefined(CleanNameSpace, :InitialValues)
@test hasinitialvalue(add)
@test isknown(Init(add))
@test add(Init(add), :x) == "Got: :x"
@test add(Init(add), missing) === missing
end
module NonFunction
using InitialValues: @def, @disambiguate
struct Add end
const add = Add()
add(x, y) = x + y
@def add
@disambiguate add Missing
end
@testset "NonFunction" begin
add = NonFunction.add
@test !(add isa Function)
@test hasinitialvalue(add)
@test isknown(Init(add))
@test add(Init(add), :x) == :x
@test add(Init(add), missing) === missing
end
end # module