aboutsummaryrefslogtreecommitdiff
path: root/tests/test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.lua')
-rw-r--r--tests/test.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua
new file mode 100644
index 0000000..32e18c7
--- /dev/null
+++ b/tests/test.lua
@@ -0,0 +1,34 @@
1-- Standard function declaration
2function hello(name)
3 print("Hello, " .. name)
4end
5
6-- Local function declaration
7local function secret_formula(x, y)
8 return x * y + 42
9end
10
11-- Function assigned to a variable
12myfunc = function(a, b)
13 return a - b
14end
15
16-- Method-like function
17local MyTable = {}
18function MyTable:greet()
19 print("Greetings!")
20end
21
22-- Nested function
23function outer()
24 local function inner()
25 print("I am inside")
26 end
27 inner()
28end
29
30hello("User")
31secret_formula(1, 2)
32myfunc(10, 5)
33MyTable:greet()
34outer()