diff options
author | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
---|---|---|
committer | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
commit | 9b6df71d97a70ee7179949ef9f15368cbf29dcbd (patch) | |
tree | bf7a7e62ed7c164a12bdce437c17262a5235bcec /test/cli/visualize/test.lua | |
parent | 483fe246b6ae8c25d433aa15e43f04f0e71a74d5 (diff) | |
parent | 3e6fd3ce1f2f0528336ded939d776a29bbfaf2eb (diff) | |
download | lua-language-server-9b6df71d97a70ee7179949ef9f15368cbf29dcbd.zip |
Merge branch 'master' of github.com:CppCXY/lua-language-server
Diffstat (limited to 'test/cli/visualize/test.lua')
-rw-r--r-- | test/cli/visualize/test.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/cli/visualize/test.lua b/test/cli/visualize/test.lua new file mode 100644 index 00000000..c9722c32 --- /dev/null +++ b/test/cli/visualize/test.lua @@ -0,0 +1,23 @@ +local visualize = require 'cli.visualize' + +local testDataDir = 'test/cli/visualize/testdata/' + +local function TestVisualize(fileName) + local inputFile = testDataDir .. fileName .. '.txt' + local outputFile = testDataDir .. fileName .. '-expected.txt' + local output = '' + local writer = {} + function writer:write(text) + output = output .. text + end + visualize.visualizeAst(io.open(inputFile):read('a'), writer) + local expectedOutput = io.open(outputFile):read('a') + if expectedOutput ~= output then + -- uncomment this to update reference output + --io.open(outputFile, "w+"):write(output):close() + error('output mismatch for test file ' .. inputFile) + end +end + +TestVisualize('all-types') +TestVisualize('shorten-names') |