11:5270185b6e41
Anton Shestakov <av6@dwimlabs.net>, Fri, 09 Sep 2016 01:06:05 +0800
spec: check that file handles are indeed open file handles

next change 12:928e6b6d811d
previous change 10:22909b024e86

spec/hglib_spec.lua

Permissions: -rw-r--r--

Other formats: Feeds:
local hglib = require('hglib')
describe('hglib helper functions', function()
describe('decode_i4', function()
it('can decode 0', function()
assert.are_equal(0, hglib.decode_i4('\0\0\0\0'))
end)
it('can decode 255', function()
assert.are_equal(255, hglib.decode_i4('\0\0\0\255'))
end)
it('can decode 256', function()
assert.are_equal(256, hglib.decode_i4('\0\0\1\0'))
end)
it('can decode -1', function()
assert.are_equal(-1, hglib.decode_i4('\255\255\255\255'))
end)
end)
end)
describe('hglib client', function()
it('can connect using just file handles', function()
local rh = io.open('spec/data/hello', 'rb')
local client = hglib.Client.connect(rh, nil)
rh:close()
assert.is_true(client.capabilities.getencoding)
assert.is_true(client.capabilities.runcommand)
assert.are_equal('UTF-8', client.encoding)
assert.are_equal(3615, client.pid)
assert.are_equal(3615, client.pgid)
end)
it('can launch a new cmdserver process', function()
local client = hglib.Client.open()
assert.is_true(client.capabilities.getencoding)
assert.is_true(client.capabilities.runcommand)
assert.are_equal('string', type(client.encoding))
assert.are_equal('number', type(client.pid))
assert.are_equal('number', type(client.lpcpid))
assert.are_equal('file', io.type(client.rh))
assert.are_equal('file', io.type(client.wh))
client:close()
end)
it('can send getencoding command', function()
local client = hglib.Client.open()
local encoding, err = client:getencoding()
client:close()
assert.is_nil(err)
assert.are_equal('string', type(encoding))
end)
end)