feat: format
This commit is contained in:
parent
d5b3c9a881
commit
0951944e8c
2 changed files with 18 additions and 7 deletions
|
|
@ -248,7 +248,9 @@ local function toggle_test_panel()
|
||||||
logger.log(("navigating test by %d"):format(delta))
|
logger.log(("navigating test by %d"):format(delta))
|
||||||
local test_state = test_module.get_test_panel_state()
|
local test_state = test_module.get_test_panel_state()
|
||||||
local new_index = test_state.current_index + delta
|
local new_index = test_state.current_index + delta
|
||||||
logger.log(("current: %d, new: %d, total: %d"):format(test_state.current_index, new_index, #test_state.test_cases))
|
logger.log(
|
||||||
|
("current: %d, new: %d, total: %d"):format(test_state.current_index, new_index, #test_state.test_cases)
|
||||||
|
)
|
||||||
if new_index >= 1 and new_index <= #test_state.test_cases then
|
if new_index >= 1 and new_index <= #test_state.test_cases then
|
||||||
test_state.current_index = new_index
|
test_state.current_index = new_index
|
||||||
toggle_test_panel()
|
toggle_test_panel()
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ function M.scrape_problem(ctx)
|
||||||
table.insert(test_cases, {
|
table.insert(test_cases, {
|
||||||
index = i,
|
index = i,
|
||||||
input = input_content,
|
input = input_content,
|
||||||
output = expected_content
|
output = expected_content,
|
||||||
})
|
})
|
||||||
i = i + 1
|
i = i + 1
|
||||||
else
|
else
|
||||||
|
|
@ -228,7 +228,6 @@ function M.scrape_problem(ctx)
|
||||||
timeout = 30000,
|
timeout = 30000,
|
||||||
}):wait()
|
}):wait()
|
||||||
|
|
||||||
|
|
||||||
if result.code ~= 0 then
|
if result.code ~= 0 then
|
||||||
return {
|
return {
|
||||||
success = false,
|
success = false,
|
||||||
|
|
@ -246,7 +245,6 @@ function M.scrape_problem(ctx)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if not data.success then
|
if not data.success then
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
@ -269,8 +267,20 @@ function M.scrape_problem(ctx)
|
||||||
vim.fn.writefile(vim.split(expected_content, "\n", true), expected_file)
|
vim.fn.writefile(vim.split(expected_content, "\n", true), expected_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
local combined_input = data.combined and data.combined.input:gsub("\r", "") or table.concat(vim.tbl_map(function(tc) return tc.input end, data.test_cases), "\n")
|
local combined_input = data.combined and data.combined.input:gsub("\r", "")
|
||||||
local combined_output = data.combined and data.combined.output:gsub("\r", "") or table.concat(vim.tbl_map(function(tc) return tc.output end, data.test_cases), "\n")
|
or table.concat(
|
||||||
|
vim.tbl_map(function(tc)
|
||||||
|
return tc.input
|
||||||
|
end, data.test_cases),
|
||||||
|
"\n"
|
||||||
|
)
|
||||||
|
local combined_output = data.combined and data.combined.output:gsub("\r", "")
|
||||||
|
or table.concat(
|
||||||
|
vim.tbl_map(function(tc)
|
||||||
|
return tc.output
|
||||||
|
end, data.test_cases),
|
||||||
|
"\n"
|
||||||
|
)
|
||||||
|
|
||||||
if ctx.contest == "atcoder" then
|
if ctx.contest == "atcoder" then
|
||||||
combined_input = tostring(#data.test_cases) .. "\n" .. combined_input
|
combined_input = tostring(#data.test_cases) .. "\n" .. combined_input
|
||||||
|
|
@ -280,7 +290,6 @@ function M.scrape_problem(ctx)
|
||||||
vim.fn.writefile(vim.split(combined_output, "\n", true), ctx.expected_file)
|
vim.fn.writefile(vim.split(combined_output, "\n", true), ctx.expected_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success = true,
|
success = true,
|
||||||
problem_id = ctx.problem_name,
|
problem_id = ctx.problem_name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue