Skip to content
This repository
Newer
Older
100644 66 lines (50 sloc) 1.557 kb
baeeb701 »
2012-01-07 Use Apache 2.0 License consistently throughout luvit
1 --[[
2
3 Copyright 2012 The Luvit Authors. All Rights Reserved.
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS-IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 --]]
18
741d6e62 »
2012-01-06 include helper in test
19 require("helper")
56374c00 »
2012-01-06 add unit test and fix various things
20 local net = require('net')
21
f9ae9bed »
2012-02-06 Dynamically allocate the ports used for network based tests, starting…
22 local PORT = process.env.PORT or 10081
56374c00 »
2012-01-06 add unit test and fix various things
23 local HOST = '127.0.0.1'
24
25 local server = net.createServer(function(client)
26 client:on("data", function (chunk)
aad66882 »
2012-01-06 style nits
27 client:write(chunk, function(err)
56374c00 »
2012-01-06 add unit test and fix various things
28 assert(err == nil)
29 end)
30 end)
31
aad66882 »
2012-01-06 style nits
32 client:on("end", function()
f0baa30a »
2012-04-03 lib: net: make streams use destroy() instead of close()
33 client:destroy()
56374c00 »
2012-01-06 add unit test and fix various things
34 end)
35
36 end)
37
38 server:listen(PORT, HOST, function(err)
39 local client
40 client = net.createConnection(PORT, HOST, function(err)
41 if err then
42 assert(err)
43 end
44 client:on('data', function(data)
45 assert(#data == 5)
46 assert(data == 'hello')
9eba8d26 »
2012-08-09 tests: test-net: double destroy the handlle
47
48 client:destroy()
49 -- Ensure double destroy doesn't return an error
f0baa30a »
2012-04-03 lib: net: make streams use destroy() instead of close()
50 client:destroy()
df9a2b6f »
2012-08-08 tests: test-net: ensure double close returns error
51
9eba8d26 »
2012-08-09 tests: test-net: double destroy the handlle
52 server:close()
df9a2b6f »
2012-08-08 tests: test-net: ensure double close returns error
53 -- Ensure double close returns an error
54 local success, err = pcall(server.close, server)
55 assert(success == false)
53e5ad59 »
2012-08-07 luvit: uv: Handle: avoid double close on handles
56 assert(err)
56374c00 »
2012-01-06 add unit test and fix various things
57 end)
58
59 client:write('hello')
60 end)
61 end)
62
aad66882 »
2012-01-06 style nits
63 server:on("error", function(err)
56374c00 »
2012-01-06 add unit test and fix various things
64 assert(err)
65 end)
Something went wrong with that request. Please try again.