about summary refs log tree commit diff stats
path: root/lua/chupacabra/test_chupacabra.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/chupacabra/test_chupacabra.lua')
-rw-r--r--lua/chupacabra/test_chupacabra.lua16
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