-
Notifications
You must be signed in to change notification settings - Fork 98
/
runtests.jl
58 lines (46 loc) · 2.03 KB
/
runtests.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Base.Test
using POMDPs
mutable struct A <: POMDP{Int,Bool,Bool} end
@test_throws MethodError n_states(A())
@test_throws MethodError state_index(A(), 1)
@test !@implemented discount(::A)
POMDPs.discount(::A) = 0.95
@test @implemented discount(::A)
@test !@implemented reward(::A,::Int,::Bool,::Int)
@test !@implemented reward(::A,::Int,::Bool)
POMDPs.reward(::A,::Int,::Bool) = -1.0
@test @implemented reward(::A,::Int,::Bool,::Int)
@test @implemented reward(::A,::Int,::Bool)
@test !@implemented observation(::A,::Int,::Bool,::Int)
@test !@implemented observation(::A,::Bool,::Int)
POMDPs.observation(::A,::Bool,::Int) = [true, false]
@test @implemented observation(::A,::Int,::Bool,::Int)
@test @implemented observation(::A,::Bool,::Int)
mutable struct D end
POMDPs.sampletype(::Type{D}) = Int
@test @implemented sampletype(::D)
@test sampletype(D()) == Int
struct E end
@test_throws MethodError sampletype(E)
@test_throws MethodError sampletype(E())
include("test_inferrence.jl")
include("test_requirements.jl")
include("test_generative.jl")
include("test_tutorials.jl")
include("test_generative_backedges.jl")
let
struct CI <: POMDP{Int,Int,Int} end
struct CV <: POMDP{Vector{Float64},Vector{Float64},Vector{Float64}} end
@test convert_s(Vector{Float32}, 1, CI()) == Float32[1.0]
@test convert_s(state_type(CI), Float32[1.0], CI()) == 1
@test convert_s(state_type(CV), Float32[2.0,3.0], CV()) == [2.0, 3.0]
@test convert_s(Vector{Float32}, [2.0, 3.0], CV()) == Float32[2.0, 3.0]
@test convert_a(Vector{Float32}, 1, CI()) == Float32[1.0]
@test convert_a(state_type(CI), Float32[1.0], CI()) == 1
@test convert_a(state_type(CV), Float32[2.0,3.0], CV()) == [2.0, 3.0]
@test convert_a(Vector{Float32}, [2.0, 3.0], CV()) == Float32[2.0, 3.0]
@test convert_o(Vector{Float32}, 1, CI()) == Float32[1.0]
@test convert_o(state_type(CI), Float32[1.0], CI()) == 1
@test convert_o(state_type(CV), Float32[2.0,3.0], CV()) == [2.0, 3.0]
@test convert_o(Vector{Float32}, [2.0, 3.0], CV()) == Float32[2.0, 3.0]
end