diff options
author | elioat <elioat@tilde.institute> | 2024-06-09 20:54:53 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-06-09 20:54:53 -0400 |
commit | 3ff223f2a297a7300fede33dbe69da63f08e0c84 (patch) | |
tree | 0576d764fe9ab6e22b735e261237502bd1cf7f31 /lua/chupacabra/test_chupacabra.lua | |
parent | 252f3076873868dee5cec2b4b571b47673c1cf06 (diff) | |
download | tour-3ff223f2a297a7300fede33dbe69da63f08e0c84.tar.gz |
*
Diffstat (limited to 'lua/chupacabra/test_chupacabra.lua')
-rw-r--r-- | lua/chupacabra/test_chupacabra.lua | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/lua/chupacabra/test_chupacabra.lua b/lua/chupacabra/test_chupacabra.lua index 0a06124..5cf04e0 100644 --- a/lua/chupacabra/test_chupacabra.lua +++ b/lua/chupacabra/test_chupacabra.lua @@ -1,22 +1,10 @@ local chupacabra = require("chupacabra") -local function table_to_string(t) - local str = "[" - for i, v in ipairs(t) do - if i > 1 then - str = str .. " " - end - str = str .. tostring(v) - end - str = str .. "]" - return str -end - -- test cases local function tc(input, expected_output) local output = chupacabra.run(input, {}) - local expected_output_str = type(expected_output) == "table" and table_to_string(expected_output) or tostring(expected_output) - local output_str = type(output) == "table" and table_to_string(output) or tostring(output) + local expected_output_str = type(expected_output) == "table" and chupacabra.table_to_string(expected_output) or tostring(expected_output) + local output_str = type(output) == "table" and chupacabra.table_to_string(output) or tostring(output) assert(output_str == expected_output_str, "Test failed: " .. input .. " => " .. output_str .. ", expected: " .. expected_output_str) print("Test passed: " .. input .. " => " .. output_str) end |