Skip to content

Commit 83b2804

Browse files
committed
#1192 improve test
1 parent cd23038 commit 83b2804

File tree

3 files changed

+70
-68
lines changed

3 files changed

+70
-68
lines changed

test/tclient/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ require 'tclient.tests.folders-with-single-file'
55
require 'tclient.tests.load-library'
66
require 'tclient.tests.files-associations'
77
require 'tclient.tests.resolve-completion'
8-
require 'tclient.tests.performance-1'
8+
require 'tclient.tests.performance-jass-common'

test/tclient/tests/performance-1.lua

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
local lclient = require 'lclient'
2+
local util = require 'utility'
3+
local ws = require 'workspace'
4+
local files = require 'files'
5+
local furi = require 'file-uri'
6+
local fs = require 'bee.filesystem'
7+
local await = require 'await'
8+
9+
---@async
10+
lclient():start(function (client)
11+
client:registerFakers()
12+
13+
client:register('workspace/configuration', function ()
14+
return {
15+
{
16+
['workspace.library'] = { '${3rd}/Jass/library' }
17+
},
18+
}
19+
end)
20+
21+
client:initialize()
22+
23+
ws.awaitReady()
24+
25+
local clock = os.clock()
26+
27+
for i = 1, 10 do
28+
local text = [[
29+
local jass = require 'jass.common'
30+
31+
]]
32+
33+
client:awaitRequest('textDocument/didOpen', {
34+
textDocument = {
35+
uri = furi.encode('abc/1.lua'),
36+
languageId = 'lua',
37+
version = i,
38+
text = text,
39+
}
40+
})
41+
42+
for c in ('jass'):gmatch '.' do
43+
text = text .. c
44+
client:awaitRequest('textDocument/didChange', {
45+
textDocument = {
46+
uri = furi.encode('abc/1.lua'),
47+
},
48+
contentChanges = {
49+
{
50+
text = text,
51+
}
52+
}
53+
})
54+
end
55+
56+
local results = client:awaitRequest('textDocument/definition', {
57+
textDocument = { uri = furi.encode('abc/1.lua') },
58+
position = { line = 2, character = 4 },
59+
})
60+
61+
assert(results[1] ~= nil)
62+
63+
client:awaitRequest('textDocument/didClose', {
64+
textDocument = { uri = furi.encode('abc/1.lua') },
65+
})
66+
end
67+
68+
print(('Benchmark [performance-jass-common] takes [%.3f] sec.'):format(os.clock() - clock))
69+
end)

0 commit comments

Comments
 (0)