-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathruntests.jl
57 lines (56 loc) · 1.89 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
using TableView
using Test, WebIO, Tables, JSON
@testset "installation" begin
version = readchomp(joinpath(@__DIR__, "..", "ag-grid.version"))
@test isfile(joinpath(@__DIR__, "..", "deps", "ag-grid-$(version)", "ag-grid.js"))
end
@testset "named tuple table" begin
nttable = [
(a = 2.0, b = 3),
(a = 3.0, b = 12)
]
@test showtable(nttable) isa WebIO.Scope
end
@testset "named tuple table with missing and nothing" begin
nttable = [
(a = 2.0, b = 3, c = missing),
(a = 3.0, b = 12, c = nothing)
]
@test showtable(nttable) isa WebIO.Scope
end
@testset "inf, nan, and missing serializing" begin
rows = Tables.table([NaN Inf -Inf 0 missing])
names = [:a, :b, :c, :d, :e]
types = vcat([Float64 for _ in 1:4], [Missing])
Base.show(io::IO, x::Missing) = print(io, "test_missing")
json = TableView.table2json(Tables.Schema(names, types), rows, types)
firstrow = JSON.parse(json)[1]
@test firstrow["a"] == "NaN"
@test firstrow["b"] == "Inf"
@test firstrow["c"] == "-Inf"
@test firstrow["d"] == 0
@test firstrow["e"] == "test_missing"
end
@testset "large integers" begin
rows = Tables.table([2^52 2^53 2^54])
names = [:a, :b, :c]
types = [Int64 for _ in 1:3]
json = TableView.table2json(Tables.Schema(names, types), rows, types)
firstrow = JSON.parse(json)[1]
@test firstrow["a"] == 4503599627370496
@test firstrow["b"] == "9007199254740992"
@test firstrow["c"] == "18014398509481984"
end
@testset "large floats" begin
rows = Tables.table([1.0e50 1.0e100])
names = [:a, :b]
types = [Float64, Float64]
json = TableView.table2json(Tables.Schema(names, types), rows, types)
firstrow = JSON.parse(json)[1]
@test firstrow["a"] == "1.0e50"
@test firstrow["b"] == "1.0e100"
end
@testset "normal array" begin
array = rand(10, 10)
@test showtable(array) isa WebIO.Scope
end