Skip to content

Commit 0f9ff61

Browse files
committed
Use testsetup
1 parent ddf995e commit 0f9ff61

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

test/shared_test_code.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
using JSONRPC: @dict_readable, Outbound
1+
@testmodule TestStructs begin
2+
using JSONRPC: @dict_readable, Outbound
23

3-
@dict_readable struct Foo <: Outbound
4-
fieldA::Int
5-
fieldB::String
6-
fieldC::Union{Missing,String}
7-
fieldD::Union{String,Missing}
8-
end
4+
export Foo, Foo2
95

10-
@dict_readable struct Foo2 <: Outbound
11-
fieldA::Union{Nothing,Int}
12-
fieldB::Vector{Int}
13-
end
6+
@dict_readable struct Foo <: Outbound
7+
fieldA::Int
8+
fieldB::String
9+
fieldC::Union{Missing,String}
10+
fieldD::Union{String,Missing}
11+
end
12+
13+
@dict_readable struct Foo2 <: Outbound
14+
fieldA::Union{Nothing,Int}
15+
fieldB::Vector{Int}
16+
end
1417

15-
Base.:(==)(a::Foo2,b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
18+
Base.:(==)(a::Foo2,b::Foo2) = a.fieldA == b.fieldA && a.fieldB == b.fieldB
19+
20+
end

test/test_interface_def.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@testitem "Interface Definition" begin
1+
@testitem "Interface Definition" setup=[TestStructs] begin
22
using JSON
3-
include("shared_test_code.jl")
3+
using .TestStructs: Foo, Foo2
44

55
@test_throws ErrorException Foo()
66

test/test_typed.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
@testitem "Message dispatcher" begin
1+
@testitem "Dynamic message dispatcher" setup=[TestStructs] begin
22
using Sockets
3-
4-
include("shared_test_code.jl")
3+
using .TestStructs: Foo, Foo2
54

65
if Sys.iswindows()
76
global_socket_name1 = "\\\\.\\pipe\\jsonrpc-testrun1"

0 commit comments

Comments
 (0)