diff options
Diffstat (limited to 'tests/test.lua')
| -rw-r--r-- | tests/test.lua | 34 |
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 | ||
| 2 | function hello(name) | ||
| 3 | print("Hello, " .. name) | ||
| 4 | end | ||
| 5 | |||
| 6 | -- Local function declaration | ||
| 7 | local function secret_formula(x, y) | ||
| 8 | return x * y + 42 | ||
| 9 | end | ||
| 10 | |||
| 11 | -- Function assigned to a variable | ||
| 12 | myfunc = function(a, b) | ||
| 13 | return a - b | ||
| 14 | end | ||
| 15 | |||
| 16 | -- Method-like function | ||
| 17 | local MyTable = {} | ||
| 18 | function MyTable:greet() | ||
| 19 | print("Greetings!") | ||
| 20 | end | ||
| 21 | |||
| 22 | -- Nested function | ||
| 23 | function outer() | ||
| 24 | local function inner() | ||
| 25 | print("I am inside") | ||
| 26 | end | ||
| 27 | inner() | ||
| 28 | end | ||
| 29 | |||
| 30 | hello("User") | ||
| 31 | secret_formula(1, 2) | ||
| 32 | myfunc(10, 5) | ||
| 33 | MyTable:greet() | ||
| 34 | outer() | ||
