diff options
Diffstat (limited to 'test/tests')
| -rw-r--r-- | test/tests/call.lua | 4 | ||||
| -rw-r--r-- | test/tests/valid_snippits/call.lua | 22 | ||||
| -rw-r--r-- | test/tests/valid_snippits/forinloop.lua | 10 | ||||
| -rw-r--r-- | test/tests/valid_snippits/fornumloop.lua | 10 | ||||
| -rw-r--r-- | test/tests/valid_snippits/invoke.lua | 12 | ||||
| -rw-r--r-- | test/tests/valid_snippits/string.lua | 8 |
6 files changed, 65 insertions, 1 deletions
diff --git a/test/tests/call.lua b/test/tests/call.lua index 8549b7f..db79cf9 100644 --- a/test/tests/call.lua +++ b/test/tests/call.lua @@ -1,4 +1,6 @@ - +describe("Should minify calls to other functions correctly",function() + local minitxt = glum. +end) function afunction() print("You called a function!") end diff --git a/test/tests/valid_snippits/call.lua b/test/tests/valid_snippits/call.lua new file mode 100644 index 0000000..8549b7f --- /dev/null +++ b/test/tests/valid_snippits/call.lua @@ -0,0 +1,22 @@ + +function afunction() + print("You called a function!") +end + +function anotherfunction(num) + print("Thanks, I love " .. num .. "!") + return num == 0 and 1 or anotherfunction(num-1) +end + +local function yetanotherfunction(num) + print("Ew, I don't like " .. num .. ".") + return num <= 0 and 1 or yetanotherfunction(num/2) +end + +afunction() + +for k = 100,1000,100 do + anotherfunction(k) +end + +yetanotherfunction(2000) diff --git a/test/tests/valid_snippits/forinloop.lua b/test/tests/valid_snippits/forinloop.lua new file mode 100644 index 0000000..b9ee57b --- /dev/null +++ b/test/tests/valid_snippits/forinloop.lua @@ -0,0 +1,10 @@ + +local tbl = { + "Alpha", + "Beta", + "Charlie", +} + +for k,v in pairs(tbl) do + print(v) +end diff --git a/test/tests/valid_snippits/fornumloop.lua b/test/tests/valid_snippits/fornumloop.lua new file mode 100644 index 0000000..19ee201 --- /dev/null +++ b/test/tests/valid_snippits/fornumloop.lua @@ -0,0 +1,10 @@ + +local tbl = { + "Alpha", + "Beta", + "Charlie", +} + +for k = 1,#tbl do + print(v) +end diff --git a/test/tests/valid_snippits/invoke.lua b/test/tests/valid_snippits/invoke.lua new file mode 100644 index 0000000..568bc2d --- /dev/null +++ b/test/tests/valid_snippits/invoke.lua @@ -0,0 +1,12 @@ +local something = {} + +something.givenumber = function(self,num) + print("Thanks, I love " .. num .. "! It's much better than " .. self.lastnum) + self.lastnum = num +end + +something.lastnum = 0 + +something:givenumber(1) +something:givenumber(2) +something:givenumber(10) diff --git a/test/tests/valid_snippits/string.lua b/test/tests/valid_snippits/string.lua new file mode 100644 index 0000000..769d528 --- /dev/null +++ b/test/tests/valid_snippits/string.lua @@ -0,0 +1,8 @@ +local string = "what" + +local tbl = {} +local tbl2 = {} + +tbl[string] = 10 +tbl2.what = 10 +assert(tbl.what == tbl2[string],"Not equal") |
