|
| 1 | +using JSON |
| 2 | +using Test |
| 3 | +using Distributed: RemoteChannel |
| 4 | + |
| 5 | +@isdefined(a) || include("json-samples.jl") |
| 6 | + |
1 | 7 | finished_async_tests = RemoteChannel()
|
2 | 8 |
|
3 | 9 | using Sockets
|
4 | 10 |
|
5 |
| -@async begin |
6 |
| - s = listen(7777) |
7 |
| - s = accept(s) |
8 |
| - |
9 |
| - Base.start_reading(s) |
10 |
| - |
11 |
| - @test JSON.parse(s) != nothing # a |
12 |
| - @test JSON.parse(s) != nothing # b |
13 |
| - validate_c(s) # c |
14 |
| - @test JSON.parse(s) != nothing # d |
15 |
| - validate_svg_tviewer_menu(s) # svg_tviewer_menu |
16 |
| - @test JSON.parse(s) != nothing # gmaps |
17 |
| - @test JSON.parse(s) != nothing # colors1 |
18 |
| - @test JSON.parse(s) != nothing # colors2 |
19 |
| - @test JSON.parse(s) != nothing # colors3 |
20 |
| - @test JSON.parse(s) != nothing # twitter |
21 |
| - @test JSON.parse(s) != nothing # facebook |
22 |
| - validate_flickr(s) # flickr |
23 |
| - @test JSON.parse(s) != nothing # youtube |
24 |
| - @test JSON.parse(s) != nothing # iphone |
25 |
| - @test JSON.parse(s) != nothing # customer |
26 |
| - @test JSON.parse(s) != nothing # product |
27 |
| - @test JSON.parse(s) != nothing # interop |
28 |
| - validate_unicode(s) # unicode |
29 |
| - @test JSON.parse(s) != nothing # issue5 |
30 |
| - @test JSON.parse(s) != nothing # dollars |
31 |
| - @test JSON.parse(s) != nothing # brackets |
32 |
| - |
33 |
| - put!(finished_async_tests, nothing) |
| 11 | +let serv = listen(7777) |
| 12 | + @async let s; try |
| 13 | + s = accept(serv) |
| 14 | + close(serv) |
| 15 | + @test JSON.parse(s) != nothing # a |
| 16 | + @test JSON.parse(s) != nothing # b |
| 17 | + validate_c(s) # c |
| 18 | + @test JSON.parse(s) != nothing # d |
| 19 | + validate_svg_tviewer_menu(s) # svg_tviewer_menu |
| 20 | + @test JSON.parse(s) != nothing # gmaps |
| 21 | + @test JSON.parse(s) != nothing # colors1 |
| 22 | + @test JSON.parse(s) != nothing # colors2 |
| 23 | + @test JSON.parse(s) != nothing # colors3 |
| 24 | + @test JSON.parse(s) != nothing # twitter |
| 25 | + @test JSON.parse(s) != nothing # facebook |
| 26 | + validate_flickr(s) # flickr |
| 27 | + @test JSON.parse(s) != nothing # youtube |
| 28 | + @test JSON.parse(s) != nothing # iphone |
| 29 | + @test JSON.parse(s) != nothing # customer |
| 30 | + @test JSON.parse(s) != nothing # product |
| 31 | + @test JSON.parse(s) != nothing # interop |
| 32 | + validate_unicode(s) # unicode |
| 33 | + @test JSON.parse(s) != nothing # issue5 |
| 34 | + @test JSON.parse(s) != nothing # dollars |
| 35 | + @test JSON.parse(s) != nothing # brackets |
| 36 | + |
| 37 | + put!(finished_async_tests, nothing) |
| 38 | + catch ex |
| 39 | + @error "async test failure" _exception=ex |
| 40 | + finally |
| 41 | + @isdefined(s) && close(s) |
| 42 | + close(serv) |
| 43 | + end; end |
34 | 44 | end
|
35 | 45 |
|
36 |
| -w = connect("localhost", 7777) |
| 46 | +w = connect(Sockets.localhost, 7777) |
37 | 47 |
|
38 | 48 | @test JSON.parse(a) != nothing
|
39 | 49 | write(w, a)
|
|
0 commit comments