From 85ff81f2388cd2ce10a65dfc3d2a00eb137fecae Mon Sep 17 00:00:00 2001 From: Felipe Garcia Date: Tue, 6 Oct 2020 20:45:12 -0300 Subject: [PATCH] Add Lua syntax test. --- tests/syntax-tests/highlighted/Lua/test.lua | 34 +++++++++++++++++++++ tests/syntax-tests/source/Lua/test.lua | 34 +++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tests/syntax-tests/highlighted/Lua/test.lua create mode 100644 tests/syntax-tests/source/Lua/test.lua diff --git a/tests/syntax-tests/highlighted/Lua/test.lua b/tests/syntax-tests/highlighted/Lua/test.lua new file mode 100644 index 00000000..3c37aeee --- /dev/null +++ b/tests/syntax-tests/highlighted/Lua/test.lua @@ -0,0 +1,34 @@ +--- Finds factorial of a number. +-- @param value Number to find factorial. +-- @return Factorial of number. +local function factorial(value) + if value <= 1 then + return 1 + else + return value * factorial(value - 1) + end +end + +--- Joins a table of strings into a new string. +-- @param table Table of strings. +-- @param separator Separator character. +-- @return Joined string. +local function join(table, separator) + local data = "" +  + for index, value in ipairs(table) do + data = data .. value .. separator + end +  + data = data:sub(1, data:len() - 1) +  + return data +end + +local a = factorial(5) + +print(a) + +local b = join({ "l", "u", "a" }, ",") + +print(b) diff --git a/tests/syntax-tests/source/Lua/test.lua b/tests/syntax-tests/source/Lua/test.lua new file mode 100644 index 00000000..68eb90e6 --- /dev/null +++ b/tests/syntax-tests/source/Lua/test.lua @@ -0,0 +1,34 @@ +--- Finds factorial of a number. +-- @param value Number to find factorial. +-- @return Factorial of number. +local function factorial(value) + if value <= 1 then + return 1 + else + return value * factorial(value - 1) + end +end + +--- Joins a table of strings into a new string. +-- @param table Table of strings. +-- @param separator Separator character. +-- @return Joined string. +local function join(table, separator) + local data = "" + + for index, value in ipairs(table) do + data = data .. value .. separator + end + + data = data:sub(1, data:len() - 1) + + return data +end + +local a = factorial(5) + +print(a) + +local b = join({ "l", "u", "a" }, ",") + +print(b)